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