@clypra-studio/engine 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{chunk-LT3HTJ3X.js → chunk-3UEOLDJJ.js} +5 -829
- package/dist/chunk-3UEOLDJJ.js.map +1 -0
- package/dist/{chunk-Y4FMAOTW.js → chunk-E6O6LZME.js} +266 -1004
- package/dist/chunk-E6O6LZME.js.map +1 -0
- package/dist/chunk-PU3Q4QI7.js +833 -0
- package/dist/chunk-PU3Q4QI7.js.map +1 -0
- package/dist/{index-D6GAXDBy.d.cts → index-C18SQ-y6.d.cts} +171 -37
- package/dist/{index-D6GAXDBy.d.ts → index-C18SQ-y6.d.ts} +171 -37
- package/dist/index.cjs +11149 -23528
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2087 -7834
- package/dist/index.d.ts +2087 -7834
- package/dist/index.js +10059 -17971
- package/dist/index.js.map +1 -1
- package/dist/textEffects/index.cjs +259 -971
- package/dist/textEffects/index.cjs.map +1 -1
- package/dist/textEffects/index.d.cts +1 -1
- package/dist/textEffects/index.d.ts +1 -1
- package/dist/textEffects/index.js +1 -1
- package/dist/transitions/index.cjs +18 -2199
- package/dist/transitions/index.cjs.map +1 -1
- package/dist/transitions/index.d.cts +37 -53
- package/dist/transitions/index.d.ts +37 -53
- package/dist/transitions/index.js +3 -51
- package/dist/videoEffects/index.cjs +4 -835
- package/dist/videoEffects/index.cjs.map +1 -1
- package/dist/videoEffects/index.d.cts +9 -138
- package/dist/videoEffects/index.d.ts +9 -138
- package/dist/videoEffects/index.js +1 -15
- package/package.json +13 -16
- package/dist/TransitionDefinition-CQoSb4ZB.d.cts +0 -158
- package/dist/TransitionDefinition-CQoSb4ZB.d.ts +0 -158
- package/dist/chunk-FIJBB3MH.js +0 -2990
- package/dist/chunk-FIJBB3MH.js.map +0 -1
- package/dist/chunk-LT3HTJ3X.js.map +0 -1
- package/dist/chunk-RYA4KGDB.js +0 -690
- package/dist/chunk-RYA4KGDB.js.map +0 -1
- package/dist/chunk-Y4FMAOTW.js.map +0 -1
- package/dist/index-BdQ3oRT4.d.cts +0 -139
- package/dist/index-BdQ3oRT4.d.ts +0 -139
- package/dist/v2/backends/index.cjs +0 -693
- package/dist/v2/backends/index.cjs.map +0 -1
- package/dist/v2/backends/index.d.cts +0 -3
- package/dist/v2/backends/index.d.ts +0 -3
- package/dist/v2/backends/index.js +0 -8
- package/dist/v2/backends/index.js.map +0 -1
package/dist/chunk-RYA4KGDB.js
DELETED
|
@@ -1,690 +0,0 @@
|
|
|
1
|
-
// src/v2/backends/PixiRenderBackend.ts
|
|
2
|
-
import * as PIXI from "pixi.js";
|
|
3
|
-
import { AdjustmentFilter } from "pixi-filters";
|
|
4
|
-
|
|
5
|
-
// src/effects/light/ColorAdjustmentsEffect.ts
|
|
6
|
-
import { Filter } from "pixi.js";
|
|
7
|
-
function mergeGradingParams(presetParams, manualAdjustments) {
|
|
8
|
-
if (!presetParams && !manualAdjustments) return {};
|
|
9
|
-
const merged = { ...presetParams };
|
|
10
|
-
if (manualAdjustments) {
|
|
11
|
-
if ("exposure" in manualAdjustments) merged.exposure = manualAdjustments.exposure;
|
|
12
|
-
if ("brightness" in manualAdjustments) merged.brightness = manualAdjustments.brightness;
|
|
13
|
-
if ("contrast" in manualAdjustments) merged.contrast = manualAdjustments.contrast;
|
|
14
|
-
if ("saturation" in manualAdjustments) merged.saturation = manualAdjustments.saturation;
|
|
15
|
-
if ("temperature" in manualAdjustments) merged.temperature = manualAdjustments.temperature;
|
|
16
|
-
if ("tint" in manualAdjustments) merged.tint = manualAdjustments.tint;
|
|
17
|
-
if ("sepia" in manualAdjustments) merged.sepia = manualAdjustments.sepia;
|
|
18
|
-
if ("grayscale" in manualAdjustments) merged.grayscale = manualAdjustments.grayscale;
|
|
19
|
-
if ("hue" in manualAdjustments) merged.hueRotate = manualAdjustments.hue * Math.PI / 180;
|
|
20
|
-
if ("vignette" in manualAdjustments) merged.vignette = manualAdjustments.vignette;
|
|
21
|
-
if ("invert" in manualAdjustments) merged.invert = manualAdjustments.invert ? 1 : 0;
|
|
22
|
-
if ("lift" in manualAdjustments) merged.lift = manualAdjustments.lift;
|
|
23
|
-
if ("vibrance" in manualAdjustments) merged.vibrance = manualAdjustments.vibrance;
|
|
24
|
-
if ("grain" in manualAdjustments) merged.grain = manualAdjustments.grain;
|
|
25
|
-
if ("crossProcess" in manualAdjustments) merged.crossProcess = manualAdjustments.crossProcess;
|
|
26
|
-
}
|
|
27
|
-
return merged;
|
|
28
|
-
}
|
|
29
|
-
var ADJUSTMENTS_VERTEX_SHADER = `
|
|
30
|
-
in vec2 aPosition;
|
|
31
|
-
out vec2 vTextureCoord;
|
|
32
|
-
|
|
33
|
-
uniform vec4 uInputSize;
|
|
34
|
-
uniform vec4 uOutputFrame;
|
|
35
|
-
uniform vec4 uOutputTexture;
|
|
36
|
-
|
|
37
|
-
vec4 filterVertexPosition( void )
|
|
38
|
-
{
|
|
39
|
-
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
40
|
-
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
41
|
-
position.y = position.y * (2.0 * uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
42
|
-
return vec4(position, 0.0, 1.0);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
vec2 filterTextureCoord( void )
|
|
46
|
-
{
|
|
47
|
-
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
void main(void)
|
|
51
|
-
{
|
|
52
|
-
gl_Position = filterVertexPosition();
|
|
53
|
-
vTextureCoord = filterTextureCoord();
|
|
54
|
-
}
|
|
55
|
-
`;
|
|
56
|
-
var ADJUSTMENTS_FRAGMENT_SHADER = `
|
|
57
|
-
in vec2 vTextureCoord;
|
|
58
|
-
out vec4 finalColor;
|
|
59
|
-
|
|
60
|
-
uniform sampler2D uTexture;
|
|
61
|
-
|
|
62
|
-
// \u2500\u2500 Existing uniforms \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
63
|
-
uniform float uExposure; // -1.0 to 1.0
|
|
64
|
-
uniform float uBrightness; // -1.0 to 1.0
|
|
65
|
-
uniform float uContrast; // -1.0 to 1.0
|
|
66
|
-
uniform float uSaturation; // -1.0 to 1.0
|
|
67
|
-
uniform vec3 uTemperatureColor; // warm or cool color
|
|
68
|
-
uniform float uTemperatureWeight; // 0.0 to 1.0
|
|
69
|
-
uniform vec3 uTintColor; // magenta or green color
|
|
70
|
-
uniform float uTintWeight; // 0.0 to 1.0
|
|
71
|
-
uniform float uSepia; // 0.0 to 1.0
|
|
72
|
-
uniform float uGrayscale; // 0.0 to 1.0
|
|
73
|
-
uniform float uHueRotate; // radians
|
|
74
|
-
uniform float uVignette; // 0.0 to 1.0
|
|
75
|
-
uniform float uInvert; // 0.0 to 1.0
|
|
76
|
-
|
|
77
|
-
// \u2500\u2500 NEW: Lift \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
78
|
-
uniform float uLift; // -0.2 to 0.2; positive = faded/matte, negative = crushed
|
|
79
|
-
|
|
80
|
-
// \u2500\u2500 NEW: Split-toning \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
81
|
-
uniform vec3 uShadowTint; // multiplicative color for shadows (neutral = vec3(1))
|
|
82
|
-
uniform float uShadowTintStrength;
|
|
83
|
-
uniform vec3 uHighlightTint; // multiplicative color for highlights (neutral = vec3(1))
|
|
84
|
-
uniform float uHighlightTintStrength;
|
|
85
|
-
uniform float uSplitBalance; // 0.0-1.0, luma split point
|
|
86
|
-
|
|
87
|
-
// \u2500\u2500 NEW: Film grain \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
88
|
-
uniform float uGrainIntensity; // 0.0 to 0.5
|
|
89
|
-
uniform float uGrainSize; // 0.1 to 5.0
|
|
90
|
-
uniform float uTime; // animated, incremented each frame
|
|
91
|
-
|
|
92
|
-
// \u2500\u2500 NEW: Channel-mix B&W \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
93
|
-
uniform vec3 uChannelMix; // R/G/B weights summing to ~1.0
|
|
94
|
-
uniform float uUseChannelMix; // 1.0 = active, 0.0 = off
|
|
95
|
-
|
|
96
|
-
// \u2500\u2500 NEW: Duotone \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
97
|
-
uniform vec3 uDuotoneDark; // color mapped to black/dark tones
|
|
98
|
-
uniform vec3 uDuotoneLight; // color mapped to white/light tones
|
|
99
|
-
uniform float uUseDuotone; // 1.0 = active, 0.0 = off
|
|
100
|
-
|
|
101
|
-
// \u2500\u2500 NEW: Vibrance \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
102
|
-
uniform float uVibranceAmount; // -1.0 to 1.0
|
|
103
|
-
uniform vec3 uVibranceProtectedHue; // reference color for skin-tone protection
|
|
104
|
-
|
|
105
|
-
// \u2500\u2500 NEW: Cross-process \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
106
|
-
uniform float uCrossProcessAmount; // 0.0 to 1.0
|
|
107
|
-
|
|
108
|
-
// \u2500\u2500 Helper functions \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
109
|
-
vec3 hueRotateColor(vec3 color, float angle) {
|
|
110
|
-
vec3 k = vec3(0.57735, 0.57735, 0.57735);
|
|
111
|
-
float c = cos(angle);
|
|
112
|
-
return color * c + cross(k, color) * sin(angle) + k * dot(k, color) * (1.0 - c);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
vec3 rgb2hsv(vec3 c) {
|
|
116
|
-
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
|
117
|
-
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
|
118
|
-
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
|
119
|
-
float d = q.x - min(q.w, q.y);
|
|
120
|
-
float e = 1.0e-10;
|
|
121
|
-
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
vec3 hsv2rgb(vec3 c) {
|
|
125
|
-
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
|
126
|
-
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
|
127
|
-
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
void main() {
|
|
131
|
-
vec4 texColor = texture(uTexture, vTextureCoord);
|
|
132
|
-
vec3 rgb = texColor.rgb;
|
|
133
|
-
|
|
134
|
-
// Invert
|
|
135
|
-
rgb = mix(rgb, 1.0 - rgb, uInvert);
|
|
136
|
-
|
|
137
|
-
// Exposure
|
|
138
|
-
rgb = rgb * pow(2.0, uExposure);
|
|
139
|
-
|
|
140
|
-
// Brightness
|
|
141
|
-
rgb = rgb + uBrightness;
|
|
142
|
-
|
|
143
|
-
// Lift \u2014 shift black point; applied before contrast so it interacts correctly with tonal range
|
|
144
|
-
if (uLift != 0.0) {
|
|
145
|
-
rgb = rgb + uLift * (1.0 - rgb);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Contrast
|
|
149
|
-
rgb = (rgb - 0.5) * (1.0 + uContrast) + 0.5;
|
|
150
|
-
|
|
151
|
-
// Saturation (flat, distinct from vibrance)
|
|
152
|
-
float luma = dot(rgb, vec3(0.2126, 0.7152, 0.0722));
|
|
153
|
-
rgb = mix(vec3(luma), rgb, 1.0 + uSaturation);
|
|
154
|
-
|
|
155
|
-
// Grayscale
|
|
156
|
-
float lumaG = dot(rgb, vec3(0.2126, 0.7152, 0.0722));
|
|
157
|
-
rgb = mix(rgb, vec3(lumaG), uGrayscale);
|
|
158
|
-
|
|
159
|
-
// Sepia
|
|
160
|
-
if (uSepia > 0.0) {
|
|
161
|
-
vec3 sep = vec3(
|
|
162
|
-
dot(rgb, vec3(0.393, 0.769, 0.189)),
|
|
163
|
-
dot(rgb, vec3(0.349, 0.686, 0.168)),
|
|
164
|
-
dot(rgb, vec3(0.272, 0.534, 0.131))
|
|
165
|
-
);
|
|
166
|
-
rgb = mix(rgb, sep, uSepia);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Hue Rotate
|
|
170
|
-
if (uHueRotate != 0.0) {
|
|
171
|
-
rgb = hueRotateColor(rgb, uHueRotate);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// Temperature \u2014 soft-light blend
|
|
175
|
-
if (uTemperatureWeight > 0.0) {
|
|
176
|
-
vec3 t = uTemperatureColor;
|
|
177
|
-
rgb = mix(rgb, (1.0 - 2.0 * t) * rgb * rgb + 2.0 * t * rgb, uTemperatureWeight);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// Tint \u2014 soft-light blend
|
|
181
|
-
if (uTintWeight > 0.0) {
|
|
182
|
-
vec3 t = uTintColor;
|
|
183
|
-
rgb = mix(rgb, (1.0 - 2.0 * t) * rgb * rgb + 2.0 * t * rgb, uTintWeight);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// \u2500\u2500 NEW: Channel-mixed B&W \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
187
|
-
// Applied before duotone; mutually exclusive (both produce mono, duotone adds color back)
|
|
188
|
-
if (uUseChannelMix > 0.5) {
|
|
189
|
-
float mono = dot(rgb, uChannelMix);
|
|
190
|
-
rgb = vec3(mono);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// \u2500\u2500 NEW: Duotone \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
194
|
-
// Maps current luminance to a 2-color gradient; applied after channel-mix for correct mono base
|
|
195
|
-
if (uUseDuotone > 0.5) {
|
|
196
|
-
float duoLuma = dot(rgb, vec3(0.299, 0.587, 0.114));
|
|
197
|
-
rgb = mix(uDuotoneDark, uDuotoneLight, duoLuma);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// \u2500\u2500 NEW: Split-toning \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
201
|
-
if (uShadowTintStrength > 0.0 || uHighlightTintStrength > 0.0) {
|
|
202
|
-
float splitLuma = dot(rgb, vec3(0.299, 0.587, 0.114));
|
|
203
|
-
float shadowW = 1.0 - smoothstep(0.0, uSplitBalance, splitLuma);
|
|
204
|
-
float highlightW = smoothstep(uSplitBalance, 1.0, splitLuma);
|
|
205
|
-
rgb = mix(rgb, rgb * uShadowTint, shadowW * uShadowTintStrength);
|
|
206
|
-
rgb = mix(rgb, rgb * uHighlightTint, highlightW * uHighlightTintStrength);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// \u2500\u2500 NEW: Vibrance \u2014 hue-selective saturation \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
210
|
-
// Skipped when channel-mix or duotone have flattened color information
|
|
211
|
-
if (uVibranceAmount != 0.0 && uUseChannelMix < 0.5 && uUseDuotone < 0.5) {
|
|
212
|
-
vec3 hsv = rgb2hsv(clamp(rgb, 0.0, 1.0));
|
|
213
|
-
vec3 protHSV = rgb2hsv(uVibranceProtectedHue);
|
|
214
|
-
float hueDist = abs(hsv.x - protHSV.x);
|
|
215
|
-
hueDist = min(hueDist, 1.0 - hueDist); // wrap hue distance
|
|
216
|
-
float protection = smoothstep(0.0, 0.15, hueDist);
|
|
217
|
-
hsv.y = clamp(hsv.y + uVibranceAmount * protection, 0.0, 1.0);
|
|
218
|
-
rgb = hsv2rgb(hsv);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// \u2500\u2500 NEW: Cross-process \u2014 channel curve swap \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
222
|
-
if (uCrossProcessAmount > 0.0) {
|
|
223
|
-
float origR = rgb.r;
|
|
224
|
-
float origB = rgb.b;
|
|
225
|
-
rgb.r = mix(rgb.r, pow(max(origB, 0.001), 0.8), uCrossProcessAmount);
|
|
226
|
-
rgb.b = mix(rgb.b, pow(max(origR, 0.001), 1.2), uCrossProcessAmount);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// \u2500\u2500 NEW: Film grain \u2014 last before vignette \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
230
|
-
if (uGrainIntensity > 0.0) {
|
|
231
|
-
float grain = fract(sin(dot(vTextureCoord * uGrainSize + uTime, vec2(12.9898, 78.233))) * 43758.5453);
|
|
232
|
-
rgb += (grain - 0.5) * uGrainIntensity;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
// Vignette
|
|
236
|
-
vec2 uv = vTextureCoord - 0.5;
|
|
237
|
-
float vignetteVal = smoothstep(0.45, 1.0, length(uv));
|
|
238
|
-
rgb = mix(rgb, vec3(0.0), vignetteVal * uVignette);
|
|
239
|
-
|
|
240
|
-
finalColor = vec4(rgb, texColor.a);
|
|
241
|
-
}
|
|
242
|
-
`;
|
|
243
|
-
function hexToRgb(hex) {
|
|
244
|
-
const clean = hex.replace("#", "").padEnd(6, "0");
|
|
245
|
-
const r = parseInt(clean.substring(0, 2), 16) / 255;
|
|
246
|
-
const g = parseInt(clean.substring(2, 4), 16) / 255;
|
|
247
|
-
const b = parseInt(clean.substring(4, 6), 16) / 255;
|
|
248
|
-
return [isNaN(r) ? 1 : r, isNaN(g) ? 1 : g, isNaN(b) ? 1 : b];
|
|
249
|
-
}
|
|
250
|
-
var ColorAdjustmentsEffect = {
|
|
251
|
-
backend: "pixi",
|
|
252
|
-
subtype: "filter",
|
|
253
|
-
id: "color-adjustments",
|
|
254
|
-
name: "Color Adjustments",
|
|
255
|
-
category: "light",
|
|
256
|
-
description: "Adjust exposure, brightness, contrast, saturation, temperature, tint, sepia, grayscale, hue, invert, vignette, lift, split-toning, grain, channel-mix, duotone, vibrance, and cross-process.",
|
|
257
|
-
tags: ["color", "adjustments", "brightness", "contrast", "saturation", "temperature", "tint", "vignette", "grain", "duotone", "vibrance"],
|
|
258
|
-
thumbnail: "",
|
|
259
|
-
params: [
|
|
260
|
-
// ── Existing ───────────────────────────────────────────────────────────
|
|
261
|
-
{ key: "exposure", label: "Exposure", type: "range", value: 0, min: -1, max: 1, step: 0.01 },
|
|
262
|
-
{ key: "brightness", label: "Brightness", type: "range", value: 0, min: -1, max: 1, step: 0.01 },
|
|
263
|
-
{ key: "contrast", label: "Contrast", type: "range", value: 0, min: -1, max: 1, step: 0.01 },
|
|
264
|
-
{ key: "saturation", label: "Saturation", type: "range", value: 0, min: -1, max: 1, step: 0.01 },
|
|
265
|
-
{ key: "temperature", label: "Temperature", type: "range", value: 0, min: -1, max: 1, step: 0.01 },
|
|
266
|
-
{ key: "tint", label: "Tint", type: "range", value: 0, min: -1, max: 1, step: 0.01 },
|
|
267
|
-
{ key: "sepia", label: "Sepia", type: "range", value: 0, min: 0, max: 1, step: 0.01 },
|
|
268
|
-
{ key: "grayscale", label: "Grayscale", type: "range", value: 0, min: 0, max: 1, step: 0.01 },
|
|
269
|
-
{ key: "hueRotate", label: "Hue Rotate", type: "range", value: 0, min: 0, max: 6.28318, step: 0.01 },
|
|
270
|
-
{ key: "vignette", label: "Vignette", type: "range", value: 0, min: 0, max: 1, step: 0.01 },
|
|
271
|
-
{ key: "invert", label: "Invert", type: "range", value: 0, min: 0, max: 1, step: 0.01 },
|
|
272
|
-
// ── NEW ────────────────────────────────────────────────────────────────
|
|
273
|
-
{ key: "lift", label: "Lift", type: "range", value: 0, min: -0.5, max: 0.5, step: 0.01 },
|
|
274
|
-
{ key: "shadowTintR", label: "Shadow Tint R", type: "range", value: 1, min: 0, max: 2, step: 0.01 },
|
|
275
|
-
{ key: "shadowTintG", label: "Shadow Tint G", type: "range", value: 1, min: 0, max: 2, step: 0.01 },
|
|
276
|
-
{ key: "shadowTintB", label: "Shadow Tint B", type: "range", value: 1, min: 0, max: 2, step: 0.01 },
|
|
277
|
-
{ key: "shadowTintStrength", label: "Shadow Strength", type: "range", value: 0, min: 0, max: 1, step: 0.01 },
|
|
278
|
-
{ key: "highlightTintR", label: "Hi Tint R", type: "range", value: 1, min: 0, max: 2, step: 0.01 },
|
|
279
|
-
{ key: "highlightTintG", label: "Hi Tint G", type: "range", value: 1, min: 0, max: 2, step: 0.01 },
|
|
280
|
-
{ key: "highlightTintB", label: "Hi Tint B", type: "range", value: 1, min: 0, max: 2, step: 0.01 },
|
|
281
|
-
{ key: "highlightTintStrength", label: "Hi Strength", type: "range", value: 0, min: 0, max: 1, step: 0.01 },
|
|
282
|
-
{ key: "splitBalance", label: "Split Balance", type: "range", value: 0.5, min: 0, max: 1, step: 0.01 },
|
|
283
|
-
{ key: "grainIntensity", label: "Grain Intensity", type: "range", value: 0, min: 0, max: 0.5, step: 0.01 },
|
|
284
|
-
{ key: "grainSize", label: "Grain Size", type: "range", value: 1, min: 0.1, max: 5, step: 0.1 },
|
|
285
|
-
{ key: "channelMixR", label: "Channel Mix R", type: "range", value: 0, min: 0, max: 1, step: 0.01 },
|
|
286
|
-
{ key: "channelMixG", label: "Channel Mix G", type: "range", value: 0, min: 0, max: 1, step: 0.01 },
|
|
287
|
-
{ key: "channelMixB", label: "Channel Mix B", type: "range", value: 0, min: 0, max: 1, step: 0.01 },
|
|
288
|
-
{ key: "useChannelMix", label: "Use Channel Mix", type: "range", value: 0, min: 0, max: 1, step: 1 },
|
|
289
|
-
{ key: "duotoneDarkR", label: "Duo Dark R", type: "range", value: 0, min: 0, max: 1, step: 0.01 },
|
|
290
|
-
{ key: "duotoneDarkG", label: "Duo Dark G", type: "range", value: 0, min: 0, max: 1, step: 0.01 },
|
|
291
|
-
{ key: "duotoneDarkB", label: "Duo Dark B", type: "range", value: 0, min: 0, max: 1, step: 0.01 },
|
|
292
|
-
{ key: "duotoneLightR", label: "Duo Light R", type: "range", value: 1, min: 0, max: 1, step: 0.01 },
|
|
293
|
-
{ key: "duotoneLightG", label: "Duo Light G", type: "range", value: 1, min: 0, max: 1, step: 0.01 },
|
|
294
|
-
{ key: "duotoneLightB", label: "Duo Light B", type: "range", value: 1, min: 0, max: 1, step: 0.01 },
|
|
295
|
-
{ key: "useDuotone", label: "Use Duotone", type: "range", value: 0, min: 0, max: 1, step: 1 },
|
|
296
|
-
{ key: "vibranceAmount", label: "Vibrance", type: "range", value: 0, min: -1, max: 1, step: 0.01 },
|
|
297
|
-
{ key: "vibranceProtectedHueR", label: "Vib Protect R", type: "range", value: 0.91, min: 0, max: 1, step: 0.01 },
|
|
298
|
-
{ key: "vibranceProtectedHueG", label: "Vib Protect G", type: "range", value: 0.69, min: 0, max: 1, step: 0.01 },
|
|
299
|
-
{ key: "vibranceProtectedHueB", label: "Vib Protect B", type: "range", value: 0.55, min: 0, max: 1, step: 0.01 },
|
|
300
|
-
{ key: "crossProcessAmount", label: "Cross Process", type: "range", value: 0, min: 0, max: 1, step: 0.01 }
|
|
301
|
-
],
|
|
302
|
-
filterSpec: {
|
|
303
|
-
create(params) {
|
|
304
|
-
const temperature = params.temperature || 0;
|
|
305
|
-
const tempWeight = Math.abs(temperature);
|
|
306
|
-
const tempColor = temperature > 0 ? [1, 0.55, 0.16] : [0.16, 0.47, 1];
|
|
307
|
-
const tint = params.tint || 0;
|
|
308
|
-
const tintWeight = Math.abs(tint);
|
|
309
|
-
const tintColor = tint > 0 ? [1, 0.16, 0.71] : [0.16, 1, 0.39];
|
|
310
|
-
return Filter.from({
|
|
311
|
-
gl: { vertex: ADJUSTMENTS_VERTEX_SHADER, fragment: ADJUSTMENTS_FRAGMENT_SHADER },
|
|
312
|
-
clipToViewport: false,
|
|
313
|
-
resources: {
|
|
314
|
-
adjustmentsUniforms: {
|
|
315
|
-
// ── Existing ──────────────────────────────────────────────────
|
|
316
|
-
uExposure: { value: params.exposure || 0, type: "f32" },
|
|
317
|
-
uBrightness: { value: params.brightness || 0, type: "f32" },
|
|
318
|
-
uContrast: { value: params.contrast || 0, type: "f32" },
|
|
319
|
-
uSaturation: { value: params.saturation || 0, type: "f32" },
|
|
320
|
-
uTemperatureColor: { value: tempColor, type: "vec3<f32>" },
|
|
321
|
-
uTemperatureWeight: { value: tempWeight, type: "f32" },
|
|
322
|
-
uTintColor: { value: tintColor, type: "vec3<f32>" },
|
|
323
|
-
uTintWeight: { value: tintWeight, type: "f32" },
|
|
324
|
-
uSepia: { value: params.sepia || 0, type: "f32" },
|
|
325
|
-
uGrayscale: { value: params.grayscale || 0, type: "f32" },
|
|
326
|
-
uHueRotate: { value: params.hueRotate || 0, type: "f32" },
|
|
327
|
-
uVignette: { value: params.vignette || 0, type: "f32" },
|
|
328
|
-
uInvert: { value: params.invert || 0, type: "f32" },
|
|
329
|
-
// ── NEW ───────────────────────────────────────────────────────
|
|
330
|
-
uLift: { value: params.lift || 0, type: "f32" },
|
|
331
|
-
uShadowTint: { value: [params.shadowTintR ?? 1, params.shadowTintG ?? 1, params.shadowTintB ?? 1], type: "vec3<f32>" },
|
|
332
|
-
uShadowTintStrength: { value: params.shadowTintStrength || 0, type: "f32" },
|
|
333
|
-
uHighlightTint: { value: [params.highlightTintR ?? 1, params.highlightTintG ?? 1, params.highlightTintB ?? 1], type: "vec3<f32>" },
|
|
334
|
-
uHighlightTintStrength: { value: params.highlightTintStrength || 0, type: "f32" },
|
|
335
|
-
uSplitBalance: { value: params.splitBalance ?? 0.5, type: "f32" },
|
|
336
|
-
uGrainIntensity: { value: params.grainIntensity || 0, type: "f32" },
|
|
337
|
-
uGrainSize: { value: params.grainSize ?? 1, type: "f32" },
|
|
338
|
-
uTime: { value: 0, type: "f32" },
|
|
339
|
-
uChannelMix: { value: [params.channelMixR ?? 0, params.channelMixG ?? 0, params.channelMixB ?? 0], type: "vec3<f32>" },
|
|
340
|
-
uUseChannelMix: { value: params.useChannelMix || 0, type: "f32" },
|
|
341
|
-
uDuotoneDark: { value: [params.duotoneDarkR ?? 0, params.duotoneDarkG ?? 0, params.duotoneDarkB ?? 0], type: "vec3<f32>" },
|
|
342
|
-
uDuotoneLight: { value: [params.duotoneLightR ?? 1, params.duotoneLightG ?? 1, params.duotoneLightB ?? 1], type: "vec3<f32>" },
|
|
343
|
-
uUseDuotone: { value: params.useDuotone || 0, type: "f32" },
|
|
344
|
-
uVibranceAmount: { value: params.vibranceAmount || 0, type: "f32" },
|
|
345
|
-
uVibranceProtectedHue: { value: [params.vibranceProtectedHueR ?? 0.91, params.vibranceProtectedHueG ?? 0.69, params.vibranceProtectedHueB ?? 0.55], type: "vec3<f32>" },
|
|
346
|
-
uCrossProcessAmount: { value: params.crossProcessAmount || 0, type: "f32" }
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
});
|
|
350
|
-
},
|
|
351
|
-
updateUniforms(filter, params) {
|
|
352
|
-
const group = filter.resources?.adjustmentsUniforms;
|
|
353
|
-
const uniforms = group?.uniforms;
|
|
354
|
-
if (!uniforms) return;
|
|
355
|
-
const temperature = params.temperature || 0;
|
|
356
|
-
const tempWeight = Math.abs(temperature);
|
|
357
|
-
const tempColor = temperature > 0 ? [1, 0.55, 0.16] : [0.16, 0.47, 1];
|
|
358
|
-
const tint = params.tint || 0;
|
|
359
|
-
const tintWeight = Math.abs(tint);
|
|
360
|
-
const tintColor = tint > 0 ? [1, 0.16, 0.71] : [0.16, 1, 0.39];
|
|
361
|
-
uniforms.uExposure = params.exposure || 0;
|
|
362
|
-
uniforms.uBrightness = params.brightness || 0;
|
|
363
|
-
uniforms.uContrast = params.contrast || 0;
|
|
364
|
-
uniforms.uSaturation = params.saturation || 0;
|
|
365
|
-
uniforms.uTemperatureColor = tempColor;
|
|
366
|
-
uniforms.uTemperatureWeight = tempWeight;
|
|
367
|
-
uniforms.uTintColor = tintColor;
|
|
368
|
-
uniforms.uTintWeight = tintWeight;
|
|
369
|
-
uniforms.uSepia = params.sepia || 0;
|
|
370
|
-
uniforms.uGrayscale = params.grayscale || 0;
|
|
371
|
-
uniforms.uHueRotate = params.hueRotate || 0;
|
|
372
|
-
uniforms.uVignette = params.vignette || 0;
|
|
373
|
-
uniforms.uInvert = params.invert || 0;
|
|
374
|
-
uniforms.uLift = params.lift || 0;
|
|
375
|
-
uniforms.uShadowTint = [params.shadowTintR ?? 1, params.shadowTintG ?? 1, params.shadowTintB ?? 1];
|
|
376
|
-
uniforms.uShadowTintStrength = params.shadowTintStrength || 0;
|
|
377
|
-
uniforms.uHighlightTint = [params.highlightTintR ?? 1, params.highlightTintG ?? 1, params.highlightTintB ?? 1];
|
|
378
|
-
uniforms.uHighlightTintStrength = params.highlightTintStrength || 0;
|
|
379
|
-
uniforms.uSplitBalance = params.splitBalance ?? 0.5;
|
|
380
|
-
uniforms.uGrainIntensity = params.grainIntensity || 0;
|
|
381
|
-
uniforms.uGrainSize = params.grainSize ?? 1;
|
|
382
|
-
uniforms.uTime = ((uniforms.uTime || 0) + 0.016) % 100;
|
|
383
|
-
uniforms.uChannelMix = [params.channelMixR ?? 0, params.channelMixG ?? 0, params.channelMixB ?? 0];
|
|
384
|
-
uniforms.uUseChannelMix = params.useChannelMix || 0;
|
|
385
|
-
uniforms.uDuotoneDark = [params.duotoneDarkR ?? 0, params.duotoneDarkG ?? 0, params.duotoneDarkB ?? 0];
|
|
386
|
-
uniforms.uDuotoneLight = [params.duotoneLightR ?? 1, params.duotoneLightG ?? 1, params.duotoneLightB ?? 1];
|
|
387
|
-
uniforms.uUseDuotone = params.useDuotone || 0;
|
|
388
|
-
uniforms.uVibranceAmount = params.vibranceAmount || 0;
|
|
389
|
-
uniforms.uVibranceProtectedHue = [params.vibranceProtectedHueR ?? 0.91, params.vibranceProtectedHueG ?? 0.69, params.vibranceProtectedHueB ?? 0.55];
|
|
390
|
-
uniforms.uCrossProcessAmount = params.crossProcessAmount || 0;
|
|
391
|
-
group?.update?.();
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
// src/v2/backends/colorAdjustmentsFilter.ts
|
|
397
|
-
var spec = ColorAdjustmentsEffect.filterSpec;
|
|
398
|
-
function createColorAdjustmentsFilter(params = {}) {
|
|
399
|
-
return spec.create(params);
|
|
400
|
-
}
|
|
401
|
-
function updateColorAdjustmentsFilter(filter, params) {
|
|
402
|
-
spec.updateUniforms(filter, params, 0);
|
|
403
|
-
}
|
|
404
|
-
function normalizeColorAdjustmentsUniforms(uniforms) {
|
|
405
|
-
return {
|
|
406
|
-
// ── Existing ────────────────────────────────────────────────────────────
|
|
407
|
-
exposure: uniforms.exposure ?? 0,
|
|
408
|
-
brightness: uniforms.brightness ?? 0,
|
|
409
|
-
contrast: uniforms.contrast ?? 0,
|
|
410
|
-
saturation: uniforms.saturation ?? 0,
|
|
411
|
-
temperature: uniforms.temperature ?? 0,
|
|
412
|
-
tint: uniforms.tint ?? 0,
|
|
413
|
-
sepia: uniforms.sepia ?? 0,
|
|
414
|
-
grayscale: uniforms.grayscale ?? 0,
|
|
415
|
-
hueRotate: uniforms.hueRotate ?? 0,
|
|
416
|
-
vignette: uniforms.vignette ?? 0,
|
|
417
|
-
invert: uniforms.invert ?? 0,
|
|
418
|
-
// ── NEW: Lift ────────────────────────────────────────────────────────────
|
|
419
|
-
lift: uniforms.lift ?? 0,
|
|
420
|
-
// ── NEW: Split-toning ────────────────────────────────────────────────────
|
|
421
|
-
shadowTintR: uniforms.shadowTintR ?? 1,
|
|
422
|
-
shadowTintG: uniforms.shadowTintG ?? 1,
|
|
423
|
-
shadowTintB: uniforms.shadowTintB ?? 1,
|
|
424
|
-
shadowTintStrength: uniforms.shadowTintStrength ?? 0,
|
|
425
|
-
highlightTintR: uniforms.highlightTintR ?? 1,
|
|
426
|
-
highlightTintG: uniforms.highlightTintG ?? 1,
|
|
427
|
-
highlightTintB: uniforms.highlightTintB ?? 1,
|
|
428
|
-
highlightTintStrength: uniforms.highlightTintStrength ?? 0,
|
|
429
|
-
splitBalance: uniforms.splitBalance ?? 0.5,
|
|
430
|
-
// ── NEW: Film grain ──────────────────────────────────────────────────────
|
|
431
|
-
grainIntensity: uniforms.grainIntensity ?? 0,
|
|
432
|
-
grainSize: uniforms.grainSize ?? 1,
|
|
433
|
-
// ── NEW: Channel-mix B&W ─────────────────────────────────────────────────
|
|
434
|
-
channelMixR: uniforms.channelMixR ?? 0,
|
|
435
|
-
channelMixG: uniforms.channelMixG ?? 0,
|
|
436
|
-
channelMixB: uniforms.channelMixB ?? 0,
|
|
437
|
-
useChannelMix: uniforms.useChannelMix ?? 0,
|
|
438
|
-
// ── NEW: Duotone ─────────────────────────────────────────────────────────
|
|
439
|
-
duotoneDarkR: uniforms.duotoneDarkR ?? 0,
|
|
440
|
-
duotoneDarkG: uniforms.duotoneDarkG ?? 0,
|
|
441
|
-
duotoneDarkB: uniforms.duotoneDarkB ?? 0,
|
|
442
|
-
duotoneLightR: uniforms.duotoneLightR ?? 1,
|
|
443
|
-
duotoneLightG: uniforms.duotoneLightG ?? 1,
|
|
444
|
-
duotoneLightB: uniforms.duotoneLightB ?? 1,
|
|
445
|
-
useDuotone: uniforms.useDuotone ?? 0,
|
|
446
|
-
// ── NEW: Vibrance ────────────────────────────────────────────────────────
|
|
447
|
-
vibranceAmount: uniforms.vibranceAmount ?? 0,
|
|
448
|
-
vibranceProtectedHueR: uniforms.vibranceProtectedHueR ?? 0.91,
|
|
449
|
-
vibranceProtectedHueG: uniforms.vibranceProtectedHueG ?? 0.69,
|
|
450
|
-
vibranceProtectedHueB: uniforms.vibranceProtectedHueB ?? 0.55,
|
|
451
|
-
// ── NEW: Cross-process ───────────────────────────────────────────────────
|
|
452
|
-
crossProcessAmount: uniforms.crossProcessAmount ?? 0
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
// src/v2/backends/PixiRenderBackend.ts
|
|
457
|
-
var PixiRenderBackend = class {
|
|
458
|
-
app = null;
|
|
459
|
-
initialized = false;
|
|
460
|
-
resources = /* @__PURE__ */ new Map();
|
|
461
|
-
filters = /* @__PURE__ */ new Map();
|
|
462
|
-
canvasElement;
|
|
463
|
-
async init(canvasElement, width, height) {
|
|
464
|
-
if (this.initialized) {
|
|
465
|
-
throw new Error("PixiRenderBackend already initialized");
|
|
466
|
-
}
|
|
467
|
-
this.canvasElement = canvasElement;
|
|
468
|
-
const logicalWidth = width ?? canvasElement?.clientWidth ?? canvasElement?.width ?? 1920;
|
|
469
|
-
const logicalHeight = height ?? canvasElement?.clientHeight ?? canvasElement?.height ?? 1080;
|
|
470
|
-
this.app = new PIXI.Application();
|
|
471
|
-
await this.app.init({
|
|
472
|
-
canvas: canvasElement,
|
|
473
|
-
width: logicalWidth,
|
|
474
|
-
height: logicalHeight,
|
|
475
|
-
backgroundColor: 921106,
|
|
476
|
-
antialias: true,
|
|
477
|
-
preference: "webgl",
|
|
478
|
-
resolution: typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1,
|
|
479
|
-
autoDensity: true,
|
|
480
|
-
preserveDrawingBuffer: true
|
|
481
|
-
});
|
|
482
|
-
this.initialized = true;
|
|
483
|
-
}
|
|
484
|
-
resize(width, height) {
|
|
485
|
-
if (!this.app) return;
|
|
486
|
-
this.app.renderer.resize(width, height);
|
|
487
|
-
}
|
|
488
|
-
get logicalWidth() {
|
|
489
|
-
return this.app?.renderer.width ?? 0;
|
|
490
|
-
}
|
|
491
|
-
get logicalHeight() {
|
|
492
|
-
return this.app?.renderer.height ?? 0;
|
|
493
|
-
}
|
|
494
|
-
allocateResource(id, _type, width, height, _format) {
|
|
495
|
-
if (!this.initialized || !this.app) {
|
|
496
|
-
throw new Error("PixiRenderBackend not initialized");
|
|
497
|
-
}
|
|
498
|
-
if (this.resources.has(id)) {
|
|
499
|
-
throw new Error(`Resource "${id}" already allocated`);
|
|
500
|
-
}
|
|
501
|
-
this.resources.set(id, PIXI.RenderTexture.create({ width, height }));
|
|
502
|
-
}
|
|
503
|
-
releaseResource(id) {
|
|
504
|
-
if (!this.initialized) {
|
|
505
|
-
throw new Error("PixiRenderBackend not initialized");
|
|
506
|
-
}
|
|
507
|
-
const texture = this.resources.get(id);
|
|
508
|
-
if (!texture) {
|
|
509
|
-
throw new Error(`Resource "${id}" not found for release`);
|
|
510
|
-
}
|
|
511
|
-
texture.destroy(true);
|
|
512
|
-
this.resources.delete(id);
|
|
513
|
-
}
|
|
514
|
-
compileShader(shaderId, _sourceGLSLOrWGSL) {
|
|
515
|
-
if (!this.initialized) {
|
|
516
|
-
throw new Error("PixiRenderBackend not initialized");
|
|
517
|
-
}
|
|
518
|
-
if (this.filters.has(shaderId)) return;
|
|
519
|
-
let filter;
|
|
520
|
-
switch (shaderId) {
|
|
521
|
-
case "brightness":
|
|
522
|
-
filter = new AdjustmentFilter({ brightness: 1 });
|
|
523
|
-
break;
|
|
524
|
-
case "contrast":
|
|
525
|
-
filter = new AdjustmentFilter({ contrast: 1 });
|
|
526
|
-
break;
|
|
527
|
-
case "gaussian-blur-h":
|
|
528
|
-
case "gaussian-blur-v":
|
|
529
|
-
filter = new PIXI.BlurFilter({ strength: 8, quality: 4 });
|
|
530
|
-
break;
|
|
531
|
-
case "copy":
|
|
532
|
-
case "blit-source":
|
|
533
|
-
filter = new AdjustmentFilter({ brightness: 1, contrast: 1, saturation: 1 });
|
|
534
|
-
break;
|
|
535
|
-
case "color-adjustments":
|
|
536
|
-
return;
|
|
537
|
-
default:
|
|
538
|
-
filter = new AdjustmentFilter({});
|
|
539
|
-
}
|
|
540
|
-
this.filters.set(shaderId, filter);
|
|
541
|
-
}
|
|
542
|
-
async submit(commandBuffer) {
|
|
543
|
-
if (!this.initialized || !this.app) {
|
|
544
|
-
throw new Error("PixiRenderBackend not initialized");
|
|
545
|
-
}
|
|
546
|
-
for (const { pass } of commandBuffer.passes) {
|
|
547
|
-
await this.executePass(pass);
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
async executePass(pass) {
|
|
551
|
-
if (!this.app) return;
|
|
552
|
-
const inputTexture = pass.inputs.length > 0 ? this.resources.get(pass.inputs[0]) : null;
|
|
553
|
-
const outputTexture = this.resources.get(pass.output);
|
|
554
|
-
if (!outputTexture) {
|
|
555
|
-
throw new Error(`Output resource not found: ${pass.output}`);
|
|
556
|
-
}
|
|
557
|
-
if (pass.shaderId === "copy" || pass.shaderId === "blit-source") {
|
|
558
|
-
if (inputTexture) {
|
|
559
|
-
this.blitTexture(inputTexture, outputTexture);
|
|
560
|
-
}
|
|
561
|
-
return;
|
|
562
|
-
}
|
|
563
|
-
if (!inputTexture) return;
|
|
564
|
-
const target = outputTexture;
|
|
565
|
-
const sprite = new PIXI.Sprite(inputTexture);
|
|
566
|
-
sprite.width = target.width;
|
|
567
|
-
sprite.height = target.height;
|
|
568
|
-
let filter;
|
|
569
|
-
let disposeFilter = false;
|
|
570
|
-
if (pass.shaderId === "color-adjustments") {
|
|
571
|
-
filter = createColorAdjustmentsFilter(normalizeColorAdjustmentsUniforms(pass.uniforms));
|
|
572
|
-
disposeFilter = true;
|
|
573
|
-
} else {
|
|
574
|
-
if (!this.filters.has(pass.shaderId)) {
|
|
575
|
-
this.compileShader(pass.shaderId, "");
|
|
576
|
-
}
|
|
577
|
-
const cachedFilter = this.filters.get(pass.shaderId);
|
|
578
|
-
if (!cachedFilter) {
|
|
579
|
-
throw new Error(`Filter not compiled for shader: ${pass.shaderId}`);
|
|
580
|
-
}
|
|
581
|
-
filter = cachedFilter;
|
|
582
|
-
this.applyUniforms(cachedFilter, pass.uniforms, pass.shaderId);
|
|
583
|
-
}
|
|
584
|
-
const filterArray = Array.isArray(filter) ? filter : [filter];
|
|
585
|
-
sprite.filters = filterArray;
|
|
586
|
-
this.app.renderer.render({ container: sprite, target, clear: true });
|
|
587
|
-
sprite.filters = null;
|
|
588
|
-
if (disposeFilter) {
|
|
589
|
-
if (Array.isArray(filter)) {
|
|
590
|
-
filter.forEach((f) => f.destroy());
|
|
591
|
-
} else {
|
|
592
|
-
filter.destroy();
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
applyUniforms(filter, uniforms, shaderId) {
|
|
597
|
-
if (shaderId === "color-adjustments") {
|
|
598
|
-
updateColorAdjustmentsFilter(filter, normalizeColorAdjustmentsUniforms(uniforms));
|
|
599
|
-
return;
|
|
600
|
-
}
|
|
601
|
-
if (filter instanceof AdjustmentFilter) {
|
|
602
|
-
if (uniforms.brightness !== void 0) {
|
|
603
|
-
filter.brightness = 1 + Number(uniforms.brightness);
|
|
604
|
-
}
|
|
605
|
-
if (uniforms.contrast !== void 0) {
|
|
606
|
-
filter.contrast = 1 + Number(uniforms.contrast);
|
|
607
|
-
}
|
|
608
|
-
} else if (filter instanceof PIXI.BlurFilter && uniforms.uBlurStrength !== void 0) {
|
|
609
|
-
filter.strength = Number(uniforms.uBlurStrength);
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
blitTexture(source, target) {
|
|
613
|
-
if (!this.app) return;
|
|
614
|
-
const sprite = new PIXI.Sprite(source);
|
|
615
|
-
this.app.renderer.render({ container: sprite, target });
|
|
616
|
-
}
|
|
617
|
-
/** Upload a source image into track/source render textures (contain-fit). */
|
|
618
|
-
uploadSourceImage(sourceImage, resourceIds) {
|
|
619
|
-
if (!this.app) return;
|
|
620
|
-
const sourceTexture = PIXI.Texture.from(sourceImage);
|
|
621
|
-
for (const resourceId of resourceIds) {
|
|
622
|
-
const texture = this.resources.get(resourceId);
|
|
623
|
-
if (!texture) continue;
|
|
624
|
-
const blitSprite = new PIXI.Sprite(sourceTexture);
|
|
625
|
-
const fitScale = Math.min(texture.width / sourceTexture.width, texture.height / sourceTexture.height);
|
|
626
|
-
blitSprite.scale.set(fitScale);
|
|
627
|
-
blitSprite.position.set((texture.width - sourceTexture.width * fitScale) / 2, (texture.height - sourceTexture.height * fitScale) / 2);
|
|
628
|
-
this.app.renderer.render({ container: blitSprite, target: texture });
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
/** Present a resource texture to the canvas screen. */
|
|
632
|
-
present(resourceId) {
|
|
633
|
-
if (!this.app) return;
|
|
634
|
-
const texture = this.resources.get(resourceId);
|
|
635
|
-
if (!texture) return;
|
|
636
|
-
const screenW = this.app.renderer.screen.width;
|
|
637
|
-
const screenH = this.app.renderer.screen.height;
|
|
638
|
-
const scale = Math.min(screenW / texture.width, screenH / texture.height);
|
|
639
|
-
const sprite = new PIXI.Sprite(texture);
|
|
640
|
-
sprite.scale.set(scale);
|
|
641
|
-
sprite.position.set((screenW - texture.width * scale) / 2, (screenH - texture.height * scale) / 2);
|
|
642
|
-
this.app.stage.removeChildren();
|
|
643
|
-
this.app.stage.addChild(sprite);
|
|
644
|
-
this.app.renderer.render(this.app.stage);
|
|
645
|
-
}
|
|
646
|
-
getResource(id) {
|
|
647
|
-
return this.resources.get(id);
|
|
648
|
-
}
|
|
649
|
-
async readPixels(resourceId) {
|
|
650
|
-
if (!this.initialized || !this.app) {
|
|
651
|
-
throw new Error("PixiRenderBackend not initialized");
|
|
652
|
-
}
|
|
653
|
-
const texture = this.resources.get(resourceId);
|
|
654
|
-
if (!texture) {
|
|
655
|
-
throw new Error(`Resource "${resourceId}" not found for readPixels`);
|
|
656
|
-
}
|
|
657
|
-
const pixels = this.app.renderer.extract.pixels(texture);
|
|
658
|
-
return new Uint8Array(pixels.pixels);
|
|
659
|
-
}
|
|
660
|
-
clearResources() {
|
|
661
|
-
for (const id of [...this.resources.keys()]) {
|
|
662
|
-
this.releaseResource(id);
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
destroy() {
|
|
666
|
-
if (!this.initialized) return;
|
|
667
|
-
for (const texture of this.resources.values()) {
|
|
668
|
-
texture.destroy(true);
|
|
669
|
-
}
|
|
670
|
-
this.resources.clear();
|
|
671
|
-
for (const filter of this.filters.values()) {
|
|
672
|
-
filter.destroy();
|
|
673
|
-
}
|
|
674
|
-
this.filters.clear();
|
|
675
|
-
if (this.app) {
|
|
676
|
-
this.app.destroy(true);
|
|
677
|
-
this.app = null;
|
|
678
|
-
}
|
|
679
|
-
this.initialized = false;
|
|
680
|
-
this.canvasElement = void 0;
|
|
681
|
-
}
|
|
682
|
-
};
|
|
683
|
-
|
|
684
|
-
export {
|
|
685
|
-
mergeGradingParams,
|
|
686
|
-
hexToRgb,
|
|
687
|
-
ColorAdjustmentsEffect,
|
|
688
|
-
PixiRenderBackend
|
|
689
|
-
};
|
|
690
|
-
//# sourceMappingURL=chunk-RYA4KGDB.js.map
|