@remotion/light-leaks 4.0.498 → 4.0.500

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.
@@ -1,3 +1,9 @@
1
+ // src/light-leak-internals.ts
2
+ import {
3
+ lightLeak,
4
+ lightLeakEffectSchema
5
+ } from "@remotion/effects/light-leak";
6
+
1
7
  // src/LightLeak.tsx
2
8
  import { useCallback, useEffect, useRef, useState } from "react";
3
9
  import {
@@ -243,334 +249,8 @@ var LightLeak = Interactive.withSchema({
243
249
  supportsEffects: false
244
250
  });
245
251
  LightLeak.displayName = "LightLeak";
246
- // src/light-leak-internals.ts
247
- import { Internals as Internals2 } from "remotion";
248
- var { createEffect, createWebGL2ContextError } = Internals2;
249
- var DEFAULT_SEED = 0;
250
- var DEFAULT_HUE_SHIFT = 0;
251
- var DEFAULT_PROGRESS = 0.5;
252
- var lightLeakEffectSchema = {
253
- seed: {
254
- type: "number",
255
- default: DEFAULT_SEED,
256
- description: "Seed",
257
- hiddenFromList: false
258
- },
259
- hueShift: {
260
- type: "number",
261
- min: 0,
262
- max: 360,
263
- default: DEFAULT_HUE_SHIFT,
264
- description: "Hue Shift",
265
- hiddenFromList: false
266
- },
267
- progress: {
268
- type: "number",
269
- min: 0,
270
- max: 1,
271
- step: 0.01,
272
- default: DEFAULT_PROGRESS,
273
- description: "Progress",
274
- hiddenFromList: false
275
- }
276
- };
277
- var resolve = (p) => ({
278
- seed: p.seed ?? DEFAULT_SEED,
279
- hueShift: p.hueShift ?? DEFAULT_HUE_SHIFT,
280
- progress: p.progress ?? DEFAULT_PROGRESS
281
- });
282
- var assertEffectParamsObject = (params, effectLabel) => {
283
- if (params === null || typeof params !== "object") {
284
- throw new TypeError(`${effectLabel} effect requires a parameters object, but got ${JSON.stringify(params)}`);
285
- }
286
- };
287
- var assertOptionalFiniteNumber = (value, name) => {
288
- if (value === undefined) {
289
- return;
290
- }
291
- if (typeof value !== "number" || !Number.isFinite(value)) {
292
- throw new TypeError(`"${name}" must be a finite number, but got ${JSON.stringify(value)}`);
293
- }
294
- };
295
- var validateUnitInterval = (value, name) => {
296
- if (value < 0) {
297
- throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
298
- }
299
- if (value > 1) {
300
- throw new TypeError(`"${name}" must be <= 1, but got ${JSON.stringify(value)}`);
301
- }
302
- };
303
- var validateLightLeakParams = (params) => {
304
- assertEffectParamsObject(params, "lightLeak()");
305
- assertOptionalFiniteNumber(params.seed, "seed");
306
- assertOptionalFiniteNumber(params.hueShift, "hueShift");
307
- assertOptionalFiniteNumber(params.progress, "progress");
308
- const { hueShift, progress } = resolve(params);
309
- if (hueShift < 0) {
310
- throw new TypeError(`"hueShift" must be >= 0, but got ${hueShift}`);
311
- }
312
- if (hueShift > 360) {
313
- throw new TypeError(`"hueShift" must be <= 360, but got ${hueShift}`);
314
- }
315
- validateUnitInterval(progress, "progress");
316
- };
317
- var LIGHT_LEAK_VS = `#version 300 es
318
- in vec2 aPos;
319
- in vec2 aUv;
320
- out vec2 vUv;
321
- void main() {
322
- vUv = aUv;
323
- gl_Position = vec4(aPos, 0.0, 1.0);
324
- }
325
- `;
326
- var LIGHT_LEAK_FS = `#version 300 es
327
- precision highp float;
328
-
329
- in vec2 vUv;
330
- out vec4 fragColor;
331
-
332
- uniform sampler2D uSource;
333
- uniform float evolveProgress;
334
- uniform float retractProgress;
335
- uniform float seed;
336
- uniform float retractSeed;
337
- uniform float hueShift;
338
- uniform vec2 resolution;
339
-
340
- const float Pi = 3.14159;
341
-
342
- vec3 computePattern(vec2 uv, float s, float t) {
343
- vec2 p = uv * 0.8;
344
- p += vec2(sin(s * 1.61803) * 5.0, cos(s * 2.71828) * 5.0);
345
-
346
- for (int i = 1; i < 5; i++) {
347
- vec2 newp = p;
348
- float fi = float(i);
349
- float phase = s * 0.7 * fi;
350
- newp.x += 0.6 / fi * cos(fi * p.y + t * 0.7 + 0.3 * fi + phase) + 20.0;
351
- newp.y += 0.6 / fi * cos(fi * p.x + t * 0.7 + 0.3 * float(i + 10) + phase) - 20.0 + 15.0;
352
- p = newp;
353
- }
354
-
355
- float v1 = 0.5 * sin(2.0 * p.x) + 0.5;
356
- float v2 = 0.5 * sin(2.0 * p.y) + 0.5;
357
- float blend = sin(p.x + p.y) * 0.5 + 0.5;
358
- float brightness = v1 * 0.5 + v2 * 0.5;
359
- float patternValue = brightness * 0.6 + blend * 0.4;
360
-
361
- return vec3(brightness, blend, patternValue);
362
- }
363
-
364
- void main() {
365
- float refScale = 1.92;
366
- vec2 uv = (gl_FragCoord.xy / resolution) * vec2(refScale, refScale * resolution.y / resolution.x);
367
252
 
368
- vec3 patA = computePattern(uv, seed, evolveProgress * Pi);
369
- float threshA = 1.0 - evolveProgress;
370
- float revealAlpha = smoothstep(threshA, threshA + 0.3, patA.z);
371
-
372
- vec2 maxUv = vec2(refScale, refScale * resolution.y / resolution.x);
373
- vec2 retractUv = maxUv - uv;
374
- vec3 patB = computePattern(retractUv, retractSeed, retractProgress * Pi);
375
- float threshB = 1.0 - retractProgress;
376
- float eraseAlpha = smoothstep(threshB, threshB + 0.3, patB.z);
377
-
378
- float alpha = revealAlpha * (1.0 - eraseAlpha);
379
-
380
- vec3 yellow = vec3(1.0, 0.85, 0.2);
381
- vec3 orange = vec3(1.0, 0.5, 0.05);
382
- vec3 col = mix(yellow, orange, patA.y);
383
- col *= 0.6 + 0.6 * patA.x;
384
-
385
- float angle = hueShift * Pi / 180.0;
386
- float cosA = cos(angle);
387
- float sinA = sin(angle);
388
- mat3 hueRot = mat3(
389
- cosA + (1.0 - cosA) / 3.0,
390
- (1.0 - cosA) / 3.0 - sinA * 0.57735,
391
- (1.0 - cosA) / 3.0 + sinA * 0.57735,
392
- (1.0 - cosA) / 3.0 + sinA * 0.57735,
393
- cosA + (1.0 - cosA) / 3.0,
394
- (1.0 - cosA) / 3.0 - sinA * 0.57735,
395
- (1.0 - cosA) / 3.0 - sinA * 0.57735,
396
- (1.0 - cosA) / 3.0 + sinA * 0.57735,
397
- cosA + (1.0 - cosA) / 3.0
398
- );
399
- col = clamp(hueRot * col, 0.0, 1.0);
400
-
401
- vec4 src = texture(uSource, vUv);
402
- vec4 leakPm = vec4(col * alpha, alpha);
403
- fragColor = leakPm + src * (1.0 - alpha);
404
- }
405
- `;
406
- var compileShader = (gl, type, source) => {
407
- const shader = gl.createShader(type);
408
- if (!shader) {
409
- throw new Error("Failed to create WebGL shader");
410
- }
411
- gl.shaderSource(shader, source);
412
- gl.compileShader(shader);
413
- if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
414
- const log = gl.getShaderInfoLog(shader);
415
- gl.deleteShader(shader);
416
- throw new Error(`Light leak shader compile failed: ${log ?? "(no log)"}`);
417
- }
418
- return shader;
419
- };
420
- var linkProgram = (gl, vs, fs) => {
421
- const program = gl.createProgram();
422
- if (!program) {
423
- throw new Error("Failed to create WebGL program");
424
- }
425
- gl.attachShader(program, vs);
426
- gl.attachShader(program, fs);
427
- gl.linkProgram(program);
428
- if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
429
- const log = gl.getProgramInfoLog(program);
430
- gl.deleteProgram(program);
431
- throw new Error(`Light leak program link failed: ${log ?? "(no log)"}`);
432
- }
433
- return program;
434
- };
435
- var lightLeak = createEffect({
436
- type: "dev.remotion.lightLeaks.lightLeak",
437
- label: "lightLeak()",
438
- documentationLink: "https://www.remotion.dev/docs/light-leaks/light-leak-effect",
439
- backend: "webgl2",
440
- calculateKey: (params) => {
441
- const r = resolve(params);
442
- return `light-leak-${r.seed}-${r.hueShift}-${r.progress}`;
443
- },
444
- setup: (target) => {
445
- const gl = target.getContext("webgl2", {
446
- premultipliedAlpha: true,
447
- alpha: true,
448
- preserveDrawingBuffer: true
449
- });
450
- if (!gl) {
451
- throw createWebGL2ContextError("light leak effect");
452
- }
453
- gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
454
- const vs = compileShader(gl, gl.VERTEX_SHADER, LIGHT_LEAK_VS);
455
- const fs = compileShader(gl, gl.FRAGMENT_SHADER, LIGHT_LEAK_FS);
456
- const program = linkProgram(gl, vs, fs);
457
- gl.deleteShader(vs);
458
- gl.deleteShader(fs);
459
- const vao = gl.createVertexArray();
460
- if (!vao) {
461
- throw new Error("Failed to create WebGL vertex array");
462
- }
463
- gl.bindVertexArray(vao);
464
- const data = new Float32Array([
465
- -1,
466
- -1,
467
- 0,
468
- 0,
469
- 1,
470
- -1,
471
- 1,
472
- 0,
473
- -1,
474
- 1,
475
- 0,
476
- 1,
477
- 1,
478
- 1,
479
- 1,
480
- 1
481
- ]);
482
- const vbo = gl.createBuffer();
483
- if (!vbo) {
484
- throw new Error("Failed to create WebGL buffer");
485
- }
486
- gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
487
- gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
488
- const aPos = gl.getAttribLocation(program, "aPos");
489
- const aUv = gl.getAttribLocation(program, "aUv");
490
- gl.enableVertexAttribArray(aPos);
491
- gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);
492
- gl.enableVertexAttribArray(aUv);
493
- gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);
494
- gl.bindVertexArray(null);
495
- const texture = gl.createTexture();
496
- if (!texture) {
497
- throw new Error("Failed to create WebGL texture");
498
- }
499
- gl.bindTexture(gl.TEXTURE_2D, texture);
500
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
501
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
502
- gl.bindTexture(gl.TEXTURE_2D, null);
503
- return {
504
- gl,
505
- program,
506
- vao,
507
- vbo,
508
- texture,
509
- uSource: gl.getUniformLocation(program, "uSource"),
510
- uEvolveProgress: gl.getUniformLocation(program, "evolveProgress"),
511
- uRetractProgress: gl.getUniformLocation(program, "retractProgress"),
512
- uSeed: gl.getUniformLocation(program, "seed"),
513
- uRetractSeed: gl.getUniformLocation(program, "retractSeed"),
514
- uHueShift: gl.getUniformLocation(program, "hueShift"),
515
- uResolution: gl.getUniformLocation(program, "resolution")
516
- };
517
- },
518
- apply: ({ source, width, height, params, state, flipSourceY }) => {
519
- const r = resolve(params);
520
- const evolveProgress = Math.min(1, r.progress * 2);
521
- const retractProgress = Math.max(0, r.progress * 2 - 1);
522
- const {
523
- gl,
524
- program,
525
- vao,
526
- texture,
527
- uSource,
528
- uEvolveProgress,
529
- uRetractProgress,
530
- uSeed,
531
- uRetractSeed,
532
- uHueShift,
533
- uResolution
534
- } = state;
535
- gl.viewport(0, 0, width, height);
536
- gl.clearColor(0, 0, 0, 0);
537
- gl.clear(gl.COLOR_BUFFER_BIT);
538
- gl.useProgram(program);
539
- gl.bindVertexArray(vao);
540
- gl.activeTexture(gl.TEXTURE0);
541
- gl.bindTexture(gl.TEXTURE_2D, texture);
542
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
543
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
544
- gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipSourceY);
545
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
546
- if (uSource)
547
- gl.uniform1i(uSource, 0);
548
- if (uEvolveProgress)
549
- gl.uniform1f(uEvolveProgress, evolveProgress);
550
- if (uRetractProgress)
551
- gl.uniform1f(uRetractProgress, retractProgress);
552
- if (uSeed)
553
- gl.uniform1f(uSeed, r.seed);
554
- if (uRetractSeed)
555
- gl.uniform1f(uRetractSeed, r.seed + 42);
556
- if (uHueShift)
557
- gl.uniform1f(uHueShift, r.hueShift);
558
- if (uResolution)
559
- gl.uniform2f(uResolution, width, height);
560
- gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
561
- gl.bindVertexArray(null);
562
- gl.bindTexture(gl.TEXTURE_2D, null);
563
- gl.useProgram(null);
564
- },
565
- cleanup: ({ gl, program, vao, vbo, texture }) => {
566
- gl.deleteBuffer(vbo);
567
- gl.deleteProgram(program);
568
- gl.deleteVertexArray(vao);
569
- gl.deleteTexture(texture);
570
- },
571
- schema: lightLeakEffectSchema,
572
- validateParams: validateLightLeakParams
573
- });
253
+ // src/index.ts
574
254
  var LightLeakInternals = {
575
255
  lightLeak
576
256
  };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,12 @@
1
1
  export { LightLeak } from './LightLeak';
2
2
  export type { LightLeakProps } from './LightLeak';
3
- export { LightLeakInternals, lightLeak, lightLeakEffectSchema, } from './light-leak-internals';
3
+ export { lightLeak, lightLeakEffectSchema } from './light-leak-internals';
4
4
  export type { LightLeakEffectParams } from './light-leak-internals';
5
+ /**
6
+ * Experimental internals for the light leak canvas effect pipeline.
7
+ */
8
+ export declare const LightLeakInternals: {
9
+ readonly lightLeak: (params?: (import("@remotion/effects/light-leak").LightLeakEffectParams & {
10
+ readonly disabled?: boolean | undefined;
11
+ }) | undefined) => import("remotion").EffectDescriptor<unknown>;
12
+ };
@@ -1,42 +1 @@
1
- export declare const lightLeakEffectSchema: {
2
- readonly seed: {
3
- readonly type: "number";
4
- readonly default: 0;
5
- readonly description: "Seed";
6
- readonly hiddenFromList: false;
7
- };
8
- readonly hueShift: {
9
- readonly type: "number";
10
- readonly min: 0;
11
- readonly max: 360;
12
- readonly default: 0;
13
- readonly description: "Hue Shift";
14
- readonly hiddenFromList: false;
15
- };
16
- readonly progress: {
17
- readonly type: "number";
18
- readonly min: 0;
19
- readonly max: 1;
20
- readonly step: 0.01;
21
- readonly default: 0.5;
22
- readonly description: "Progress";
23
- readonly hiddenFromList: false;
24
- };
25
- };
26
- export type LightLeakEffectParams = {
27
- readonly seed?: number;
28
- readonly hueShift?: number;
29
- /** Evolve/retract phase from 0 (start) to 1 (end). Defaults to 0.5. */
30
- readonly progress?: number;
31
- };
32
- export declare const lightLeak: (params?: (LightLeakEffectParams & {
33
- readonly disabled?: boolean | undefined;
34
- }) | undefined) => import("remotion").EffectDescriptor<unknown>;
35
- /**
36
- * Experimental internals for the light leak canvas effect pipeline.
37
- */
38
- export declare const LightLeakInternals: {
39
- readonly lightLeak: (params?: (LightLeakEffectParams & {
40
- readonly disabled?: boolean | undefined;
41
- }) | undefined) => import("remotion").EffectDescriptor<unknown>;
42
- };
1
+ export { lightLeak, lightLeakEffectSchema, type LightLeakEffectParams, } from '@remotion/effects/light-leak';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/light-leaks",
3
- "version": "4.0.498",
3
+ "version": "4.0.500",
4
4
  "description": "Light leak effects for Remotion",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,8 +24,9 @@
24
24
  "url": "https://github.com/remotion-dev/remotion/issues"
25
25
  },
26
26
  "dependencies": {
27
- "remotion": "4.0.498",
28
- "zod": "4.3.6"
27
+ "@remotion/effects": "4.0.500",
28
+ "remotion": "4.0.500",
29
+ "zod": "4.4.3"
29
30
  },
30
31
  "peerDependencies": {
31
32
  "react": ">=16.8.0",
@@ -42,7 +43,7 @@
42
43
  "devDependencies": {
43
44
  "react": "19.2.3",
44
45
  "react-dom": "19.2.3",
45
- "@remotion/eslint-config-internal": "4.0.498",
46
+ "@remotion/eslint-config-internal": "4.0.500",
46
47
  "eslint": "9.19.0",
47
48
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
48
49
  },