@remotion/effects 4.0.540 → 4.0.542

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 (133) hide show
  1. package/THIRD_PARTY_LICENSES.md +10 -0
  2. package/dist/esm/lightning.mjs +603 -0
  3. package/dist/esm/magnify.mjs +403 -0
  4. package/dist/esm/preview/barrel-distortion.mjs +303 -0
  5. package/dist/esm/preview/bevel-alpha.mjs +525 -0
  6. package/dist/esm/preview/blur.mjs +435 -0
  7. package/dist/esm/preview/brightness.mjs +95 -0
  8. package/dist/esm/preview/burlap.mjs +481 -0
  9. package/dist/esm/preview/checkerboard.mjs +8 -0
  10. package/dist/esm/preview/chromatic-aberration.mjs +308 -0
  11. package/dist/esm/preview/color-correction.mjs +522 -0
  12. package/dist/esm/preview/color-key.mjs +440 -0
  13. package/dist/esm/preview/contour-lines.mjs +608 -0
  14. package/dist/esm/preview/contrast.mjs +95 -0
  15. package/dist/esm/preview/corner-pin.mjs +6 -0
  16. package/dist/esm/preview/curves.mjs +357 -0
  17. package/dist/esm/preview/cylinder.mjs +273 -0
  18. package/dist/esm/preview/dot-grid.mjs +333 -0
  19. package/dist/esm/preview/drop-shadow.mjs +607 -0
  20. package/dist/esm/preview/duotone.mjs +344 -0
  21. package/dist/esm/preview/emboss.mjs +479 -0
  22. package/dist/esm/preview/evolve.mjs +485 -0
  23. package/dist/esm/preview/exposure.mjs +264 -0
  24. package/dist/esm/preview/film-burn.mjs +298 -0
  25. package/dist/esm/preview/fisheye.mjs +422 -0
  26. package/dist/esm/preview/flannel.mjs +401 -0
  27. package/dist/esm/preview/fractal-noise.mjs +642 -0
  28. package/dist/esm/preview/glow.mjs +598 -0
  29. package/dist/esm/preview/grayscale.mjs +86 -0
  30. package/dist/esm/preview/gridlines.mjs +8 -0
  31. package/dist/esm/preview/halftone-linear-gradient.mjs +523 -0
  32. package/dist/esm/preview/halftone.mjs +552 -0
  33. package/dist/esm/preview/hue.mjs +83 -0
  34. package/dist/esm/preview/index-00v3hr66.mjs +299 -0
  35. package/dist/esm/preview/index-0w4eqht8.mjs +351 -0
  36. package/dist/esm/preview/index-18y0zcy2.mjs +440 -0
  37. package/dist/esm/preview/index-1m1b1ad7.mjs +520 -0
  38. package/dist/esm/preview/index-34fxm3ax.mjs +518 -0
  39. package/dist/esm/preview/index-4fvp93ps.mjs +32 -0
  40. package/dist/esm/preview/index-4scpn12x.mjs +224 -0
  41. package/dist/esm/preview/index-4z6pt3ka.mjs +104 -0
  42. package/dist/esm/preview/index-618ky75w.mjs +51 -0
  43. package/dist/esm/preview/index-6agxdrvr.mjs +411 -0
  44. package/dist/esm/preview/index-6jkps947.mjs +120 -0
  45. package/dist/esm/preview/index-8agtsbw4.mjs +617 -0
  46. package/dist/esm/preview/index-8jx11jyn.mjs +29 -0
  47. package/dist/esm/preview/index-8p04sssx.mjs +123 -0
  48. package/dist/esm/preview/index-afdtmrh2.mjs +596 -0
  49. package/dist/esm/preview/index-b86qstcs.mjs +18 -0
  50. package/dist/esm/preview/index-cb77qg3g.mjs +587 -0
  51. package/dist/esm/preview/index-cdp7tr8x.mjs +122 -0
  52. package/dist/esm/preview/index-evy8hyah.mjs +55 -0
  53. package/dist/esm/preview/index-gnsce796.mjs +6 -0
  54. package/dist/esm/preview/index-kkvzt8b7.mjs +199 -0
  55. package/dist/esm/preview/index-r0v18b2n.mjs +425 -0
  56. package/dist/esm/preview/index-rswpzmm5.mjs +926 -0
  57. package/dist/esm/preview/index-s9mrx750.mjs +97 -0
  58. package/dist/esm/preview/index-tvfexb7s.mjs +164 -0
  59. package/dist/esm/preview/index-vp56k1gj.mjs +215 -0
  60. package/dist/esm/preview/index-wxhvgv2s.mjs +79 -0
  61. package/dist/esm/preview/index-wy95a41r.mjs +407 -0
  62. package/dist/esm/preview/index-ysnwfc4t.mjs +306 -0
  63. package/dist/esm/preview/index.mjs +51 -0
  64. package/dist/esm/preview/invert.mjs +84 -0
  65. package/dist/esm/preview/iris-wipe.mjs +315 -0
  66. package/dist/esm/preview/lens-blur.mjs +563 -0
  67. package/dist/esm/preview/levels.mjs +400 -0
  68. package/dist/esm/preview/light-leak.mjs +8 -0
  69. package/dist/esm/preview/light-trail.mjs +516 -0
  70. package/dist/esm/preview/lightning.mjs +603 -0
  71. package/dist/esm/preview/linear-gradient-tint.mjs +6 -0
  72. package/dist/esm/preview/linear-gradient.mjs +6 -0
  73. package/dist/esm/preview/linear-progressive-blur.mjs +516 -0
  74. package/dist/esm/preview/linear-progressive-pixelate.mjs +176 -0
  75. package/dist/esm/preview/lines.mjs +536 -0
  76. package/dist/esm/preview/liquid-contours.mjs +512 -0
  77. package/dist/esm/preview/long-shadows.mjs +437 -0
  78. package/dist/esm/preview/lut.mjs +601 -0
  79. package/dist/esm/preview/magnify.mjs +403 -0
  80. package/dist/esm/preview/mirror.mjs +341 -0
  81. package/dist/esm/preview/noise-displacement.mjs +584 -0
  82. package/dist/esm/preview/noise.mjs +318 -0
  83. package/dist/esm/preview/outline.mjs +725 -0
  84. package/dist/esm/preview/page-turn.mjs +302 -0
  85. package/dist/esm/preview/paper.mjs +1249 -0
  86. package/dist/esm/preview/pattern.mjs +6 -0
  87. package/dist/esm/preview/pixel-dissolve.mjs +360 -0
  88. package/dist/esm/preview/pixelate.mjs +249 -0
  89. package/dist/esm/preview/radial-progressive-blur.mjs +582 -0
  90. package/dist/esm/preview/radial-progressive-pixelate.mjs +220 -0
  91. package/dist/esm/preview/radial-wipe.mjs +224 -0
  92. package/dist/esm/preview/rain-fall.mjs +114 -0
  93. package/dist/esm/preview/region-blur.mjs +500 -0
  94. package/dist/esm/preview/rings.mjs +8 -0
  95. package/dist/esm/preview/roughen-edges.mjs +590 -0
  96. package/dist/esm/preview/saturation.mjs +86 -0
  97. package/dist/esm/preview/scale.mjs +109 -0
  98. package/dist/esm/preview/scanlines.mjs +362 -0
  99. package/dist/esm/preview/shadows-highlights.mjs +284 -0
  100. package/dist/esm/preview/shatter.mjs +868 -0
  101. package/dist/esm/preview/shine.mjs +368 -0
  102. package/dist/esm/preview/shrinkwrap.mjs +769 -0
  103. package/dist/esm/preview/skew.mjs +300 -0
  104. package/dist/esm/preview/snow-fall.mjs +170 -0
  105. package/dist/esm/preview/speckle.mjs +356 -0
  106. package/dist/esm/preview/sphere.mjs +252 -0
  107. package/dist/esm/preview/starburst.mjs +8 -0
  108. package/dist/esm/preview/tear.mjs +375 -0
  109. package/dist/esm/preview/thermal-vision.mjs +387 -0
  110. package/dist/esm/preview/tile.mjs +7 -0
  111. package/dist/esm/preview/tint.mjs +125 -0
  112. package/dist/esm/preview/translate.mjs +151 -0
  113. package/dist/esm/preview/turbulent-displace.mjs +613 -0
  114. package/dist/esm/preview/tv-signal-off.mjs +308 -0
  115. package/dist/esm/preview/venetian-blinds.mjs +341 -0
  116. package/dist/esm/preview/vibrance.mjs +254 -0
  117. package/dist/esm/preview/vignette.mjs +458 -0
  118. package/dist/esm/preview/wave.mjs +384 -0
  119. package/dist/esm/preview/waves.mjs +599 -0
  120. package/dist/esm/preview/white-balance.mjs +280 -0
  121. package/dist/esm/preview/white-noise.mjs +244 -0
  122. package/dist/esm/preview/zigzag.mjs +8 -0
  123. package/dist/esm/preview/zoom-blur.mjs +389 -0
  124. package/dist/lightning/geometry.d.ts +10 -0
  125. package/dist/lightning/index.d.ts +4 -0
  126. package/dist/lightning/mask.d.ts +2 -0
  127. package/dist/lightning/params.d.ts +259 -0
  128. package/dist/lightning/shaders.d.ts +2 -0
  129. package/dist/lightning.d.ts +2 -0
  130. package/dist/magnify/shader.d.ts +1 -0
  131. package/dist/magnify/webgpu-shader.d.ts +1 -0
  132. package/dist/magnify.d.ts +28 -0
  133. package/package.json +30 -6
@@ -0,0 +1,518 @@
1
+ import {
2
+ publicUvToShaderUv
3
+ } from "./index-gnsce796.mjs";
4
+ import {
5
+ setupWebGpuColors,
6
+ getWebGpuColors
7
+ } from "./index-8jx11jyn.mjs";
8
+ import {
9
+ assertOptionalFiniteNumber,
10
+ validateUnitInterval,
11
+ parseColorRgba
12
+ } from "./index-wxhvgv2s.mjs";
13
+ import {
14
+ WEBGPU_SINGLE_PASS_VERTEX,
15
+ cleanupWebGpuSinglePass,
16
+ applyWebGpuSinglePass
17
+ } from "./index-tvfexb7s.mjs";
18
+ import {
19
+ assertEffectParamsObject,
20
+ assertRequiredColor,
21
+ assertOptionalBoolean
22
+ } from "./index-4fvp93ps.mjs";
23
+
24
+ // src/rings.ts
25
+ import { Internals } from "remotion";
26
+
27
+ // src/rings-webgpu-shader.ts
28
+ var RINGS_WEBGPU_SHADER = `
29
+ ${WEBGPU_SINGLE_PASS_VERTEX}
30
+ @group(0) @binding(0) var sourceTexture: texture_2d<f32>;
31
+ @group(0) @binding(1) var sourceSampler: sampler;
32
+ @group(0) @binding(2) var<uniform> params: Params;
33
+ @group(0) @binding(3) var palette: texture_2d<f32>;
34
+ struct Params {
35
+ geometry: vec4f,
36
+ stripe: vec4f,
37
+ center: vec4f,
38
+ flags: vec4f,
39
+ }
40
+ fn sampleSource(uv: vec2f) -> vec4f {
41
+ return textureSampleLevel(sourceTexture, sourceSampler, vec2f(uv.x, 1.0 - uv.y), 0);
42
+ }
43
+ fn glslModulo(value: f32, divisor: f32) -> f32 { return value - divisor * floor(value / divisor); }
44
+ fn paletteColor(index: f32) -> vec4f { return textureLoad(palette, vec2i(i32(index), 0), 0); }
45
+
46
+ @fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {
47
+ let vUv = vec2f(input.uv.x, 1.0 - input.uv.y);
48
+
49
+ let texColor = sampleSource(vUv);
50
+ let thickness = max(params.stripe.x, 0.001);
51
+ let spacing = max(params.stripe.y, 0.001);
52
+ let cycle = spacing * params.geometry.z;
53
+ let pixelPosition = vec2f(input.position.x, params.geometry.y - input.position.y);
54
+ let centerPosition = params.center.xy * params.geometry.xy;
55
+ let radius = length(pixelPosition - centerPosition);
56
+ var position = glslModulo(radius + params.stripe.w, cycle);
57
+ if (position < 0.0) { position += cycle; }
58
+ let colorIndex = floor(position / spacing);
59
+ let inStripe = glslModulo(position, spacing);
60
+ if (inStripe > thickness) { return texColor; }
61
+
62
+ let overlay = paletteColor(colorIndex);
63
+ let premultiplied = overlay.rgb * overlay.a;
64
+ if (params.flags.x != 0.0) {
65
+ return vec4f(premultiplied * texColor.a + texColor.rgb * (1.0 - overlay.a), texColor.a);
66
+ }
67
+ return vec4f(premultiplied + texColor.rgb * (1.0 - overlay.a), overlay.a + texColor.a * (1.0 - overlay.a));
68
+
69
+ }
70
+ `;
71
+
72
+ // src/rings.ts
73
+ var { createEffect, createWebGL2ContextError } = Internals;
74
+ var DEFAULT_COLORS = ["#dff4ff", "#7cc6ff"];
75
+ var DEFAULT_CENTER = [0.5, 0.5];
76
+ var DEFAULT_THICKNESS = 40;
77
+ var DEFAULT_GAP = 0;
78
+ var DEFAULT_OFFSET = 0;
79
+ var DEFAULT_MASK_TO_SOURCE_ALPHA = false;
80
+ var ringsSchema2 = {
81
+ colors: {
82
+ type: "array",
83
+ item: {
84
+ type: "color"
85
+ },
86
+ default: DEFAULT_COLORS,
87
+ minLength: 2,
88
+ newItemDefault: "#ff0000",
89
+ description: "Colors",
90
+ keyframable: false
91
+ },
92
+ center: {
93
+ type: "uv-coordinate",
94
+ min: 0,
95
+ max: 1,
96
+ step: 0.01,
97
+ default: DEFAULT_CENTER,
98
+ description: "Center"
99
+ },
100
+ thickness: {
101
+ type: "number",
102
+ min: 0.1,
103
+ max: 400,
104
+ step: 0.1,
105
+ default: DEFAULT_THICKNESS,
106
+ description: "Thickness",
107
+ hiddenFromList: false
108
+ },
109
+ gap: {
110
+ type: "number",
111
+ min: 0,
112
+ max: 400,
113
+ step: 0.1,
114
+ default: DEFAULT_GAP,
115
+ description: "Gap",
116
+ hiddenFromList: false
117
+ },
118
+ offset: {
119
+ type: "number",
120
+ step: 0.1,
121
+ default: DEFAULT_OFFSET,
122
+ description: "Offset",
123
+ hiddenFromList: false
124
+ },
125
+ maskToSourceAlpha: {
126
+ type: "boolean",
127
+ default: DEFAULT_MASK_TO_SOURCE_ALPHA,
128
+ description: "Mask to source alpha"
129
+ }
130
+ };
131
+ var resolve = (p) => {
132
+ const thickness = p.thickness ?? DEFAULT_THICKNESS;
133
+ const gap = p.gap ?? DEFAULT_GAP;
134
+ return {
135
+ colors: p.colors ?? DEFAULT_COLORS,
136
+ center: [...p.center ?? DEFAULT_CENTER],
137
+ thickness,
138
+ spacing: thickness + gap,
139
+ offset: p.offset ?? DEFAULT_OFFSET,
140
+ maskToSourceAlpha: p.maskToSourceAlpha ?? DEFAULT_MASK_TO_SOURCE_ALPHA
141
+ };
142
+ };
143
+ var validatePositive = (value, name) => {
144
+ if (value <= 0) {
145
+ throw new TypeError(`"${name}" must be greater than 0, but got ${JSON.stringify(value)}`);
146
+ }
147
+ };
148
+ var validateNonNegative = (value, name) => {
149
+ if (value < 0) {
150
+ throw new TypeError(`"${name}" must be greater than or equal to 0, but got ${JSON.stringify(value)}`);
151
+ }
152
+ };
153
+ var validateColors = (colors) => {
154
+ if (colors === undefined) {
155
+ return;
156
+ }
157
+ if (!Array.isArray(colors) || colors.length < 2) {
158
+ throw new TypeError(`"colors" must be an array with at least 2 colors, but got ${JSON.stringify(colors)}`);
159
+ }
160
+ for (let i = 0;i < colors.length; i++) {
161
+ assertRequiredColor(colors[i], `colors[${i}]`);
162
+ }
163
+ };
164
+ var assertOptionalCenter = (value, name) => {
165
+ if (value === undefined) {
166
+ return;
167
+ }
168
+ if (!Array.isArray(value) || value.length !== 2 || value.some((item) => typeof item !== "number" || !Number.isFinite(item))) {
169
+ throw new TypeError(`"${name}" must be a [number, number] tuple`);
170
+ }
171
+ validateUnitInterval(value[0], `${name}[0]`);
172
+ validateUnitInterval(value[1], `${name}[1]`);
173
+ };
174
+ var validateRingsParams = (params) => {
175
+ assertEffectParamsObject(params, "Rings");
176
+ validateColors(params.colors);
177
+ assertOptionalCenter(params.center, "center");
178
+ assertOptionalFiniteNumber(params.thickness, "thickness");
179
+ assertOptionalFiniteNumber(params.gap, "gap");
180
+ assertOptionalFiniteNumber(params.offset, "offset");
181
+ assertOptionalBoolean(params.maskToSourceAlpha, "maskToSourceAlpha");
182
+ const thickness = params.thickness ?? DEFAULT_THICKNESS;
183
+ const gap = params.gap ?? DEFAULT_GAP;
184
+ validatePositive(thickness, "thickness");
185
+ validateNonNegative(gap, "gap");
186
+ };
187
+ var RINGS_VS = `#version 300 es
188
+ in vec2 aPos;
189
+ in vec2 aUv;
190
+ out vec2 vUv;
191
+
192
+ void main() {
193
+ vUv = aUv;
194
+ gl_Position = vec4(aPos, 0.0, 1.0);
195
+ }
196
+ `;
197
+ var RINGS_FS = `#version 300 es
198
+ precision highp float;
199
+
200
+ in vec2 vUv;
201
+ out vec4 fragColor;
202
+
203
+ uniform sampler2D uSource;
204
+ uniform sampler2D uPalette;
205
+ uniform vec2 uResolution;
206
+ uniform float uNumColors;
207
+ uniform vec2 uCenter;
208
+ uniform float uThickness;
209
+ uniform float uSpacing;
210
+ uniform float uOffset;
211
+ uniform bool uMaskToSourceAlpha;
212
+
213
+ void main() {
214
+ vec4 texColor = texture(uSource, vUv);
215
+ float thickness = max(uThickness, 0.001);
216
+ float spacing = max(uSpacing, 0.001);
217
+ float cycle = spacing * uNumColors;
218
+ vec2 pixelPosition = gl_FragCoord.xy;
219
+ vec2 centerPosition = uCenter * uResolution;
220
+ float radius = length(pixelPosition - centerPosition);
221
+ float position = mod(radius + uOffset, cycle);
222
+ if (position < 0.0) {
223
+ position += cycle;
224
+ }
225
+
226
+ float colorIndex = floor(position / spacing);
227
+ float inStripe = mod(position, spacing);
228
+ if (inStripe > thickness) {
229
+ fragColor = texColor;
230
+ return;
231
+ }
232
+
233
+ float texCoord = (colorIndex + 0.5) / uNumColors;
234
+ vec4 ringColor = texture(uPalette, vec2(texCoord, 0.5));
235
+ float ringAlpha = ringColor.a;
236
+ vec3 premultipliedRing = ringColor.rgb * ringAlpha;
237
+
238
+ if (uMaskToSourceAlpha) {
239
+ fragColor = vec4(
240
+ premultipliedRing * texColor.a + texColor.rgb * (1.0 - ringAlpha),
241
+ texColor.a
242
+ );
243
+ return;
244
+ }
245
+
246
+ fragColor = vec4(
247
+ premultipliedRing + texColor.rgb * (1.0 - ringAlpha),
248
+ ringAlpha + texColor.a * (1.0 - ringAlpha)
249
+ );
250
+ }
251
+ `;
252
+ var compileShader = (gl, type, source) => {
253
+ const shader = gl.createShader(type);
254
+ if (!shader) {
255
+ throw new Error("Failed to create WebGL shader");
256
+ }
257
+ gl.shaderSource(shader, source);
258
+ gl.compileShader(shader);
259
+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
260
+ const log = gl.getShaderInfoLog(shader);
261
+ gl.deleteShader(shader);
262
+ throw new Error(`Rings shader compile failed: ${log ?? "(no log)"}`);
263
+ }
264
+ return shader;
265
+ };
266
+ var linkProgram = (gl, vs, fs) => {
267
+ const program = gl.createProgram();
268
+ if (!program) {
269
+ throw new Error("Failed to create WebGL program");
270
+ }
271
+ gl.attachShader(program, vs);
272
+ gl.attachShader(program, fs);
273
+ gl.linkProgram(program);
274
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
275
+ const log = gl.getProgramInfoLog(program);
276
+ gl.deleteProgram(program);
277
+ throw new Error(`Rings program link failed: ${log ?? "(no log)"}`);
278
+ }
279
+ return program;
280
+ };
281
+ var createProgram = (gl, vertexSource, fragmentSource) => {
282
+ const vs = compileShader(gl, gl.VERTEX_SHADER, vertexSource);
283
+ const fs = compileShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
284
+ const program = linkProgram(gl, vs, fs);
285
+ gl.deleteShader(vs);
286
+ gl.deleteShader(fs);
287
+ return program;
288
+ };
289
+ var createTexture = (gl, filter) => {
290
+ const texture = gl.createTexture();
291
+ if (!texture) {
292
+ throw new Error("Failed to create WebGL texture");
293
+ }
294
+ gl.bindTexture(gl.TEXTURE_2D, texture);
295
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter);
296
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);
297
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
298
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
299
+ gl.bindTexture(gl.TEXTURE_2D, null);
300
+ return texture;
301
+ };
302
+ var setupRings = (target) => {
303
+ const gl = target.getContext("webgl2", {
304
+ premultipliedAlpha: true,
305
+ alpha: true,
306
+ preserveDrawingBuffer: true
307
+ });
308
+ if (!gl) {
309
+ throw createWebGL2ContextError("rings effect");
310
+ }
311
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
312
+ const program = createProgram(gl, RINGS_VS, RINGS_FS);
313
+ const vao = gl.createVertexArray();
314
+ if (!vao) {
315
+ throw new Error("Failed to create WebGL vertex array");
316
+ }
317
+ gl.bindVertexArray(vao);
318
+ const data = new Float32Array([
319
+ -1,
320
+ -1,
321
+ 0,
322
+ 0,
323
+ 1,
324
+ -1,
325
+ 1,
326
+ 0,
327
+ -1,
328
+ 1,
329
+ 0,
330
+ 1,
331
+ 1,
332
+ 1,
333
+ 1,
334
+ 1
335
+ ]);
336
+ const vbo = gl.createBuffer();
337
+ if (!vbo) {
338
+ throw new Error("Failed to create WebGL buffer");
339
+ }
340
+ gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
341
+ gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
342
+ const aPos = gl.getAttribLocation(program, "aPos");
343
+ const aUv = gl.getAttribLocation(program, "aUv");
344
+ gl.enableVertexAttribArray(aPos);
345
+ gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);
346
+ gl.enableVertexAttribArray(aUv);
347
+ gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);
348
+ gl.bindVertexArray(null);
349
+ const colorCanvas = document.createElement("canvas");
350
+ colorCanvas.width = 1;
351
+ colorCanvas.height = 1;
352
+ const colorCtx = colorCanvas.getContext("2d", { willReadFrequently: true });
353
+ if (!colorCtx) {
354
+ throw new Error("Failed to acquire 2D context for color parsing");
355
+ }
356
+ return {
357
+ gl,
358
+ program,
359
+ vao,
360
+ vbo,
361
+ sourceTexture: createTexture(gl, gl.LINEAR),
362
+ paletteTexture: createTexture(gl, gl.NEAREST),
363
+ colorCtx,
364
+ uniforms: {
365
+ uSource: gl.getUniformLocation(program, "uSource"),
366
+ uPalette: gl.getUniformLocation(program, "uPalette"),
367
+ uResolution: gl.getUniformLocation(program, "uResolution"),
368
+ uNumColors: gl.getUniformLocation(program, "uNumColors"),
369
+ uCenter: gl.getUniformLocation(program, "uCenter"),
370
+ uThickness: gl.getUniformLocation(program, "uThickness"),
371
+ uSpacing: gl.getUniformLocation(program, "uSpacing"),
372
+ uOffset: gl.getUniformLocation(program, "uOffset"),
373
+ uMaskToSourceAlpha: gl.getUniformLocation(program, "uMaskToSourceAlpha")
374
+ },
375
+ cachedPaletteKey: "",
376
+ palettePixelData: new Uint8Array(0)
377
+ };
378
+ };
379
+ var updatePalette = (state, colors) => {
380
+ const paletteKey = colors.join("|");
381
+ const paletteDirty = state.cachedPaletteKey !== paletteKey;
382
+ if (!paletteDirty) {
383
+ return false;
384
+ }
385
+ state.cachedPaletteKey = paletteKey;
386
+ const len = colors.length * 4;
387
+ if (state.palettePixelData.length !== len) {
388
+ state.palettePixelData = new Uint8Array(len);
389
+ }
390
+ const { palettePixelData } = state;
391
+ for (let i = 0;i < colors.length; i++) {
392
+ const color = parseColorRgba(state.colorCtx, colors[i]);
393
+ palettePixelData[i * 4] = color[0];
394
+ palettePixelData[i * 4 + 1] = color[1];
395
+ palettePixelData[i * 4 + 2] = color[2];
396
+ palettePixelData[i * 4 + 3] = color[3];
397
+ }
398
+ return true;
399
+ };
400
+ var rings2 = createEffect({
401
+ type: "dev.remotion.effects.rings",
402
+ label: "rings()",
403
+ documentationLink: "https://www.remotion.dev/docs/effects/rings",
404
+ calculateKey: (params) => {
405
+ const r = resolve(params);
406
+ const maskSuffix = r.maskToSourceAlpha ? "-mask-to-source-alpha" : "";
407
+ return `rings-${r.colors.join("|")}-${r.center.join(":")}-${r.thickness}-${r.spacing}-${r.offset}${maskSuffix}`;
408
+ },
409
+ implementations: {
410
+ webgpu: Internals.createEffectImplementation({
411
+ setup: (target) => setupWebGpuColors(target, "rings"),
412
+ apply: ({ source, width, height, params, state, gpuDevice }) => {
413
+ if (!gpuDevice)
414
+ throw new Error("A WebGPU device is required for the rings effect");
415
+ const r = resolve(params);
416
+ const colors = getWebGpuColors(state, r.colors);
417
+ const uniformData = new Float32Array([
418
+ width,
419
+ height,
420
+ r.colors.length,
421
+ 0,
422
+ r.thickness,
423
+ r.spacing,
424
+ 0,
425
+ r.offset,
426
+ r.center[0],
427
+ 1 - r.center[1],
428
+ 0,
429
+ 0,
430
+ r.maskToSourceAlpha ? 1 : 0,
431
+ 0,
432
+ 0,
433
+ 0
434
+ ]);
435
+ applyWebGpuSinglePass({
436
+ state,
437
+ source,
438
+ width,
439
+ height,
440
+ device: gpuDevice,
441
+ shader: RINGS_WEBGPU_SHADER,
442
+ uniformData
443
+ }, {
444
+ sourceFilter: null,
445
+ auxiliaryTexture: {
446
+ data: colors,
447
+ width: r.colors.length,
448
+ height: 1,
449
+ format: "rgba8unorm"
450
+ }
451
+ });
452
+ },
453
+ cleanup: cleanupWebGpuSinglePass
454
+ }),
455
+ webgl2: Internals.createEffectImplementation({
456
+ setup: (target) => setupRings(target),
457
+ apply: ({ source, width, height, params, state, flipSourceY }) => {
458
+ const r = resolve(params);
459
+ const paletteDirty = updatePalette(state, r.colors);
460
+ const { gl, program, sourceTexture, paletteTexture, uniforms, vao } = state;
461
+ gl.viewport(0, 0, width, height);
462
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
463
+ gl.clearColor(0, 0, 0, 0);
464
+ gl.clear(gl.COLOR_BUFFER_BIT);
465
+ gl.activeTexture(gl.TEXTURE0);
466
+ gl.bindTexture(gl.TEXTURE_2D, sourceTexture);
467
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
468
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipSourceY);
469
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
470
+ gl.activeTexture(gl.TEXTURE1);
471
+ gl.bindTexture(gl.TEXTURE_2D, paletteTexture);
472
+ if (paletteDirty) {
473
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
474
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
475
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, r.colors.length, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, state.palettePixelData);
476
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
477
+ }
478
+ gl.useProgram(program);
479
+ if (uniforms.uSource)
480
+ gl.uniform1i(uniforms.uSource, 0);
481
+ if (uniforms.uPalette)
482
+ gl.uniform1i(uniforms.uPalette, 1);
483
+ if (uniforms.uResolution)
484
+ gl.uniform2f(uniforms.uResolution, width, height);
485
+ if (uniforms.uNumColors)
486
+ gl.uniform1f(uniforms.uNumColors, r.colors.length);
487
+ if (uniforms.uCenter) {
488
+ const shaderCenter = publicUvToShaderUv(r.center);
489
+ gl.uniform2f(uniforms.uCenter, shaderCenter[0], shaderCenter[1]);
490
+ }
491
+ if (uniforms.uThickness)
492
+ gl.uniform1f(uniforms.uThickness, r.thickness);
493
+ if (uniforms.uSpacing)
494
+ gl.uniform1f(uniforms.uSpacing, r.spacing);
495
+ if (uniforms.uOffset)
496
+ gl.uniform1f(uniforms.uOffset, r.offset);
497
+ if (uniforms.uMaskToSourceAlpha)
498
+ gl.uniform1i(uniforms.uMaskToSourceAlpha, r.maskToSourceAlpha ? 1 : 0);
499
+ gl.bindVertexArray(vao);
500
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
501
+ gl.bindVertexArray(null);
502
+ gl.bindTexture(gl.TEXTURE_2D, null);
503
+ gl.useProgram(null);
504
+ },
505
+ cleanup: ({ gl, program, vao, vbo, sourceTexture, paletteTexture }) => {
506
+ gl.deleteTexture(sourceTexture);
507
+ gl.deleteTexture(paletteTexture);
508
+ gl.deleteBuffer(vbo);
509
+ gl.deleteProgram(program);
510
+ gl.deleteVertexArray(vao);
511
+ }
512
+ })
513
+ },
514
+ schema: ringsSchema2,
515
+ validateParams: validateRingsParams
516
+ });
517
+
518
+ export { ringsSchema2, rings2 };
@@ -0,0 +1,32 @@
1
+ // src/validate-effect-param.ts
2
+ var assertEffectParamsObject = (params, effectLabel) => {
3
+ if (params === null || typeof params !== "object") {
4
+ throw new TypeError(`${effectLabel} effect requires a parameters object, but got ${JSON.stringify(params)}`);
5
+ }
6
+ };
7
+ var assertRequiredFiniteNumber = (value, name) => {
8
+ if (typeof value !== "number" || !Number.isFinite(value)) {
9
+ throw new TypeError(`"${name}" must be a finite number, but got ${JSON.stringify(value)}`);
10
+ }
11
+ };
12
+ var assertRequiredColor = (value, name) => {
13
+ if (typeof value !== "string" || value.length === 0) {
14
+ throw new TypeError(`"${name}" must be a non-empty string, but got ${JSON.stringify(value)}`);
15
+ }
16
+ };
17
+ var assertOptionalColor = (value, name) => {
18
+ if (value === undefined) {
19
+ return;
20
+ }
21
+ assertRequiredColor(value, name);
22
+ };
23
+ var assertOptionalBoolean = (value, name) => {
24
+ if (value === undefined) {
25
+ return;
26
+ }
27
+ if (typeof value !== "boolean") {
28
+ throw new TypeError(`"${name}" must be a boolean, but got ${JSON.stringify(value)}`);
29
+ }
30
+ };
31
+
32
+ export { assertEffectParamsObject, assertRequiredFiniteNumber, assertRequiredColor, assertOptionalColor, assertOptionalBoolean };