@remotion/effects 4.0.467 → 4.0.469

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 (43) hide show
  1. package/dist/color-utils.d.ts +2 -0
  2. package/dist/dot-grid.d.ts +31 -0
  3. package/dist/drop-shadow/drop-shadow-runtime.d.ts +54 -0
  4. package/dist/drop-shadow/drop-shadow-shaders.d.ts +5 -0
  5. package/dist/drop-shadow/index.d.ts +15 -0
  6. package/dist/drop-shadow.d.ts +1 -0
  7. package/dist/duotone.d.ts +31 -0
  8. package/dist/esm/barrel-distortion.mjs +14 -1
  9. package/dist/esm/blur.mjs +38 -17
  10. package/dist/esm/brightness.mjs +14 -1
  11. package/dist/esm/chromatic-aberration.mjs +14 -1
  12. package/dist/esm/contrast.mjs +14 -1
  13. package/dist/esm/dot-grid.mjs +349 -0
  14. package/dist/esm/drop-shadow.mjs +610 -0
  15. package/dist/esm/duotone.mjs +365 -0
  16. package/dist/esm/glow.mjs +599 -0
  17. package/dist/esm/grayscale.mjs +14 -1
  18. package/dist/esm/halftone-linear-gradient.mjs +480 -0
  19. package/dist/esm/halftone.mjs +17 -18
  20. package/dist/esm/hue.mjs +14 -1
  21. package/dist/esm/invert.mjs +14 -1
  22. package/dist/esm/mirror.mjs +14 -1
  23. package/dist/esm/noise.mjs +341 -0
  24. package/dist/esm/saturation.mjs +14 -1
  25. package/dist/esm/scale.mjs +7 -1
  26. package/dist/esm/shine.mjs +389 -0
  27. package/dist/esm/speckle.mjs +360 -0
  28. package/dist/esm/tint.mjs +14 -1
  29. package/dist/esm/translate.mjs +15 -2
  30. package/dist/esm/vignette.mjs +439 -0
  31. package/dist/esm/wave.mjs +7 -1
  32. package/dist/gaussian-blur-shader.d.ts +1 -0
  33. package/dist/glow/glow-runtime.d.ts +52 -0
  34. package/dist/glow/glow-shaders.d.ts +5 -0
  35. package/dist/glow/index.d.ts +13 -0
  36. package/dist/glow.d.ts +1 -0
  37. package/dist/halftone-linear-gradient.d.ts +93 -0
  38. package/dist/noise.d.ts +11 -0
  39. package/dist/shine.d.ts +17 -0
  40. package/dist/speckle.d.ts +11 -0
  41. package/dist/validate-effect-param.d.ts +1 -0
  42. package/dist/vignette.d.ts +68 -0
  43. package/package.json +75 -3
@@ -0,0 +1,599 @@
1
+ // src/glow/index.ts
2
+ import { Internals as Internals2 } from "remotion";
3
+
4
+ // src/validate-effect-param.ts
5
+ var assertEffectParamsObject = (params, effectLabel) => {
6
+ if (params === null || typeof params !== "object") {
7
+ throw new TypeError(`${effectLabel} effect requires a parameters object, but got ${JSON.stringify(params)}`);
8
+ }
9
+ };
10
+ var assertRequiredFiniteNumber = (value, name) => {
11
+ if (typeof value !== "number" || !Number.isFinite(value)) {
12
+ throw new TypeError(`"${name}" must be a finite number, but got ${JSON.stringify(value)}`);
13
+ }
14
+ };
15
+ var assertRequiredColor = (value, name) => {
16
+ if (typeof value !== "string" || value.length === 0) {
17
+ throw new TypeError(`"${name}" must be a non-empty string, but got ${JSON.stringify(value)}`);
18
+ }
19
+ };
20
+ var assertOptionalColor = (value, name) => {
21
+ if (value === undefined) {
22
+ return;
23
+ }
24
+ assertRequiredColor(value, name);
25
+ };
26
+
27
+ // src/color-utils.ts
28
+ var DEFAULT_AMOUNT = 1;
29
+ var DEFAULT_BRIGHTNESS_AMOUNT = 0;
30
+ var DEFAULT_HUE_DEGREES = 0;
31
+ var colorAmountSchema = {
32
+ type: "number",
33
+ min: 0,
34
+ max: 1,
35
+ step: 0.01,
36
+ default: DEFAULT_AMOUNT,
37
+ description: "Amount"
38
+ };
39
+ var colorMultiplierSchema = {
40
+ type: "number",
41
+ min: 0,
42
+ step: 0.01,
43
+ default: DEFAULT_AMOUNT,
44
+ description: "Amount"
45
+ };
46
+ var brightnessAmountSchema = {
47
+ type: "number",
48
+ min: -1,
49
+ max: 1,
50
+ step: 0.01,
51
+ default: DEFAULT_BRIGHTNESS_AMOUNT,
52
+ description: "Amount"
53
+ };
54
+ var hueDegreesSchema = {
55
+ type: "number",
56
+ step: 1,
57
+ default: DEFAULT_HUE_DEGREES,
58
+ description: "Degrees"
59
+ };
60
+ var assertOptionalFiniteNumber = (value, name) => {
61
+ if (value === undefined) {
62
+ return;
63
+ }
64
+ assertRequiredFiniteNumber(value, name);
65
+ };
66
+ var validateUnitInterval = (value, name) => {
67
+ if (value < 0) {
68
+ throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
69
+ }
70
+ if (value > 1) {
71
+ throw new TypeError(`"${name}" must be <= 1, but got ${JSON.stringify(value)}`);
72
+ }
73
+ };
74
+ var validateNonNegative = (value, name) => {
75
+ if (value < 0) {
76
+ throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
77
+ }
78
+ };
79
+ var validateSignedUnitInterval = (value, name) => {
80
+ if (value < -1) {
81
+ throw new TypeError(`"${name}" must be >= -1, but got ${JSON.stringify(value)}`);
82
+ }
83
+ if (value > 1) {
84
+ throw new TypeError(`"${name}" must be <= 1, but got ${JSON.stringify(value)}`);
85
+ }
86
+ };
87
+ var clampColorChannel = (value) => {
88
+ return Math.max(0, Math.min(255, value));
89
+ };
90
+ var parseColorRgba = (ctx, color) => {
91
+ ctx.clearRect(0, 0, 1, 1);
92
+ ctx.fillStyle = color;
93
+ ctx.fillRect(0, 0, 1, 1);
94
+ const { data } = ctx.getImageData(0, 0, 1, 1);
95
+ return [data[0], data[1], data[2], data[3]];
96
+ };
97
+
98
+ // src/glow/glow-runtime.ts
99
+ import { Internals } from "remotion";
100
+
101
+ // src/gaussian-blur-shader.ts
102
+ var buildGaussianBlurFs = (direction) => {
103
+ const dirVec = direction === "horizontal" ? "vec2(1.0, 0.0)" : "vec2(0.0, 1.0)";
104
+ return `#version 300 es
105
+ precision highp float;
106
+
107
+ in vec2 vUv;
108
+ out vec4 fragColor;
109
+
110
+ uniform sampler2D uSource;
111
+ uniform float uRadius;
112
+ uniform vec2 uTexelSize;
113
+
114
+ const int MIN_KERNEL_HALF = 4;
115
+ const int MAX_KERNEL_HALF = 32;
116
+ const float TARGET_SAMPLE_DISTANCE_PX = 2.0;
117
+ const vec2 DIRECTION = ${dirVec};
118
+
119
+ void main() {
120
+ if (uRadius <= 0.0) {
121
+ fragColor = texture(uSource, vUv);
122
+ return;
123
+ }
124
+
125
+ int kernelHalf = int(
126
+ min(
127
+ float(MAX_KERNEL_HALF),
128
+ max(float(MIN_KERNEL_HALF), ceil(uRadius / TARGET_SAMPLE_DISTANCE_PX))
129
+ )
130
+ );
131
+ float pixelStride = uRadius / float(kernelHalf);
132
+ float sigma = uRadius / 3.0;
133
+ float twoSigmaSq = 2.0 * sigma * sigma;
134
+
135
+ vec4 sum = vec4(0.0);
136
+ float weightSum = 0.0;
137
+
138
+ for (int i = -MAX_KERNEL_HALF; i <= MAX_KERNEL_HALF; ++i) {
139
+ if (abs(i) > kernelHalf) {
140
+ continue;
141
+ }
142
+
143
+ float offsetPx = float(i) * pixelStride;
144
+ float w = exp(-(offsetPx * offsetPx) / twoSigmaSq);
145
+ vec2 uv = vUv + DIRECTION * uTexelSize * offsetPx;
146
+ sum += texture(uSource, uv) * w;
147
+ weightSum += w;
148
+ }
149
+
150
+ fragColor = sum / weightSum;
151
+ }
152
+ `;
153
+ };
154
+
155
+ // src/glow/glow-shaders.ts
156
+ var GLOW_VS = `#version 300 es
157
+ layout(location = 0) in vec2 aPos;
158
+ layout(location = 1) in vec2 aUv;
159
+ out vec2 vUv;
160
+
161
+ void main() {
162
+ vUv = aUv;
163
+ gl_Position = vec4(aPos, 0.0, 1.0);
164
+ }
165
+ `;
166
+ var GLOW_EXTRACT_FS = `#version 300 es
167
+ precision highp float;
168
+
169
+ in vec2 vUv;
170
+ out vec4 fragColor;
171
+
172
+ uniform sampler2D uSource;
173
+ uniform vec4 uColor;
174
+ uniform float uThreshold;
175
+
176
+ void main() {
177
+ vec4 source = texture(uSource, vUv);
178
+ float alpha = source.a;
179
+
180
+ if (alpha <= 0.001) {
181
+ fragColor = vec4(0.0);
182
+ return;
183
+ }
184
+
185
+ vec3 rgb = source.rgb / alpha;
186
+ float luminance = dot(rgb, vec3(0.299, 0.587, 0.114));
187
+ float threshold = clamp(uThreshold, 0.0, 1.0);
188
+ float contribution = threshold >= 1.0
189
+ ? step(1.0, luminance)
190
+ : clamp((luminance - threshold) / max(1.0 - threshold, 0.0001), 0.0, 1.0);
191
+ float glowAlpha = alpha * contribution * uColor.a;
192
+
193
+ fragColor = vec4(uColor.rgb * glowAlpha, glowAlpha);
194
+ }
195
+ `;
196
+ var GLOW_BLUR_FS_HORIZONTAL = buildGaussianBlurFs("horizontal");
197
+ var GLOW_BLUR_FS_VERTICAL = buildGaussianBlurFs("vertical");
198
+ var GLOW_COMPOSITE_FS = `#version 300 es
199
+ precision highp float;
200
+
201
+ in vec2 vUv;
202
+ out vec4 fragColor;
203
+
204
+ uniform sampler2D uSource;
205
+ uniform sampler2D uGlow;
206
+ uniform float uIntensity;
207
+
208
+ void main() {
209
+ vec4 source = texture(uSource, vUv);
210
+ vec4 glow = texture(uGlow, vUv) * max(uIntensity, 0.0);
211
+ vec4 outColor = source + glow;
212
+
213
+ fragColor = vec4(min(outColor.rgb, vec3(1.0)), min(outColor.a, 1.0));
214
+ }
215
+ `;
216
+
217
+ // src/glow/glow-runtime.ts
218
+ var { createWebGL2ContextError } = Internals;
219
+ var compileShader = (gl, type, source) => {
220
+ const shader = gl.createShader(type);
221
+ if (!shader) {
222
+ throw new Error("Failed to create WebGL shader");
223
+ }
224
+ gl.shaderSource(shader, source);
225
+ gl.compileShader(shader);
226
+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
227
+ const log = gl.getShaderInfoLog(shader);
228
+ gl.deleteShader(shader);
229
+ throw new Error(`Glow shader compile failed: ${log ?? "(no log)"}`);
230
+ }
231
+ return shader;
232
+ };
233
+ var linkProgram = (gl, vs, fs) => {
234
+ const program = gl.createProgram();
235
+ if (!program) {
236
+ throw new Error("Failed to create WebGL program");
237
+ }
238
+ gl.attachShader(program, vs);
239
+ gl.attachShader(program, fs);
240
+ gl.linkProgram(program);
241
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
242
+ const log = gl.getProgramInfoLog(program);
243
+ gl.deleteProgram(program);
244
+ throw new Error(`Glow program link failed: ${log ?? "(no log)"}`);
245
+ }
246
+ return program;
247
+ };
248
+ var createProgram = (gl, vertexSource, fragmentSource) => {
249
+ const vs = compileShader(gl, gl.VERTEX_SHADER, vertexSource);
250
+ const fs = compileShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
251
+ const program = linkProgram(gl, vs, fs);
252
+ gl.deleteShader(vs);
253
+ gl.deleteShader(fs);
254
+ return program;
255
+ };
256
+ var createRgbaTexture = (gl) => {
257
+ const texture = gl.createTexture();
258
+ if (!texture) {
259
+ throw new Error("Failed to create WebGL texture");
260
+ }
261
+ gl.bindTexture(gl.TEXTURE_2D, texture);
262
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
263
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
264
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
265
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
266
+ gl.bindTexture(gl.TEXTURE_2D, null);
267
+ return texture;
268
+ };
269
+ var getBlurUniforms = (gl, program) => ({
270
+ uRadius: gl.getUniformLocation(program, "uRadius"),
271
+ uTexelSize: gl.getUniformLocation(program, "uTexelSize"),
272
+ uSource: gl.getUniformLocation(program, "uSource")
273
+ });
274
+ var setupGlow = (target) => {
275
+ const gl = target.getContext("webgl2", {
276
+ premultipliedAlpha: true,
277
+ alpha: true,
278
+ preserveDrawingBuffer: true
279
+ });
280
+ if (!gl) {
281
+ throw createWebGL2ContextError("glow effect");
282
+ }
283
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
284
+ const programExtract = createProgram(gl, GLOW_VS, GLOW_EXTRACT_FS);
285
+ const programHorizontal = createProgram(gl, GLOW_VS, GLOW_BLUR_FS_HORIZONTAL);
286
+ const programVertical = createProgram(gl, GLOW_VS, GLOW_BLUR_FS_VERTICAL);
287
+ const programComposite = createProgram(gl, GLOW_VS, GLOW_COMPOSITE_FS);
288
+ const vao = gl.createVertexArray();
289
+ if (!vao) {
290
+ throw new Error("Failed to create WebGL vertex array");
291
+ }
292
+ gl.bindVertexArray(vao);
293
+ const data = new Float32Array([
294
+ -1,
295
+ -1,
296
+ 0,
297
+ 0,
298
+ 1,
299
+ -1,
300
+ 1,
301
+ 0,
302
+ -1,
303
+ 1,
304
+ 0,
305
+ 1,
306
+ 1,
307
+ 1,
308
+ 1,
309
+ 1
310
+ ]);
311
+ const vbo = gl.createBuffer();
312
+ if (!vbo) {
313
+ throw new Error("Failed to create WebGL buffer");
314
+ }
315
+ gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
316
+ gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
317
+ gl.enableVertexAttribArray(0);
318
+ gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 16, 0);
319
+ gl.enableVertexAttribArray(1);
320
+ gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 16, 8);
321
+ gl.bindVertexArray(null);
322
+ const textureSource = createRgbaTexture(gl);
323
+ const textureGlowA = createRgbaTexture(gl);
324
+ const textureGlowB = createRgbaTexture(gl);
325
+ const framebuffer = gl.createFramebuffer();
326
+ if (!framebuffer) {
327
+ throw new Error("Failed to create WebGL framebuffer");
328
+ }
329
+ const colorCanvas = document.createElement("canvas");
330
+ colorCanvas.width = 1;
331
+ colorCanvas.height = 1;
332
+ const colorCtx = colorCanvas.getContext("2d", { willReadFrequently: true });
333
+ if (!colorCtx) {
334
+ throw new Error("Failed to acquire 2D context for color parsing");
335
+ }
336
+ return {
337
+ gl,
338
+ programExtract,
339
+ programHorizontal,
340
+ programVertical,
341
+ programComposite,
342
+ vao,
343
+ vbo,
344
+ textureSource,
345
+ textureGlowA,
346
+ textureGlowB,
347
+ framebuffer,
348
+ extract: {
349
+ uSource: gl.getUniformLocation(programExtract, "uSource"),
350
+ uColor: gl.getUniformLocation(programExtract, "uColor"),
351
+ uThreshold: gl.getUniformLocation(programExtract, "uThreshold")
352
+ },
353
+ horizontal: getBlurUniforms(gl, programHorizontal),
354
+ vertical: getBlurUniforms(gl, programVertical),
355
+ composite: {
356
+ uSource: gl.getUniformLocation(programComposite, "uSource"),
357
+ uGlow: gl.getUniformLocation(programComposite, "uGlow"),
358
+ uIntensity: gl.getUniformLocation(programComposite, "uIntensity")
359
+ },
360
+ colorCtx,
361
+ cachedColorStr: "",
362
+ cachedColorRgba: [255, 255, 255, 255]
363
+ };
364
+ };
365
+ var cleanupGlow = ({
366
+ gl,
367
+ programExtract,
368
+ programHorizontal,
369
+ programVertical,
370
+ programComposite,
371
+ vao,
372
+ vbo,
373
+ textureSource,
374
+ textureGlowA,
375
+ textureGlowB,
376
+ framebuffer
377
+ }) => {
378
+ gl.deleteFramebuffer(framebuffer);
379
+ gl.deleteTexture(textureSource);
380
+ gl.deleteTexture(textureGlowA);
381
+ gl.deleteTexture(textureGlowB);
382
+ gl.deleteBuffer(vbo);
383
+ gl.deleteProgram(programExtract);
384
+ gl.deleteProgram(programHorizontal);
385
+ gl.deleteProgram(programVertical);
386
+ gl.deleteProgram(programComposite);
387
+ gl.deleteVertexArray(vao);
388
+ };
389
+ var drawFullscreenQuad = (state) => {
390
+ const { gl, vao } = state;
391
+ gl.bindVertexArray(vao);
392
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
393
+ gl.bindVertexArray(null);
394
+ };
395
+ var setTextureSize = (gl, texture, width, height) => {
396
+ gl.bindTexture(gl.TEXTURE_2D, texture);
397
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
398
+ };
399
+ var setFramebufferTexture = (gl, framebuffer, texture) => {
400
+ gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
401
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
402
+ const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
403
+ if (status !== gl.FRAMEBUFFER_COMPLETE) {
404
+ throw new Error(`Glow framebuffer incomplete: 0x${status.toString(16)}`);
405
+ }
406
+ };
407
+ var setBlurUniforms = ({
408
+ gl,
409
+ uniforms,
410
+ radius,
411
+ width,
412
+ height
413
+ }) => {
414
+ if (uniforms.uSource)
415
+ gl.uniform1i(uniforms.uSource, 0);
416
+ if (uniforms.uRadius)
417
+ gl.uniform1f(uniforms.uRadius, radius);
418
+ if (uniforms.uTexelSize)
419
+ gl.uniform2f(uniforms.uTexelSize, 1 / width, 1 / height);
420
+ };
421
+ var normalizedColor = (color) => {
422
+ return [color[0] / 255, color[1] / 255, color[2] / 255, color[3] / 255];
423
+ };
424
+ var applyGlow = ({
425
+ state,
426
+ source,
427
+ width,
428
+ height,
429
+ radius,
430
+ intensity,
431
+ threshold,
432
+ color,
433
+ flipSourceY
434
+ }) => {
435
+ const {
436
+ gl,
437
+ textureSource,
438
+ textureGlowA,
439
+ textureGlowB,
440
+ framebuffer,
441
+ programExtract,
442
+ programHorizontal,
443
+ programVertical,
444
+ programComposite
445
+ } = state;
446
+ gl.viewport(0, 0, width, height);
447
+ gl.clearColor(0, 0, 0, 0);
448
+ gl.activeTexture(gl.TEXTURE0);
449
+ gl.bindTexture(gl.TEXTURE_2D, textureSource);
450
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipSourceY);
451
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
452
+ setTextureSize(gl, textureGlowA, width, height);
453
+ setTextureSize(gl, textureGlowB, width, height);
454
+ const [r, g, b, a] = normalizedColor(color);
455
+ setFramebufferTexture(gl, framebuffer, textureGlowA);
456
+ gl.clear(gl.COLOR_BUFFER_BIT);
457
+ gl.useProgram(programExtract);
458
+ gl.activeTexture(gl.TEXTURE0);
459
+ gl.bindTexture(gl.TEXTURE_2D, textureSource);
460
+ if (state.extract.uSource)
461
+ gl.uniform1i(state.extract.uSource, 0);
462
+ if (state.extract.uColor)
463
+ gl.uniform4f(state.extract.uColor, r, g, b, a);
464
+ if (state.extract.uThreshold)
465
+ gl.uniform1f(state.extract.uThreshold, threshold);
466
+ drawFullscreenQuad(state);
467
+ setFramebufferTexture(gl, framebuffer, textureGlowB);
468
+ gl.clear(gl.COLOR_BUFFER_BIT);
469
+ gl.useProgram(programHorizontal);
470
+ gl.activeTexture(gl.TEXTURE0);
471
+ gl.bindTexture(gl.TEXTURE_2D, textureGlowA);
472
+ setBlurUniforms({
473
+ gl,
474
+ uniforms: state.horizontal,
475
+ radius,
476
+ width,
477
+ height
478
+ });
479
+ drawFullscreenQuad(state);
480
+ setFramebufferTexture(gl, framebuffer, textureGlowA);
481
+ gl.clear(gl.COLOR_BUFFER_BIT);
482
+ gl.useProgram(programVertical);
483
+ gl.activeTexture(gl.TEXTURE0);
484
+ gl.bindTexture(gl.TEXTURE_2D, textureGlowB);
485
+ setBlurUniforms({
486
+ gl,
487
+ uniforms: state.vertical,
488
+ radius,
489
+ width,
490
+ height
491
+ });
492
+ drawFullscreenQuad(state);
493
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
494
+ gl.clear(gl.COLOR_BUFFER_BIT);
495
+ gl.useProgram(programComposite);
496
+ gl.activeTexture(gl.TEXTURE0);
497
+ gl.bindTexture(gl.TEXTURE_2D, textureSource);
498
+ gl.activeTexture(gl.TEXTURE1);
499
+ gl.bindTexture(gl.TEXTURE_2D, textureGlowA);
500
+ if (state.composite.uSource)
501
+ gl.uniform1i(state.composite.uSource, 0);
502
+ if (state.composite.uGlow)
503
+ gl.uniform1i(state.composite.uGlow, 1);
504
+ if (state.composite.uIntensity)
505
+ gl.uniform1f(state.composite.uIntensity, intensity);
506
+ drawFullscreenQuad(state);
507
+ gl.bindTexture(gl.TEXTURE_2D, null);
508
+ gl.useProgram(null);
509
+ };
510
+
511
+ // src/glow/index.ts
512
+ var { createEffect } = Internals2;
513
+ var DEFAULT_RADIUS = 20;
514
+ var DEFAULT_INTENSITY = 1;
515
+ var DEFAULT_THRESHOLD = 0;
516
+ var DEFAULT_COLOR = "#ffffff";
517
+ var glowSchema = {
518
+ radius: {
519
+ type: "number",
520
+ min: 0,
521
+ max: 100,
522
+ step: 1,
523
+ default: DEFAULT_RADIUS,
524
+ description: "Radius"
525
+ },
526
+ intensity: {
527
+ type: "number",
528
+ min: 0,
529
+ max: 5,
530
+ step: 0.1,
531
+ default: DEFAULT_INTENSITY,
532
+ description: "Intensity"
533
+ },
534
+ threshold: {
535
+ type: "number",
536
+ min: 0,
537
+ max: 1,
538
+ step: 0.01,
539
+ default: DEFAULT_THRESHOLD,
540
+ description: "Threshold"
541
+ },
542
+ color: {
543
+ type: "color",
544
+ default: DEFAULT_COLOR,
545
+ description: "Color"
546
+ }
547
+ };
548
+ var resolve = (p) => ({
549
+ radius: p.radius ?? DEFAULT_RADIUS,
550
+ intensity: p.intensity ?? DEFAULT_INTENSITY,
551
+ threshold: p.threshold ?? DEFAULT_THRESHOLD,
552
+ color: p.color ?? DEFAULT_COLOR
553
+ });
554
+ var validateGlowParams = (params) => {
555
+ assertEffectParamsObject(params, "Glow");
556
+ assertOptionalFiniteNumber(params.radius, "radius");
557
+ assertOptionalFiniteNumber(params.intensity, "intensity");
558
+ assertOptionalFiniteNumber(params.threshold, "threshold");
559
+ assertOptionalColor(params.color, "color");
560
+ const r = resolve(params);
561
+ validateNonNegative(r.radius, "radius");
562
+ validateNonNegative(r.intensity, "intensity");
563
+ validateUnitInterval(r.threshold, "threshold");
564
+ };
565
+ var glow = createEffect({
566
+ type: "remotion/glow",
567
+ label: "Glow",
568
+ documentationLink: "https://www.remotion.dev/docs/effects/glow",
569
+ backend: "webgl2",
570
+ calculateKey: (params) => {
571
+ const r = resolve(params);
572
+ return `glow-${r.radius}-${r.intensity}-${r.threshold}-${r.color}`;
573
+ },
574
+ setup: (target) => setupGlow(target),
575
+ apply: ({ source, width, height, params, state, flipSourceY }) => {
576
+ const r = resolve(params);
577
+ if (state.cachedColorStr !== r.color) {
578
+ state.cachedColorStr = r.color;
579
+ state.cachedColorRgba = parseColorRgba(state.colorCtx, r.color);
580
+ }
581
+ applyGlow({
582
+ state,
583
+ source,
584
+ width,
585
+ height,
586
+ radius: r.radius,
587
+ intensity: r.intensity,
588
+ threshold: r.threshold,
589
+ color: state.cachedColorRgba,
590
+ flipSourceY
591
+ });
592
+ },
593
+ cleanup: (state) => cleanupGlow(state),
594
+ schema: glowSchema,
595
+ validateParams: validateGlowParams
596
+ });
597
+ export {
598
+ glow
599
+ };
@@ -17,6 +17,12 @@ var assertRequiredColor = (value, name) => {
17
17
  throw new TypeError(`"${name}" must be a non-empty string, but got ${JSON.stringify(value)}`);
18
18
  }
19
19
  };
20
+ var assertOptionalColor = (value, name) => {
21
+ if (value === undefined) {
22
+ return;
23
+ }
24
+ assertRequiredColor(value, name);
25
+ };
20
26
 
21
27
  // src/color-utils.ts
22
28
  var DEFAULT_AMOUNT = 1;
@@ -81,6 +87,13 @@ var validateSignedUnitInterval = (value, name) => {
81
87
  var clampColorChannel = (value) => {
82
88
  return Math.max(0, Math.min(255, value));
83
89
  };
90
+ var parseColorRgba = (ctx, color) => {
91
+ ctx.clearRect(0, 0, 1, 1);
92
+ ctx.fillStyle = color;
93
+ ctx.fillRect(0, 0, 1, 1);
94
+ const { data } = ctx.getImageData(0, 0, 1, 1);
95
+ return [data[0], data[1], data[2], data[3]];
96
+ };
84
97
 
85
98
  // src/grayscale.ts
86
99
  var { createEffect } = Internals;
@@ -98,7 +111,7 @@ var validateGrayscaleParams = (params) => {
98
111
  };
99
112
  var grayscale = createEffect({
100
113
  type: "remotion/grayscale",
101
- label: "Grayscale",
114
+ label: "grayscale()",
102
115
  documentationLink: "https://www.remotion.dev/docs/effects/grayscale",
103
116
  backend: "2d",
104
117
  calculateKey: (params) => {