@remotion/light-leaks 4.0.461 → 4.0.462
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.mjs +297 -0
- package/dist/index.d.ts +2 -0
- package/dist/light-leak-internals.d.ts +37 -0
- package/package.json +3 -4
package/dist/esm/index.mjs
CHANGED
|
@@ -225,6 +225,303 @@ var LightLeakInner = ({
|
|
|
225
225
|
var LightLeak = Internals.wrapInSchema(LightLeakInner, lightLeakSchema);
|
|
226
226
|
LightLeak.displayName = "LightLeak";
|
|
227
227
|
Internals.addSequenceStackTraces(LightLeak);
|
|
228
|
+
// src/light-leak-internals.ts
|
|
229
|
+
import { Internals as Internals2 } from "remotion";
|
|
230
|
+
var { createEffect } = Internals2;
|
|
231
|
+
var lightLeakEffectSchema = {
|
|
232
|
+
seed: { type: "number", default: 0, description: "Seed" },
|
|
233
|
+
hueShift: {
|
|
234
|
+
type: "number",
|
|
235
|
+
min: 0,
|
|
236
|
+
max: 360,
|
|
237
|
+
default: 0,
|
|
238
|
+
description: "Hue Shift"
|
|
239
|
+
},
|
|
240
|
+
durationInFrames: {
|
|
241
|
+
type: "number",
|
|
242
|
+
min: 1,
|
|
243
|
+
max: 1e5,
|
|
244
|
+
step: 1,
|
|
245
|
+
default: 300,
|
|
246
|
+
description: "Duration in frames"
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
var resolve = (p) => ({
|
|
250
|
+
seed: p.seed ?? 0,
|
|
251
|
+
hueShift: p.hueShift ?? 0,
|
|
252
|
+
durationInFrames: p.durationInFrames ?? 300
|
|
253
|
+
});
|
|
254
|
+
var LIGHT_LEAK_VS = `#version 300 es
|
|
255
|
+
in vec2 aPos;
|
|
256
|
+
in vec2 aUv;
|
|
257
|
+
out vec2 vUv;
|
|
258
|
+
void main() {
|
|
259
|
+
vUv = aUv;
|
|
260
|
+
gl_Position = vec4(aPos, 0.0, 1.0);
|
|
261
|
+
}
|
|
262
|
+
`;
|
|
263
|
+
var LIGHT_LEAK_FS = `#version 300 es
|
|
264
|
+
precision highp float;
|
|
265
|
+
|
|
266
|
+
in vec2 vUv;
|
|
267
|
+
out vec4 fragColor;
|
|
268
|
+
|
|
269
|
+
uniform sampler2D uSource;
|
|
270
|
+
uniform float evolveProgress;
|
|
271
|
+
uniform float retractProgress;
|
|
272
|
+
uniform float seed;
|
|
273
|
+
uniform float retractSeed;
|
|
274
|
+
uniform float hueShift;
|
|
275
|
+
uniform vec2 resolution;
|
|
276
|
+
|
|
277
|
+
const float Pi = 3.14159;
|
|
278
|
+
|
|
279
|
+
vec3 computePattern(vec2 uv, float s, float t) {
|
|
280
|
+
vec2 p = uv * 0.8;
|
|
281
|
+
p += vec2(sin(s * 1.61803) * 5.0, cos(s * 2.71828) * 5.0);
|
|
282
|
+
|
|
283
|
+
for (int i = 1; i < 5; i++) {
|
|
284
|
+
vec2 newp = p;
|
|
285
|
+
float fi = float(i);
|
|
286
|
+
float phase = s * 0.7 * fi;
|
|
287
|
+
newp.x += 0.6 / fi * cos(fi * p.y + t * 0.7 + 0.3 * fi + phase) + 20.0;
|
|
288
|
+
newp.y += 0.6 / fi * cos(fi * p.x + t * 0.7 + 0.3 * float(i + 10) + phase) - 20.0 + 15.0;
|
|
289
|
+
p = newp;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
float v1 = 0.5 * sin(2.0 * p.x) + 0.5;
|
|
293
|
+
float v2 = 0.5 * sin(2.0 * p.y) + 0.5;
|
|
294
|
+
float blend = sin(p.x + p.y) * 0.5 + 0.5;
|
|
295
|
+
float brightness = v1 * 0.5 + v2 * 0.5;
|
|
296
|
+
float patternValue = brightness * 0.6 + blend * 0.4;
|
|
297
|
+
|
|
298
|
+
return vec3(brightness, blend, patternValue);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
void main() {
|
|
302
|
+
float refScale = 1.92;
|
|
303
|
+
vec2 uv = (gl_FragCoord.xy / resolution) * vec2(refScale, refScale * resolution.y / resolution.x);
|
|
304
|
+
|
|
305
|
+
vec3 patA = computePattern(uv, seed, evolveProgress * Pi);
|
|
306
|
+
float threshA = 1.0 - evolveProgress;
|
|
307
|
+
float revealAlpha = smoothstep(threshA, threshA + 0.3, patA.z);
|
|
308
|
+
|
|
309
|
+
vec2 maxUv = vec2(refScale, refScale * resolution.y / resolution.x);
|
|
310
|
+
vec2 retractUv = maxUv - uv;
|
|
311
|
+
vec3 patB = computePattern(retractUv, retractSeed, retractProgress * Pi);
|
|
312
|
+
float threshB = 1.0 - retractProgress;
|
|
313
|
+
float eraseAlpha = smoothstep(threshB, threshB + 0.3, patB.z);
|
|
314
|
+
|
|
315
|
+
float alpha = revealAlpha * (1.0 - eraseAlpha);
|
|
316
|
+
|
|
317
|
+
vec3 yellow = vec3(1.0, 0.85, 0.2);
|
|
318
|
+
vec3 orange = vec3(1.0, 0.5, 0.05);
|
|
319
|
+
vec3 col = mix(yellow, orange, patA.y);
|
|
320
|
+
col *= 0.6 + 0.6 * patA.x;
|
|
321
|
+
|
|
322
|
+
float angle = hueShift * Pi / 180.0;
|
|
323
|
+
float cosA = cos(angle);
|
|
324
|
+
float sinA = sin(angle);
|
|
325
|
+
mat3 hueRot = mat3(
|
|
326
|
+
cosA + (1.0 - cosA) / 3.0,
|
|
327
|
+
(1.0 - cosA) / 3.0 - sinA * 0.57735,
|
|
328
|
+
(1.0 - cosA) / 3.0 + sinA * 0.57735,
|
|
329
|
+
(1.0 - cosA) / 3.0 + sinA * 0.57735,
|
|
330
|
+
cosA + (1.0 - cosA) / 3.0,
|
|
331
|
+
(1.0 - cosA) / 3.0 - sinA * 0.57735,
|
|
332
|
+
(1.0 - cosA) / 3.0 - sinA * 0.57735,
|
|
333
|
+
(1.0 - cosA) / 3.0 + sinA * 0.57735,
|
|
334
|
+
cosA + (1.0 - cosA) / 3.0
|
|
335
|
+
);
|
|
336
|
+
col = clamp(hueRot * col, 0.0, 1.0);
|
|
337
|
+
|
|
338
|
+
vec4 src = texture(uSource, vUv);
|
|
339
|
+
vec4 leakPm = vec4(col * alpha, alpha);
|
|
340
|
+
fragColor = leakPm + src * (1.0 - alpha);
|
|
341
|
+
}
|
|
342
|
+
`;
|
|
343
|
+
var compileShader = (gl, type, source) => {
|
|
344
|
+
const shader = gl.createShader(type);
|
|
345
|
+
if (!shader) {
|
|
346
|
+
throw new Error("Failed to create WebGL shader");
|
|
347
|
+
}
|
|
348
|
+
gl.shaderSource(shader, source);
|
|
349
|
+
gl.compileShader(shader);
|
|
350
|
+
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
351
|
+
const log = gl.getShaderInfoLog(shader);
|
|
352
|
+
gl.deleteShader(shader);
|
|
353
|
+
throw new Error(`Light leak shader compile failed: ${log ?? "(no log)"}`);
|
|
354
|
+
}
|
|
355
|
+
return shader;
|
|
356
|
+
};
|
|
357
|
+
var linkProgram = (gl, vs, fs) => {
|
|
358
|
+
const program = gl.createProgram();
|
|
359
|
+
if (!program) {
|
|
360
|
+
throw new Error("Failed to create WebGL program");
|
|
361
|
+
}
|
|
362
|
+
gl.attachShader(program, vs);
|
|
363
|
+
gl.attachShader(program, fs);
|
|
364
|
+
gl.linkProgram(program);
|
|
365
|
+
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
366
|
+
const log = gl.getProgramInfoLog(program);
|
|
367
|
+
gl.deleteProgram(program);
|
|
368
|
+
throw new Error(`Light leak program link failed: ${log ?? "(no log)"}`);
|
|
369
|
+
}
|
|
370
|
+
return program;
|
|
371
|
+
};
|
|
372
|
+
var lightLeak = createEffect({
|
|
373
|
+
type: "remotion/light-leak",
|
|
374
|
+
label: "Light leak",
|
|
375
|
+
backend: "webgl2",
|
|
376
|
+
calculateKey: (params) => {
|
|
377
|
+
const r = resolve(params);
|
|
378
|
+
return `light-leak-${r.seed}-${r.hueShift}-${r.durationInFrames}`;
|
|
379
|
+
},
|
|
380
|
+
setup: (target) => {
|
|
381
|
+
const gl = target.getContext("webgl2", {
|
|
382
|
+
premultipliedAlpha: true,
|
|
383
|
+
alpha: true,
|
|
384
|
+
preserveDrawingBuffer: true
|
|
385
|
+
});
|
|
386
|
+
if (!gl) {
|
|
387
|
+
throw new Error("Failed to acquire WebGL2 context for light leak effect");
|
|
388
|
+
}
|
|
389
|
+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
|
|
390
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
|
|
391
|
+
const vs = compileShader(gl, gl.VERTEX_SHADER, LIGHT_LEAK_VS);
|
|
392
|
+
const fs = compileShader(gl, gl.FRAGMENT_SHADER, LIGHT_LEAK_FS);
|
|
393
|
+
const program = linkProgram(gl, vs, fs);
|
|
394
|
+
gl.deleteShader(vs);
|
|
395
|
+
gl.deleteShader(fs);
|
|
396
|
+
const vao = gl.createVertexArray();
|
|
397
|
+
if (!vao) {
|
|
398
|
+
throw new Error("Failed to create WebGL vertex array");
|
|
399
|
+
}
|
|
400
|
+
gl.bindVertexArray(vao);
|
|
401
|
+
const data = new Float32Array([
|
|
402
|
+
-1,
|
|
403
|
+
-1,
|
|
404
|
+
0,
|
|
405
|
+
0,
|
|
406
|
+
1,
|
|
407
|
+
-1,
|
|
408
|
+
1,
|
|
409
|
+
0,
|
|
410
|
+
-1,
|
|
411
|
+
1,
|
|
412
|
+
0,
|
|
413
|
+
1,
|
|
414
|
+
1,
|
|
415
|
+
1,
|
|
416
|
+
1,
|
|
417
|
+
1
|
|
418
|
+
]);
|
|
419
|
+
const vbo = gl.createBuffer();
|
|
420
|
+
if (!vbo) {
|
|
421
|
+
throw new Error("Failed to create WebGL buffer");
|
|
422
|
+
}
|
|
423
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
|
|
424
|
+
gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
|
|
425
|
+
const aPos = gl.getAttribLocation(program, "aPos");
|
|
426
|
+
const aUv = gl.getAttribLocation(program, "aUv");
|
|
427
|
+
gl.enableVertexAttribArray(aPos);
|
|
428
|
+
gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);
|
|
429
|
+
gl.enableVertexAttribArray(aUv);
|
|
430
|
+
gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);
|
|
431
|
+
gl.bindVertexArray(null);
|
|
432
|
+
const texture = gl.createTexture();
|
|
433
|
+
if (!texture) {
|
|
434
|
+
throw new Error("Failed to create WebGL texture");
|
|
435
|
+
}
|
|
436
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
437
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
438
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
439
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
440
|
+
return {
|
|
441
|
+
gl,
|
|
442
|
+
program,
|
|
443
|
+
vao,
|
|
444
|
+
vbo,
|
|
445
|
+
texture,
|
|
446
|
+
uSource: gl.getUniformLocation(program, "uSource"),
|
|
447
|
+
uEvolveProgress: gl.getUniformLocation(program, "evolveProgress"),
|
|
448
|
+
uRetractProgress: gl.getUniformLocation(program, "retractProgress"),
|
|
449
|
+
uSeed: gl.getUniformLocation(program, "seed"),
|
|
450
|
+
uRetractSeed: gl.getUniformLocation(program, "retractSeed"),
|
|
451
|
+
uHueShift: gl.getUniformLocation(program, "hueShift"),
|
|
452
|
+
uResolution: gl.getUniformLocation(program, "resolution")
|
|
453
|
+
};
|
|
454
|
+
},
|
|
455
|
+
apply: ({ source, width, height, params, state, frame }) => {
|
|
456
|
+
const r = resolve(params);
|
|
457
|
+
if (typeof r.seed !== "number" || !Number.isFinite(r.seed)) {
|
|
458
|
+
throw new TypeError(`"seed" must be a finite number, but got ${JSON.stringify(r.seed)}`);
|
|
459
|
+
}
|
|
460
|
+
if (typeof r.hueShift !== "number" || !Number.isFinite(r.hueShift)) {
|
|
461
|
+
throw new TypeError(`"hueShift" must be a finite number, but got ${JSON.stringify(r.hueShift)}`);
|
|
462
|
+
}
|
|
463
|
+
if (r.hueShift < 0 || r.hueShift > 360) {
|
|
464
|
+
throw new RangeError(`"hueShift" must be between 0 and 360, but got ${r.hueShift}`);
|
|
465
|
+
}
|
|
466
|
+
const duration = r.durationInFrames;
|
|
467
|
+
const normalized = duration <= 1 ? 0 : frame / (duration - 1);
|
|
468
|
+
const evolveProgress = Math.min(1, normalized * 2);
|
|
469
|
+
const retractProgress = Math.max(0, normalized * 2 - 1);
|
|
470
|
+
const {
|
|
471
|
+
gl,
|
|
472
|
+
program,
|
|
473
|
+
vao,
|
|
474
|
+
texture,
|
|
475
|
+
uSource,
|
|
476
|
+
uEvolveProgress,
|
|
477
|
+
uRetractProgress,
|
|
478
|
+
uSeed,
|
|
479
|
+
uRetractSeed,
|
|
480
|
+
uHueShift,
|
|
481
|
+
uResolution
|
|
482
|
+
} = state;
|
|
483
|
+
gl.viewport(0, 0, width, height);
|
|
484
|
+
gl.clearColor(0, 0, 0, 0);
|
|
485
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
486
|
+
gl.useProgram(program);
|
|
487
|
+
gl.bindVertexArray(vao);
|
|
488
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
489
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
490
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
491
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
492
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
|
|
493
|
+
if (uSource)
|
|
494
|
+
gl.uniform1i(uSource, 0);
|
|
495
|
+
if (uEvolveProgress)
|
|
496
|
+
gl.uniform1f(uEvolveProgress, evolveProgress);
|
|
497
|
+
if (uRetractProgress)
|
|
498
|
+
gl.uniform1f(uRetractProgress, retractProgress);
|
|
499
|
+
if (uSeed)
|
|
500
|
+
gl.uniform1f(uSeed, r.seed);
|
|
501
|
+
if (uRetractSeed)
|
|
502
|
+
gl.uniform1f(uRetractSeed, r.seed + 42);
|
|
503
|
+
if (uHueShift)
|
|
504
|
+
gl.uniform1f(uHueShift, r.hueShift);
|
|
505
|
+
if (uResolution)
|
|
506
|
+
gl.uniform2f(uResolution, width, height);
|
|
507
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
508
|
+
gl.bindVertexArray(null);
|
|
509
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
510
|
+
gl.useProgram(null);
|
|
511
|
+
},
|
|
512
|
+
cleanup: ({ gl, program, vao, vbo, texture }) => {
|
|
513
|
+
gl.deleteBuffer(vbo);
|
|
514
|
+
gl.deleteProgram(program);
|
|
515
|
+
gl.deleteVertexArray(vao);
|
|
516
|
+
gl.deleteTexture(texture);
|
|
517
|
+
},
|
|
518
|
+
schema: lightLeakEffectSchema
|
|
519
|
+
});
|
|
520
|
+
var LightLeakInternals = {
|
|
521
|
+
lightLeak
|
|
522
|
+
};
|
|
228
523
|
export {
|
|
524
|
+
lightLeakEffectSchema,
|
|
525
|
+
LightLeakInternals,
|
|
229
526
|
LightLeak
|
|
230
527
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const lightLeakEffectSchema: {
|
|
2
|
+
readonly seed: {
|
|
3
|
+
readonly type: "number";
|
|
4
|
+
readonly default: 0;
|
|
5
|
+
readonly description: "Seed";
|
|
6
|
+
};
|
|
7
|
+
readonly hueShift: {
|
|
8
|
+
readonly type: "number";
|
|
9
|
+
readonly min: 0;
|
|
10
|
+
readonly max: 360;
|
|
11
|
+
readonly default: 0;
|
|
12
|
+
readonly description: "Hue Shift";
|
|
13
|
+
};
|
|
14
|
+
readonly durationInFrames: {
|
|
15
|
+
readonly type: "number";
|
|
16
|
+
readonly min: 1;
|
|
17
|
+
readonly max: 100000;
|
|
18
|
+
readonly step: 1;
|
|
19
|
+
readonly default: 300;
|
|
20
|
+
readonly description: "Duration in frames";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export type LightLeakEffectParams = {
|
|
24
|
+
readonly seed?: number;
|
|
25
|
+
readonly hueShift?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Controls evolve/retract timing, matching `<LightLeak>` when set to the same
|
|
28
|
+
* duration as your composition or sequence.
|
|
29
|
+
*/
|
|
30
|
+
readonly durationInFrames?: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Experimental internals for the light leak canvas effect pipeline.
|
|
34
|
+
*/
|
|
35
|
+
export declare const LightLeakInternals: {
|
|
36
|
+
readonly lightLeak: (params?: LightLeakEffectParams | undefined) => import("remotion").EffectDescriptor<unknown>;
|
|
37
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/light-leaks",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.462",
|
|
4
4
|
"description": "Light leak effects for Remotion",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"repository": {
|
|
9
9
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/light-leaks"
|
|
10
10
|
},
|
|
11
|
-
"sideEffects": false,
|
|
12
11
|
"type": "module",
|
|
13
12
|
"scripts": {
|
|
14
13
|
"formatting": "oxfmt src --check",
|
|
@@ -24,7 +23,7 @@
|
|
|
24
23
|
"url": "https://github.com/remotion-dev/remotion/issues"
|
|
25
24
|
},
|
|
26
25
|
"dependencies": {
|
|
27
|
-
"remotion": "4.0.
|
|
26
|
+
"remotion": "4.0.462",
|
|
28
27
|
"zod": "4.3.6"
|
|
29
28
|
},
|
|
30
29
|
"peerDependencies": {
|
|
@@ -42,7 +41,7 @@
|
|
|
42
41
|
"devDependencies": {
|
|
43
42
|
"react": "19.2.3",
|
|
44
43
|
"react-dom": "19.2.3",
|
|
45
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
44
|
+
"@remotion/eslint-config-internal": "4.0.462",
|
|
46
45
|
"eslint": "9.19.0",
|
|
47
46
|
"@typescript/native-preview": "7.0.0-dev.20260217.1"
|
|
48
47
|
},
|