π₯ Make videos programmatically with React
`@remotion/effects`: Migrate light leak effect (#9712)
Jonny Burger1d52fdf9d715
diff --git a/bun.lock b/bun.lockindex 36a91df44e..9c69942d32 100644--- a/bun.lock+++ b/bun.lock@@ -1087,6 +1087,7 @@"name": "@remotion/light-leaks","version": "4.0.499","dependencies": {+ "@remotion/effects": "workspace:*","remotion": "workspace:*","zod": "catalog:",},diff --git a/packages/docs/components/demos/LightLeakDemo.tsx b/packages/docs/components/demos/LightLeakDemo.tsxindex 9ac1c37a34..fda5e33fab 100644--- a/packages/docs/components/demos/LightLeakDemo.tsx+++ b/packages/docs/components/demos/LightLeakDemo.tsx@@ -1,6 +1,12 @@-import {LightLeak} from '@remotion/light-leaks';+import {lightLeak} from '@remotion/effects/light-leak';import React from 'react';-import {AbsoluteFill, useVideoConfig} from 'remotion';+import {+ AbsoluteFill,+ interpolate,+ Solid,+ useCurrentFrame,+ useVideoConfig,+} from 'remotion';interface Props {readonly seed: number;@@ -8,13 +14,24 @@ interface Props {}export const LightLeakDemoComp: React.FC<Props> = ({seed, hueShift}) => {- const {durationInFrames} = useVideoConfig();+ const frame = useCurrentFrame();+ const {durationInFrames, height, width} = useVideoConfig();+return (<AbsoluteFill style={{backgroundColor: 'black'}}>- <LightLeak- seed={seed}- hueShift={hueShift}- durationInFrames={durationInFrames}+ <Solid+ width={width}+ height={height}+ effects={[+ lightLeak({+ seed,+ hueShift,+ progress: interpolate(frame, [0, durationInFrames - 1], [0, 1], {+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ }),+ }),+ ]}/></AbsoluteFill>);diff --git a/packages/docs/components/effects-demos/registry.ts b/packages/docs/components/effects-demos/registry.tsindex d4c87ca40b..11f0191f77 100644--- a/packages/docs/components/effects-demos/registry.ts+++ b/packages/docs/components/effects-demos/registry.ts@@ -22,6 +22,7 @@ import {halftone} from '@remotion/effects/halftone';import {halftoneLinearGradient} from '@remotion/effects/halftone-linear-gradient';import {hue} from '@remotion/effects/hue';import {invert} from '@remotion/effects/invert';+import {lightLeak} from '@remotion/effects/light-leak';import {lightTrail} from '@remotion/effects/light-trail';import {linearGradient} from '@remotion/effects/linear-gradient';import {linearGradientTint} from '@remotion/effects/linear-gradient-tint';@@ -59,7 +60,6 @@ import {waves} from '@remotion/effects/waves';import {whiteNoise} from '@remotion/effects/white-noise';import {zigzag} from '@remotion/effects/zigzag';import {zoomBlur} from '@remotion/effects/zoom-blur';-import {lightLeakEffectSchema} from '@remotion/light-leaks';import {EffectsBarrelDistortionPreview} from '../effects/effects-barrel-distortion-preview';import {EffectsBlurPreview} from '../effects/effects-blur-preview';import {EffectsBrightnessPreview} from '../effects/effects-brightness-preview';@@ -698,8 +698,8 @@ export const effectsDemos: EffectsDemoType[] = [...defaults,id: 'effects-light-leak',effectName: 'lightLeak',- effectImportPath: '@remotion/light-leaks',+ effectImportPath: '@remotion/effects/light-leak',comp: EffectsLightLeakPreview,- schema: lightLeakEffectSchema,+ schema: lightLeak().definition.schema,},];diff --git a/packages/docs/components/effects/effects-light-leak-preview.tsx b/packages/docs/components/effects/effects-light-leak-preview.tsxindex 888ef0752d..4eb70cb32c 100644--- a/packages/docs/components/effects/effects-light-leak-preview.tsx+++ b/packages/docs/components/effects/effects-light-leak-preview.tsx@@ -1,4 +1,4 @@-import {lightLeak} from '@remotion/light-leaks';+import {lightLeak} from '@remotion/effects/light-leak';import React from 'react';import {Solid, useVideoConfig} from 'remotion';diff --git a/packages/docs/docs/effects/light-leak.mdx b/packages/docs/docs/effects/light-leak.mdxnew file mode 100644index 0000000000..2d208a5dbe--- /dev/null+++ b/packages/docs/docs/effects/light-leak.mdx@@ -0,0 +1,82 @@+---+image: /generated/articles-docs-effects-light-leak.png+slug: /effects/light-leak+title: lightLeak()+sidebar_label: lightLeak()+crumb: '@remotion/effects'+---++# lightLeak()<AvailableFrom v="4.0.500" />++_Part of the [`@remotion/effects`](/docs/effects/api) package._++Applies a WebGL2-based light leak overlay to canvas-based components such as [`<Video>`](/docs/media/video), [`<CanvasImage>`](/docs/canvasimage) and [`<Solid>`](/docs/solid).++The light leak reveals during the first half of its progress and retracts during the second half.++## Preview++<EffectsDemo type="effects-light-leak" />++## Example++```tsx twoslash title="MyComp.tsx"+import {lightLeak} from '@remotion/effects/light-leak';+import {CanvasImage, interpolate, staticFile, useCurrentFrame} from 'remotion';++export const MyComp: React.FC = () => {+ const frame = useCurrentFrame();++ return (+ <CanvasImage+ src={staticFile('image.png')}+ width={1280}+ height={720}+ fit="cover"+ effects={[+ lightLeak({+ seed: 3,+ hueShift: 30,+ progress: interpolate(frame, [0, 30], [0, 1], {+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ }),+ }),+ ]}+ />+ );+};+```++## API++Pass an object with the following properties. You can also call `lightLeak()` without arguments.++### `seed?`++Determines the shape of the light leak pattern. Different seeds produce different patterns. Defaults to `0`.++### `hueShift?`++Rotates the hue of the light leak from `0` to `360` degrees. Defaults to `0` for a yellow-to-orange light leak.++### `progress?`++Controls the evolve/retract phase from `0` to `1`.++Effects do not animate on their own. Drive `progress` with [`useCurrentFrame()`](/docs/use-current-frame), [`interpolate()`](/docs/interpolate), or input props. Defaults to `0.5` so the light leak is visible when the effect is first added.++### `disabled?`++When `true`, the effect is skipped. Defaults to `false`.++## Requirements++`lightLeak()` uses a WebGL2 backend. During renders, enable WebGL via [`Config.setChromiumOpenGlRenderer('angle')`](/docs/config#setchromiumopenglrenderer). See [Using WebGL during renders](/docs/remotion/html-in-canvas#using-webgl-during-renders).++## See also++- [Designing light leaks](/docs/light-leaks)+- [`<LightLeak>` from `@remotion/light-leaks`](/docs/light-leaks/light-leak)+- [`@remotion/effects`](/docs/effects/api)+- [Source code for this effect](https://github.com/remotion-dev/remotion/blob/main/packages/effects/src/light-leak.ts)diff --git a/packages/docs/docs/light-leaks-guide.mdx b/packages/docs/docs/light-leaks-guide.mdxindex f4f443c319..98d840d6f3 100644--- a/packages/docs/docs/light-leaks-guide.mdx+++ b/packages/docs/docs/light-leaks-guide.mdx@@ -2,92 +2,137 @@image: /generated/articles-docs-light-leaks-guide.pngid: light-leakstitle: Light Leaks-crumb: 'Techniques'+crumb: 'Designing visuals'----# Light Leaks<AvailableFrom v="4.0.415"/>+# Light Leaks<AvailableFrom v="4.0.500"/>-The [`<LightLeak>`](/docs/light-leaks/light-leak) component from [`@remotion/light-leaks`](/docs/light-leaks/api) renders a WebGL-based light leak effect. The effect reveals during the first half of its duration and retracts during the second half.--Use [`lightLeak()`](/docs/light-leaks/light-leak-effect) from [`@remotion/light-leaks`](/docs/light-leaks/api) to apply the same visual to canvas-based components with an `effects` array.+The [`lightLeak()`](/docs/effects/light-leak) effect from [`@remotion/effects`](/docs/effects/api) renders an animated WebGL2-based light leak overlay. The light leak reveals during the first half of its progress and retracts during the second half.<Demo type="light-leak" />+Apply the effect to a canvas-based component and animate `progress` with [`useCurrentFrame()`](/docs/use-current-frame):+```tsx twoslash title="MyComp.tsx"-import {LightLeak} from '@remotion/light-leaks';-import {AbsoluteFill} from 'remotion';+import {lightLeak} from '@remotion/effects/light-leak';+import {+ AbsoluteFill,+ interpolate,+ Solid,+ useCurrentFrame,+ useVideoConfig,+} from 'remotion';++export const MyComp: React.FC = () => {+ const frame = useCurrentFrame();+ const {durationInFrames, height, width} = useVideoConfig();-const MyComp = () => {return (<AbsoluteFill style={{backgroundColor: 'black'}}>- <LightLeak durationInFrames={60} seed={3} hueShift={30} />+ <Solid+ width={width}+ height={height}+ effects={[+ lightLeak({+ seed: 3,+ hueShift: 30,+ progress: interpolate(+ frame,+ [0, durationInFrames - 1],+ [0, 1],+ {+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ },+ ),+ }),+ ]}+ /></AbsoluteFill>);};```+Keeping the progress calculation inline makes the animation editable in [Remotion Studio](/docs/studio/interactivity-best-practices#effects-should-be-inline-too).+## Changing the seed-The [`seed`](/docs/light-leaks/light-leak#seed) prop controls the shape of the light leak pattern. Different values produce different patterns.+The [`seed`](/docs/effects/light-leak#seed) option controls the shape of the light leak pattern. Different values produce different patterns.```tsx twoslash title="DifferentSeed.tsx"-import {LightLeak} from '@remotion/light-leaks';-import {AbsoluteFill} from 'remotion';+import {lightLeak} from '@remotion/effects/light-leak';-// ---cut----const MyComp = () => {- return (- <AbsoluteFill style={{backgroundColor: 'black'}}>- <LightLeak seed={5} durationInFrames={30} />- </AbsoluteFill>- );-};+const effect = lightLeak({seed: 5});```## Changing the color-Use [`hueShift`](/docs/light-leaks/light-leak#hueshift) to rotate the color of the light leak in degrees (`0`β`360`):+Use [`hueShift`](/docs/effects/light-leak#hueshift) to rotate the color of the light leak from `0` to `360` degrees:- `0` (default) β yellow-to-orange- `120` β shifts toward green- `240` β shifts toward blue```tsx twoslash title="BlueHue.tsx"-import {LightLeak} from '@remotion/light-leaks';-import {AbsoluteFill} from 'remotion';+import {lightLeak} from '@remotion/effects/light-leak';-// ---cut----const MyComp = () => {- return (- <AbsoluteFill style={{backgroundColor: 'black'}}>- <LightLeak hueShift={240} durationInFrames={30} />- </AbsoluteFill>- );-};+const effect = lightLeak({hueShift: 240});```## Using as a transitionCombined with [`<TransitionSeries.Overlay>`](/docs/transitions/transitionseries#transitionseriesoverlay), you can place a light leak at the cut point between two sequences without shortening the timeline.-<Demo type="transition-series-overlay" />+Create an overlay component that animates the effect across its duration:```tsx twoslash title="LightLeakTransition.tsx"-import {AbsoluteFill} from 'remotion';-const Fill = ({color}: {color: string}) => <AbsoluteFill style={{backgroundColor: color}} />;--// ---cut----import {LightLeak} from '@remotion/light-leaks';+import {lightLeak} from '@remotion/effects/light-leak';import {TransitionSeries} from '@remotion/transitions';+import {+ AbsoluteFill,+ interpolate,+ Solid,+ useCurrentFrame,+ useVideoConfig,+} from 'remotion';++const Fill = ({color}: {color: string}) => (+ <AbsoluteFill style={{backgroundColor: color}} />+);++const LightLeakOverlay: React.FC = () => {+ const frame = useCurrentFrame();+ const {durationInFrames, height, width} = useVideoConfig();++ return (+ <Solid+ width={width}+ height={height}+ effects={[+ lightLeak({+ progress: interpolate(+ frame,+ [0, durationInFrames - 1],+ [0, 1],+ {+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ },+ ),+ }),+ ]}+ />+ );+};-const LightLeakTransition = () => {+export const LightLeakTransition: React.FC = () => {return (<TransitionSeries><TransitionSeries.Sequence durationInFrames={60}><Fill color="#0b84f3" /></TransitionSeries.Sequence><TransitionSeries.Overlay durationInFrames={20}>- <LightLeak />+ <LightLeakOverlay /></TransitionSeries.Overlay><TransitionSeries.Sequence durationInFrames={60}><Fill color="pink" />@@ -101,8 +146,7 @@ At the midpoint, the light leak covers most of the canvas, hiding the cut betwee## See also-- [`<LightLeak>` API reference](/docs/light-leaks/light-leak)-- [`lightLeak()` effect](/docs/light-leaks/light-leak-effect)-- [`@remotion/light-leaks`](/docs/light-leaks/api)+- [`lightLeak()` API reference](/docs/effects/light-leak)+- [`@remotion/effects`](/docs/effects/api)- [`<TransitionSeries.Overlay>`](/docs/transitions/transitionseries#transitionseriesoverlay)- [Transitions](/docs/transitioning)diff --git a/packages/docs/docs/light-leaks/index.mdx b/packages/docs/docs/light-leaks/index.mdxindex 274dbdbeb7..ca49f324f1 100644--- a/packages/docs/docs/light-leaks/index.mdx+++ b/packages/docs/docs/light-leaks/index.mdx@@ -7,6 +7,10 @@ title: '@remotion/light-leaks'# @remotion/light-leaks<AvailableFrom v="4.0.415" />+:::warning Deprecated+`@remotion/light-leaks` is deprecated and will no longer be published starting with Remotion 5.0. Migrate to [`lightLeak()`](/docs/effects/light-leak) from `@remotion/effects/light-leak`. The `<LightLeak>` component will not be moved to `@remotion/effects`.+:::+Light leak effects for Remotion videos.import {TableOfContents} from './table-of-contents';diff --git a/packages/docs/docs/light-leaks/light-leak-effect.mdx b/packages/docs/docs/light-leaks/light-leak-effect.mdxindex d47749f8c7..09b0470300 100644--- a/packages/docs/docs/light-leaks/light-leak-effect.mdx+++ b/packages/docs/docs/light-leaks/light-leak-effect.mdx@@ -8,6 +8,10 @@ crumb: '@remotion/light-leaks'# lightLeak()<AvailableFrom v="4.0.468" />+:::warning Deprecated+`@remotion/light-leaks` is deprecated and will no longer be published starting with Remotion 5.0. Migrate to [`lightLeak()`](/docs/effects/light-leak) from `@remotion/effects/light-leak`.+:::+_Part of the [`@remotion/light-leaks`](/docs/light-leaks/api) package._Applies a WebGL2-based light leak effect to canvas-based components such as [`<Video>`](/docs/media/video), [`<CanvasImage>`](/docs/canvasimage) and [`<Solid>`](/docs/solid).@@ -82,6 +86,7 @@ When `true`, the effect is skipped. Defaults to `false`.## See also- [`@remotion/light-leaks`](/docs/light-leaks/api)+- [`lightLeak()` from `@remotion/effects`](/docs/effects/light-leak)- [`<LightLeak>`](/docs/light-leaks/light-leak)- [`@remotion/effects`](/docs/effects/api)- [Source code for this effect](https://github.com/remotion-dev/remotion/blob/main/packages/effects/src/light-leak.ts)diff --git a/packages/docs/docs/light-leaks/light-leak.mdx b/packages/docs/docs/light-leaks/light-leak.mdxindex cec18b53a8..b818198a89 100644--- a/packages/docs/docs/light-leaks/light-leak.mdx+++ b/packages/docs/docs/light-leaks/light-leak.mdx@@ -6,11 +6,15 @@ crumb: '@remotion/light-leaks'# <LightLeak><AvailableFrom v="4.0.415" />+:::warning Deprecated+`@remotion/light-leaks` is deprecated and will no longer be published starting with Remotion 5.0. Migrate to [`lightLeak()`](/docs/effects/light-leak) from `@remotion/effects/light-leak`. The `<LightLeak>` component will not be moved to `@remotion/effects`.+:::+Renders a WebGL-based light leak effect.The effect reveals during the first half of the duration and retracts during the second half.Is a [`<Sequence>`](/docs/sequence) component under the hood and accepts it's props.-Use [`lightLeak()`](/docs/light-leaks/light-leak-effect) to apply the same visual as a canvas effect.+Use [`lightLeak()` from `@remotion/effects`](/docs/effects/light-leak) to apply the same visual as a canvas effect.## Example@@ -58,6 +62,6 @@ Rotates the hue of the light leak in degrees (`0`-`360`).## See also-- [`lightLeak()`](/docs/light-leaks/light-leak-effect)+- [`lightLeak()` from `@remotion/effects`](/docs/effects/light-leak)- [Source code for this component](https://github.com/remotion-dev/remotion/blob/main/packages/light-leaks/src/LightLeak.tsx)- [`<Sequence>`](/docs/sequence)diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.tsindex c1d035008c..1a24994202 100644--- a/packages/docs/sidebars.ts+++ b/packages/docs/sidebars.ts@@ -301,6 +301,7 @@ const sidebars: SidebarsConfig = {'effects/linear-gradient-tint','effects/linear-progressive-blur','effects/linear-progressive-pixelate',+ 'effects/light-leak','effects/light-trail','effects/lines','effects/liquid-contours',diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.tsindex a917ba099a..50b760bdbe 100644--- a/packages/docs/src/data/articles.ts+++ b/packages/docs/src/data/articles.ts@@ -1997,6 +1997,15 @@ export const articles = [noAi: false,slug: 'effects/invert',},+ {+ id: 'effects/light-leak',+ title: 'lightLeak()',+ relativePath: 'docs/effects/light-leak.mdx',+ compId: 'articles-docs-effects-light-leak',+ crumb: '@remotion/effects',+ noAi: false,+ slug: 'effects/light-leak',+ },{id: 'effects/light-trail',title: 'lightTrail()',@@ -3964,7 +3973,7 @@ export const articles = [title: 'Light Leaks',relativePath: 'docs/light-leaks-guide.mdx',compId: 'articles-docs-light-leaks-guide',- crumb: 'Techniques',+ crumb: 'Designing visuals',noAi: false,slug: 'light-leaks',},diff --git a/packages/docs/static/generated/articles-docs-effects-light-leak.png b/packages/docs/static/generated/articles-docs-effects-light-leak.pngnew file mode 100644index 0000000000..f17bea47c6Binary files /dev/null and b/packages/docs/static/generated/articles-docs-effects-light-leak.png differdiff --git a/packages/effects/bundle.ts b/packages/effects/bundle.tsindex abbb379a70..4c0f1060da 100644--- a/packages/effects/bundle.ts+++ b/packages/effects/bundle.ts@@ -39,6 +39,7 @@ const effectEntrypoints = ['src/linear-gradient-tint.ts','src/linear-progressive-blur.ts','src/linear-progressive-pixelate.ts',+ 'src/light-leak.ts','src/light-trail.ts','src/mirror.ts','src/noise.ts',diff --git a/packages/effects/package.json b/packages/effects/package.jsonindex 28d5693e13..6c1dd94154 100644--- a/packages/effects/package.json+++ b/packages/effects/package.json@@ -189,6 +189,11 @@"module": "./dist/esm/linear-progressive-pixelate.mjs","import": "./dist/esm/linear-progressive-pixelate.mjs"},+ "./light-leak": {+ "types": "./dist/light-leak.d.ts",+ "module": "./dist/esm/light-leak.mjs",+ "import": "./dist/esm/light-leak.mjs"+ },"./light-trail": {"types": "./dist/light-trail.d.ts","module": "./dist/esm/light-trail.mjs",@@ -436,6 +441,9 @@"linear-progressive-pixelate": ["dist/linear-progressive-pixelate.d.ts"],+ "light-leak": [+ "dist/light-leak.d.ts"+ ],"light-trail": ["dist/light-trail.d.ts"],diff --git a/packages/effects/src/index.ts b/packages/effects/src/index.tsindex e6d96d8a6b..439e630afd 100644--- a/packages/effects/src/index.ts+++ b/packages/effects/src/index.ts@@ -7,6 +7,11 @@ export {type StarburstEffectParams,type StarburstOrigin,} from './starburst.js';+export {+ lightLeak,+ lightLeakEffectSchema,+ type LightLeakEffectParams,+} from './light-leak.js';export {gridlines, type GridlinesParams} from './gridlines.js';export {zigzag, type ZigzagDirection, type ZigzagParams} from './zigzag.js';export {diff --git a/packages/effects/src/light-leak.ts b/packages/effects/src/light-leak.tsnew file mode 100644index 0000000000..0e065a3f31--- /dev/null+++ b/packages/effects/src/light-leak.ts@@ -0,0 +1,369 @@+import type {InteractivitySchema} from 'remotion';+import {Internals} from 'remotion';+import {+ assertOptionalFiniteNumber,+ validateUnitInterval,+} from './color-utils.js';+import {assertEffectParamsObject} from './validate-effect-param.js';++const {createEffect, createWebGL2ContextError} = Internals;++const DEFAULT_SEED = 0 as const;+const DEFAULT_HUE_SHIFT = 0 as const;+const DEFAULT_PROGRESS = 0.5 as const;++export const lightLeakEffectSchema = {+ seed: {+ type: 'number',+ default: DEFAULT_SEED,+ description: 'Seed',+ hiddenFromList: false,+ },+ hueShift: {+ type: 'number',+ min: 0,+ max: 360,+ default: DEFAULT_HUE_SHIFT,+ description: 'Hue Shift',+ hiddenFromList: false,+ },+ progress: {+ type: 'number',+ min: 0,+ max: 1,+ step: 0.01,+ default: DEFAULT_PROGRESS,+ description: 'Progress',+ hiddenFromList: false,+ },+} as const satisfies InteractivitySchema;++export type LightLeakEffectParams = {+ readonly seed?: number;+ readonly hueShift?: number;+ /** Evolve/retract phase from 0 (start) to 1 (end). Defaults to 0.5. */+ readonly progress?: number;+};++type LightLeakResolved = {+ seed: number;+ hueShift: number;+ progress: number;+};++const resolve = (p: LightLeakEffectParams): LightLeakResolved => ({+ seed: p.seed ?? DEFAULT_SEED,+ hueShift: p.hueShift ?? DEFAULT_HUE_SHIFT,+ progress: p.progress ?? DEFAULT_PROGRESS,+});++const validateLightLeakParams = (params: LightLeakEffectParams): void => {+ assertEffectParamsObject(params, 'lightLeak()');+ assertOptionalFiniteNumber(params.seed, 'seed');+ assertOptionalFiniteNumber(params.hueShift, 'hueShift');+ assertOptionalFiniteNumber(params.progress, 'progress');++ const {hueShift, progress} = resolve(params);+ if (hueShift < 0) {+ throw new TypeError(`"hueShift" must be >= 0, but got ${hueShift}`);+ }++ if (hueShift > 360) {+ throw new TypeError(`"hueShift" must be <= 360, but got ${hueShift}`);+ }++ validateUnitInterval(progress, 'progress');+};++const LIGHT_LEAK_VS = /* glsl */ `#version 300 es+in vec2 aPos;+in vec2 aUv;+out vec2 vUv;+void main() {+ vUv = aUv;+ gl_Position = vec4(aPos, 0.0, 1.0);+}+`;++const LIGHT_LEAK_FS = /* glsl */ `#version 300 es+precision highp float;++in vec2 vUv;+out vec4 fragColor;++uniform sampler2D uSource;+uniform float evolveProgress;+uniform float retractProgress;+uniform float seed;+uniform float retractSeed;+uniform float hueShift;+uniform vec2 resolution;++const float Pi = 3.14159;++vec3 computePattern(vec2 uv, float s, float t) {+ vec2 p = uv * 0.8;+ p += vec2(sin(s * 1.61803) * 5.0, cos(s * 2.71828) * 5.0);++ for (int i = 1; i < 5; i++) {+ vec2 newp = p;+ float fi = float(i);+ float phase = s * 0.7 * fi;+ newp.x += 0.6 / fi * cos(fi * p.y + t * 0.7 + 0.3 * fi + phase) + 20.0;+ newp.y += 0.6 / fi * cos(fi * p.x + t * 0.7 + 0.3 * float(i + 10) + phase) - 20.0 + 15.0;+ p = newp;+ }++ float v1 = 0.5 * sin(2.0 * p.x) + 0.5;+ float v2 = 0.5 * sin(2.0 * p.y) + 0.5;+ float blend = sin(p.x + p.y) * 0.5 + 0.5;+ float brightness = v1 * 0.5 + v2 * 0.5;+ float patternValue = brightness * 0.6 + blend * 0.4;++ return vec3(brightness, blend, patternValue);+}++void main() {+ float refScale = 1.92;+ vec2 uv = (gl_FragCoord.xy / resolution) * vec2(refScale, refScale * resolution.y / resolution.x);++ vec3 patA = computePattern(uv, seed, evolveProgress * Pi);+ float threshA = 1.0 - evolveProgress;+ float revealAlpha = smoothstep(threshA, threshA + 0.3, patA.z);++ vec2 maxUv = vec2(refScale, refScale * resolution.y / resolution.x);+ vec2 retractUv = maxUv - uv;+ vec3 patB = computePattern(retractUv, retractSeed, retractProgress * Pi);+ float threshB = 1.0 - retractProgress;+ float eraseAlpha = smoothstep(threshB, threshB + 0.3, patB.z);++ float alpha = revealAlpha * (1.0 - eraseAlpha);++ vec3 yellow = vec3(1.0, 0.85, 0.2);+ vec3 orange = vec3(1.0, 0.5, 0.05);+ vec3 col = mix(yellow, orange, patA.y);+ col *= 0.6 + 0.6 * patA.x;++ float angle = hueShift * Pi / 180.0;+ float cosA = cos(angle);+ float sinA = sin(angle);+ mat3 hueRot = mat3(+ cosA + (1.0 - cosA) / 3.0,+ (1.0 - cosA) / 3.0 - sinA * 0.57735,+ (1.0 - cosA) / 3.0 + sinA * 0.57735,+ (1.0 - cosA) / 3.0 + sinA * 0.57735,+ cosA + (1.0 - cosA) / 3.0,+ (1.0 - cosA) / 3.0 - sinA * 0.57735,+ (1.0 - cosA) / 3.0 - sinA * 0.57735,+ (1.0 - cosA) / 3.0 + sinA * 0.57735,+ cosA + (1.0 - cosA) / 3.0+ );+ col = clamp(hueRot * col, 0.0, 1.0);++ vec4 src = texture(uSource, vUv);+ vec4 leakPm = vec4(col * alpha, alpha);+ fragColor = leakPm + src * (1.0 - alpha);+}+`;++type LightLeakGlState = {+ gl: WebGL2RenderingContext;+ program: WebGLProgram;+ vao: WebGLVertexArrayObject;+ vbo: WebGLBuffer;+ texture: WebGLTexture;+ uSource: WebGLUniformLocation | null;+ uEvolveProgress: WebGLUniformLocation | null;+ uRetractProgress: WebGLUniformLocation | null;+ uSeed: WebGLUniformLocation | null;+ uRetractSeed: WebGLUniformLocation | null;+ uHueShift: WebGLUniformLocation | null;+ uResolution: WebGLUniformLocation | null;+};++const compileShader = (+ gl: WebGL2RenderingContext,+ type: number,+ source: string,+): WebGLShader => {+ const shader = gl.createShader(type);+ if (!shader) {+ throw new Error('Failed to create WebGL shader');+ }++ gl.shaderSource(shader, source);+ gl.compileShader(shader);+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {+ const log = gl.getShaderInfoLog(shader);+ gl.deleteShader(shader);+ throw new Error(`Light leak shader compile failed: ${log ?? '(no log)'}`);+ }++ return shader;+};++const linkProgram = (+ gl: WebGL2RenderingContext,+ vs: WebGLShader,+ fs: WebGLShader,+): WebGLProgram => {+ const program = gl.createProgram();+ if (!program) {+ throw new Error('Failed to create WebGL program');+ }++ gl.attachShader(program, vs);+ gl.attachShader(program, fs);+ gl.linkProgram(program);+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {+ const log = gl.getProgramInfoLog(program);+ gl.deleteProgram(program);+ throw new Error(`Light leak program link failed: ${log ?? '(no log)'}`);+ }++ return program;+};++export const lightLeak = createEffect<LightLeakEffectParams, LightLeakGlState>({+ type: 'remotion/light-leak',+ label: 'lightLeak()',+ documentationLink: 'https://www.remotion.dev/docs/effects/light-leak',+ backend: 'webgl2',+ calculateKey: (params) => {+ const r = resolve(params);+ return `light-leak-${r.seed}-${r.hueShift}-${r.progress}`;+ },+ setup: (target) => {+ const gl = target.getContext('webgl2', {+ premultipliedAlpha: true,+ alpha: true,+ preserveDrawingBuffer: true,+ });+ if (!gl) {+ throw createWebGL2ContextError('light leak effect');+ }++ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);++ const vs = compileShader(gl, gl.VERTEX_SHADER, LIGHT_LEAK_VS);+ const fs = compileShader(gl, gl.FRAGMENT_SHADER, LIGHT_LEAK_FS);+ const program = linkProgram(gl, vs, fs);+ gl.deleteShader(vs);+ gl.deleteShader(fs);++ const vao = gl.createVertexArray();+ if (!vao) {+ throw new Error('Failed to create WebGL vertex array');+ }++ gl.bindVertexArray(vao);++ const data = new Float32Array([+ -1, -1, 0, 0, 1, -1, 1, 0, -1, 1, 0, 1, 1, 1, 1, 1,+ ]);++ const vbo = gl.createBuffer();+ if (!vbo) {+ throw new Error('Failed to create WebGL buffer');+ }++ gl.bindBuffer(gl.ARRAY_BUFFER, vbo);+ gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);++ const aPos = gl.getAttribLocation(program, 'aPos');+ const aUv = gl.getAttribLocation(program, 'aUv');+ gl.enableVertexAttribArray(aPos);+ gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);+ gl.enableVertexAttribArray(aUv);+ gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);++ gl.bindVertexArray(null);++ const texture = gl.createTexture();+ if (!texture) {+ throw new Error('Failed to create WebGL texture');+ }++ gl.bindTexture(gl.TEXTURE_2D, texture);+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);+ gl.bindTexture(gl.TEXTURE_2D, null);++ return {+ gl,+ program,+ vao,+ vbo,+ texture,+ uSource: gl.getUniformLocation(program, 'uSource'),+ uEvolveProgress: gl.getUniformLocation(program, 'evolveProgress'),+ uRetractProgress: gl.getUniformLocation(program, 'retractProgress'),+ uSeed: gl.getUniformLocation(program, 'seed'),+ uRetractSeed: gl.getUniformLocation(program, 'retractSeed'),+ uHueShift: gl.getUniformLocation(program, 'hueShift'),+ uResolution: gl.getUniformLocation(program, 'resolution'),+ };+ },+ apply: ({source, width, height, params, state, flipSourceY}) => {+ const r = resolve(params);+ const evolveProgress = Math.min(1, r.progress * 2);+ const retractProgress = Math.max(0, r.progress * 2 - 1);++ const {+ gl,+ program,+ vao,+ texture,+ uSource,+ uEvolveProgress,+ uRetractProgress,+ uSeed,+ uRetractSeed,+ uHueShift,+ uResolution,+ } = state;++ gl.viewport(0, 0, width, height);+ gl.clearColor(0, 0, 0, 0);+ gl.clear(gl.COLOR_BUFFER_BIT);++ gl.useProgram(program);+ gl.bindVertexArray(vao);++ gl.activeTexture(gl.TEXTURE0);+ gl.bindTexture(gl.TEXTURE_2D, texture);+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipSourceY);+ gl.texImage2D(+ gl.TEXTURE_2D,+ 0,+ gl.RGBA,+ gl.RGBA,+ gl.UNSIGNED_BYTE,+ source as TexImageSource,+ );++ if (uSource) gl.uniform1i(uSource, 0);+ if (uEvolveProgress) gl.uniform1f(uEvolveProgress, evolveProgress);+ if (uRetractProgress) gl.uniform1f(uRetractProgress, retractProgress);+ if (uSeed) gl.uniform1f(uSeed, r.seed);+ if (uRetractSeed) gl.uniform1f(uRetractSeed, r.seed + 42);+ if (uHueShift) gl.uniform1f(uHueShift, r.hueShift);+ if (uResolution) gl.uniform2f(uResolution, width, height);++ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);++ gl.bindVertexArray(null);+ gl.bindTexture(gl.TEXTURE_2D, null);+ gl.useProgram(null);+ },+ cleanup: ({gl, program, vao, vbo, texture}) => {+ gl.deleteBuffer(vbo);+ gl.deleteProgram(program);+ gl.deleteVertexArray(vao);+ gl.deleteTexture(texture);+ },+ schema: lightLeakEffectSchema,+ validateParams: validateLightLeakParams,+});diff --git a/packages/effects/src/test/effect-params.test.ts b/packages/effects/src/test/effect-params.test.tsindex 62b56931d8..2c461ea4d6 100644--- a/packages/effects/src/test/effect-params.test.ts+++ b/packages/effects/src/test/effect-params.test.ts@@ -23,6 +23,7 @@ import {halftoneLinearGradient} from '../halftone-linear-gradient.js';import {halftone} from '../halftone.js';import {hue} from '../hue.js';import {invert} from '../invert.js';+import {lightLeak} from '../light-leak.js';import {lightTrail} from '../light-trail/index.js';import {linearGradientTint} from '../linear-gradient-tint.js';import {linearGradient} from '../linear-gradient.js';@@ -177,6 +178,9 @@ test('@remotion/effects expose documentation links', () => {expect(linearProgressivePixelate().definition.documentationLink).toBe('https://www.remotion.dev/docs/effects/linear-progressive-pixelate',);+ expect(lightLeak().definition.documentationLink).toBe(+ 'https://www.remotion.dev/docs/effects/light-leak',+ );expect(lightTrail().definition.documentationLink).toBe('https://www.remotion.dev/docs/effects/light-trail',);diff --git a/packages/light-leaks/src/test/light-leak-effect-params.test.ts b/packages/effects/src/test/light-leak.test.tssimilarity index 70%rename from packages/light-leaks/src/test/light-leak-effect-params.test.tsrename to packages/effects/src/test/light-leak.test.tsindex e42956e354..9d07687ebc 100644--- a/packages/light-leaks/src/test/light-leak-effect-params.test.ts+++ b/packages/effects/src/test/light-leak.test.ts@@ -1,13 +1,5 @@import {expect, test} from 'bun:test';-import {LightLeakInternals, lightLeak} from '../light-leak-internals.js';-import {lightLeakSchema} from '../LightLeak.js';--test('<LightLeak> exposes background and border controls', () => {- expect('style.backgroundColor' in lightLeakSchema).toBe(true);- expect('style.borderWidth' in lightLeakSchema).toBe(true);- expect('style.borderStyle' in lightLeakSchema).toBe(true);- expect('style.borderColor' in lightLeakSchema).toBe(true);-});+import {lightLeak} from '../light-leak.js';test('lightLeak() accepts default params', () => {expect(() => lightLeak()).not.toThrow();@@ -16,7 +8,7 @@ test('lightLeak() accepts default params', () => {test('lightLeak() exposes its documentation link', () => {expect(lightLeak().definition.documentationLink).toBe(- 'https://www.remotion.dev/docs/light-leaks/light-leak-effect',+ 'https://www.remotion.dev/docs/effects/light-leak',);});@@ -24,10 +16,6 @@ test('lightLeak() exposes its API name as the Studio label', () => {expect(lightLeak().definition.label).toBe('lightLeak()');});-test('LightLeakInternals.lightLeak points to lightLeak()', () => {- expect(LightLeakInternals.lightLeak).toBe(lightLeak);-});-test('lightLeak() rejects non-finite seed', () => {expect(() => lightLeak({seed: Number.NaN})).toThrow('"seed" must be a finite number',diff --git a/packages/example/src/EffectsTestbed/EffectsTestbed.tsx b/packages/example/src/EffectsTestbed/EffectsTestbed.tsxindex c8d5506fc3..93a53cfacc 100644--- a/packages/example/src/EffectsTestbed/EffectsTestbed.tsx+++ b/packages/example/src/EffectsTestbed/EffectsTestbed.tsx@@ -1,12 +1,18 @@import {blur} from '@remotion/effects/blur';import {halftone} from '@remotion/effects/halftone';+import {lightLeak} from '@remotion/effects/light-leak';import {starburst} from '@remotion/effects/starburst';import {tint} from '@remotion/effects/tint';import {wave} from '@remotion/effects/wave';-import {lightLeak} from '@remotion/light-leaks';import {Video} from '@remotion/media';import React from 'react';-import {AbsoluteFill, Solid, useCurrentFrame, useVideoConfig} from 'remotion';+import {+ AbsoluteFill,+ interpolate,+ Solid,+ useCurrentFrame,+ useVideoConfig,+} from 'remotion';const SAMPLE_VIDEO = 'https://remotion.media/bigbuckbunny.mp4';@@ -102,7 +108,6 @@ const AnimatedWaveVideo: React.FC = () => {const AnimatedLightLeakSolid: React.FC = () => {const frame = useCurrentFrame();const {durationInFrames} = useVideoConfig();- const progress = durationInFrames <= 1 ? 0 : frame / (durationInFrames - 1);return (<Solid@@ -114,7 +119,10 @@ const AnimatedLightLeakSolid: React.FC = () => {lightLeak({seed: 1,hueShift: 30,- progress,+ progress: interpolate(frame, [0, durationInFrames - 1], [0, 1], {+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ }),}),]}/>diff --git a/packages/light-leaks/bundle.ts b/packages/light-leaks/bundle.tsindex f7b114c5c3..3d7e6ff1cd 100644--- a/packages/light-leaks/bundle.ts+++ b/packages/light-leaks/bundle.ts@@ -10,6 +10,7 @@ const output = await build({entrypoints: ['src/index.ts'],naming: '[name].mjs',external: [+ '@remotion/effects/light-leak','remotion','remotion/no-react','react',diff --git a/packages/light-leaks/package.json b/packages/light-leaks/package.jsonindex 8748ac1c69..e2ab6a3837 100644--- a/packages/light-leaks/package.json+++ b/packages/light-leaks/package.json@@ -24,6 +24,7 @@"url": "https://github.com/remotion-dev/remotion/issues"},"dependencies": {+ "@remotion/effects": "workspace:*","remotion": "workspace:*","zod": "catalog:"},diff --git a/packages/light-leaks/src/index.ts b/packages/light-leaks/src/index.tsindex 28c0408638..29837d3569 100644--- a/packages/light-leaks/src/index.ts+++ b/packages/light-leaks/src/index.ts@@ -1,8 +1,13 @@+import {lightLeak} from './light-leak-internals';+export {LightLeak} from './LightLeak';export type {LightLeakProps} from './LightLeak';-export {- LightLeakInternals,- lightLeak,- lightLeakEffectSchema,-} from './light-leak-internals';+export {lightLeak, lightLeakEffectSchema} from './light-leak-internals';export type {LightLeakEffectParams} from './light-leak-internals';++/**+ * Experimental internals for the light leak canvas effect pipeline.+ */+export const LightLeakInternals = {+ lightLeak,+} as const;diff --git a/packages/light-leaks/src/light-leak-internals.ts b/packages/light-leaks/src/light-leak-internals.tsindex b0ac39a46c..6a3c34cd04 100644--- a/packages/light-leaks/src/light-leak-internals.ts+++ b/packages/light-leaks/src/light-leak-internals.ts@@ -1,409 +1,5 @@-import type {InteractivitySchema} from 'remotion';-import {Internals} from 'remotion';--const {createEffect, createWebGL2ContextError} = Internals;--const DEFAULT_SEED = 0 as const;-const DEFAULT_HUE_SHIFT = 0 as const;-const DEFAULT_PROGRESS = 0.5 as const;--export const lightLeakEffectSchema = {- seed: {- type: 'number',- default: DEFAULT_SEED,- description: 'Seed',- hiddenFromList: false,- },- hueShift: {- type: 'number',- min: 0,- max: 360,- default: DEFAULT_HUE_SHIFT,- description: 'Hue Shift',- hiddenFromList: false,- },- progress: {- type: 'number',- min: 0,- max: 1,- step: 0.01,- default: DEFAULT_PROGRESS,- description: 'Progress',- hiddenFromList: false,- },-} as const satisfies InteractivitySchema;--export type LightLeakEffectParams = {- readonly seed?: number;- readonly hueShift?: number;- /** Evolve/retract phase from 0 (start) to 1 (end). Defaults to 0.5. */- readonly progress?: number;-};--type LightLeakResolved = {- seed: number;- hueShift: number;- progress: number;-};--const resolve = (p: LightLeakEffectParams): LightLeakResolved => ({- seed: p.seed ?? DEFAULT_SEED,- hueShift: p.hueShift ?? DEFAULT_HUE_SHIFT,- progress: p.progress ?? DEFAULT_PROGRESS,-});--const assertEffectParamsObject = (- params: unknown,- effectLabel: string,-): void => {- if (params === null || typeof params !== 'object') {- throw new TypeError(- `${effectLabel} effect requires a parameters object, but got ${JSON.stringify(params)}`,- );- }-};--const assertOptionalFiniteNumber = (value: unknown, name: string): void => {- if (value === undefined) {- return;- }-- if (typeof value !== 'number' || !Number.isFinite(value)) {- throw new TypeError(- `"${name}" must be a finite number, but got ${JSON.stringify(value)}`,- );- }-};--const validateUnitInterval = (value: number, name: string): void => {- if (value < 0) {- throw new TypeError(- `"${name}" must be >= 0, but got ${JSON.stringify(value)}`,- );- }-- if (value > 1) {- throw new TypeError(- `"${name}" must be <= 1, but got ${JSON.stringify(value)}`,- );- }-};--const validateLightLeakParams = (params: LightLeakEffectParams): void => {- assertEffectParamsObject(params, 'lightLeak()');- assertOptionalFiniteNumber(params.seed, 'seed');- assertOptionalFiniteNumber(params.hueShift, 'hueShift');- assertOptionalFiniteNumber(params.progress, 'progress');-- const {hueShift, progress} = resolve(params);- if (hueShift < 0) {- throw new TypeError(`"hueShift" must be >= 0, but got ${hueShift}`);- }-- if (hueShift > 360) {- throw new TypeError(`"hueShift" must be <= 360, but got ${hueShift}`);- }-- validateUnitInterval(progress, 'progress');-};--const LIGHT_LEAK_VS = /* glsl */ `#version 300 es-in vec2 aPos;-in vec2 aUv;-out vec2 vUv;-void main() {- vUv = aUv;- gl_Position = vec4(aPos, 0.0, 1.0);-}-`;--const LIGHT_LEAK_FS = /* glsl */ `#version 300 es-precision highp float;--in vec2 vUv;-out vec4 fragColor;--uniform sampler2D uSource;-uniform float evolveProgress;-uniform float retractProgress;-uniform float seed;-uniform float retractSeed;-uniform float hueShift;-uniform vec2 resolution;--const float Pi = 3.14159;--vec3 computePattern(vec2 uv, float s, float t) {- vec2 p = uv * 0.8;- p += vec2(sin(s * 1.61803) * 5.0, cos(s * 2.71828) * 5.0);-- for (int i = 1; i < 5; i++) {- vec2 newp = p;- float fi = float(i);- float phase = s * 0.7 * fi;- newp.x += 0.6 / fi * cos(fi * p.y + t * 0.7 + 0.3 * fi + phase) + 20.0;- newp.y += 0.6 / fi * cos(fi * p.x + t * 0.7 + 0.3 * float(i + 10) + phase) - 20.0 + 15.0;- p = newp;- }-- float v1 = 0.5 * sin(2.0 * p.x) + 0.5;- float v2 = 0.5 * sin(2.0 * p.y) + 0.5;- float blend = sin(p.x + p.y) * 0.5 + 0.5;- float brightness = v1 * 0.5 + v2 * 0.5;- float patternValue = brightness * 0.6 + blend * 0.4;-- return vec3(brightness, blend, patternValue);-}--void main() {- float refScale = 1.92;- vec2 uv = (gl_FragCoord.xy / resolution) * vec2(refScale, refScale * resolution.y / resolution.x);-- vec3 patA = computePattern(uv, seed, evolveProgress * Pi);- float threshA = 1.0 - evolveProgress;- float revealAlpha = smoothstep(threshA, threshA + 0.3, patA.z);-- vec2 maxUv = vec2(refScale, refScale * resolution.y / resolution.x);- vec2 retractUv = maxUv - uv;- vec3 patB = computePattern(retractUv, retractSeed, retractProgress * Pi);- float threshB = 1.0 - retractProgress;- float eraseAlpha = smoothstep(threshB, threshB + 0.3, patB.z);-- float alpha = revealAlpha * (1.0 - eraseAlpha);-- vec3 yellow = vec3(1.0, 0.85, 0.2);- vec3 orange = vec3(1.0, 0.5, 0.05);- vec3 col = mix(yellow, orange, patA.y);- col *= 0.6 + 0.6 * patA.x;-- float angle = hueShift * Pi / 180.0;- float cosA = cos(angle);- float sinA = sin(angle);- mat3 hueRot = mat3(- cosA + (1.0 - cosA) / 3.0,- (1.0 - cosA) / 3.0 - sinA * 0.57735,- (1.0 - cosA) / 3.0 + sinA * 0.57735,- (1.0 - cosA) / 3.0 + sinA * 0.57735,- cosA + (1.0 - cosA) / 3.0,- (1.0 - cosA) / 3.0 - sinA * 0.57735,- (1.0 - cosA) / 3.0 - sinA * 0.57735,- (1.0 - cosA) / 3.0 + sinA * 0.57735,- cosA + (1.0 - cosA) / 3.0- );- col = clamp(hueRot * col, 0.0, 1.0);-- vec4 src = texture(uSource, vUv);- vec4 leakPm = vec4(col * alpha, alpha);- fragColor = leakPm + src * (1.0 - alpha);-}-`;--type LightLeakGlState = {- gl: WebGL2RenderingContext;- program: WebGLProgram;- vao: WebGLVertexArrayObject;- vbo: WebGLBuffer;- texture: WebGLTexture;- uSource: WebGLUniformLocation | null;- uEvolveProgress: WebGLUniformLocation | null;- uRetractProgress: WebGLUniformLocation | null;- uSeed: WebGLUniformLocation | null;- uRetractSeed: WebGLUniformLocation | null;- uHueShift: WebGLUniformLocation | null;- uResolution: WebGLUniformLocation | null;-};--const compileShader = (- gl: WebGL2RenderingContext,- type: number,- source: string,-): WebGLShader => {- const shader = gl.createShader(type);- if (!shader) {- throw new Error('Failed to create WebGL shader');- }-- gl.shaderSource(shader, source);- gl.compileShader(shader);- if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {- const log = gl.getShaderInfoLog(shader);- gl.deleteShader(shader);- throw new Error(`Light leak shader compile failed: ${log ?? '(no log)'}`);- }-- return shader;-};--const linkProgram = (- gl: WebGL2RenderingContext,- vs: WebGLShader,- fs: WebGLShader,-): WebGLProgram => {- const program = gl.createProgram();- if (!program) {- throw new Error('Failed to create WebGL program');- }-- gl.attachShader(program, vs);- gl.attachShader(program, fs);- gl.linkProgram(program);- if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {- const log = gl.getProgramInfoLog(program);- gl.deleteProgram(program);- throw new Error(`Light leak program link failed: ${log ?? '(no log)'}`);- }-- return program;-};--export const lightLeak = createEffect<LightLeakEffectParams, LightLeakGlState>({- type: 'dev.remotion.lightLeaks.lightLeak',- label: 'lightLeak()',- documentationLink:- 'https://www.remotion.dev/docs/light-leaks/light-leak-effect',- backend: 'webgl2',- calculateKey: (params) => {- const r = resolve(params);- return `light-leak-${r.seed}-${r.hueShift}-${r.progress}`;- },- setup: (target) => {- const gl = target.getContext('webgl2', {- premultipliedAlpha: true,- alpha: true,- preserveDrawingBuffer: true,- });- if (!gl) {- throw createWebGL2ContextError('light leak effect');- }-- gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);-- const vs = compileShader(gl, gl.VERTEX_SHADER, LIGHT_LEAK_VS);- const fs = compileShader(gl, gl.FRAGMENT_SHADER, LIGHT_LEAK_FS);- const program = linkProgram(gl, vs, fs);- gl.deleteShader(vs);- gl.deleteShader(fs);-- const vao = gl.createVertexArray();- if (!vao) {- throw new Error('Failed to create WebGL vertex array');- }-- gl.bindVertexArray(vao);-- const data = new Float32Array([- -1, -1, 0, 0, 1, -1, 1, 0, -1, 1, 0, 1, 1, 1, 1, 1,- ]);-- const vbo = gl.createBuffer();- if (!vbo) {- throw new Error('Failed to create WebGL buffer');- }-- gl.bindBuffer(gl.ARRAY_BUFFER, vbo);- gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);-- const aPos = gl.getAttribLocation(program, 'aPos');- const aUv = gl.getAttribLocation(program, 'aUv');- gl.enableVertexAttribArray(aPos);- gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);- gl.enableVertexAttribArray(aUv);- gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);-- gl.bindVertexArray(null);-- const texture = gl.createTexture();- if (!texture) {- throw new Error('Failed to create WebGL texture');- }-- gl.bindTexture(gl.TEXTURE_2D, texture);- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);- gl.bindTexture(gl.TEXTURE_2D, null);-- return {- gl,- program,- vao,- vbo,- texture,- uSource: gl.getUniformLocation(program, 'uSource'),- uEvolveProgress: gl.getUniformLocation(program, 'evolveProgress'),- uRetractProgress: gl.getUniformLocation(program, 'retractProgress'),- uSeed: gl.getUniformLocation(program, 'seed'),- uRetractSeed: gl.getUniformLocation(program, 'retractSeed'),- uHueShift: gl.getUniformLocation(program, 'hueShift'),- uResolution: gl.getUniformLocation(program, 'resolution'),- };- },- apply: ({source, width, height, params, state, flipSourceY}) => {- const r = resolve(params);- const evolveProgress = Math.min(1, r.progress * 2);- const retractProgress = Math.max(0, r.progress * 2 - 1);-- const {- gl,- program,- vao,- texture,- uSource,- uEvolveProgress,- uRetractProgress,- uSeed,- uRetractSeed,- uHueShift,- uResolution,- } = state;-- gl.viewport(0, 0, width, height);- gl.clearColor(0, 0, 0, 0);- gl.clear(gl.COLOR_BUFFER_BIT);-- gl.useProgram(program);- gl.bindVertexArray(vao);-- gl.activeTexture(gl.TEXTURE0);- gl.bindTexture(gl.TEXTURE_2D, texture);- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);- gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipSourceY);- gl.texImage2D(- gl.TEXTURE_2D,- 0,- gl.RGBA,- gl.RGBA,- gl.UNSIGNED_BYTE,- source as TexImageSource,- );-- if (uSource) gl.uniform1i(uSource, 0);- if (uEvolveProgress) gl.uniform1f(uEvolveProgress, evolveProgress);- if (uRetractProgress) gl.uniform1f(uRetractProgress, retractProgress);- if (uSeed) gl.uniform1f(uSeed, r.seed);- if (uRetractSeed) gl.uniform1f(uRetractSeed, r.seed + 42);- if (uHueShift) gl.uniform1f(uHueShift, r.hueShift);- if (uResolution) gl.uniform2f(uResolution, width, height);-- gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);-- gl.bindVertexArray(null);- gl.bindTexture(gl.TEXTURE_2D, null);- gl.useProgram(null);- },- cleanup: ({gl, program, vao, vbo, texture}) => {- gl.deleteBuffer(vbo);- gl.deleteProgram(program);- gl.deleteVertexArray(vao);- gl.deleteTexture(texture);- },- schema: lightLeakEffectSchema,- validateParams: validateLightLeakParams,-});--/**- * Experimental internals for the light leak canvas effect pipeline.- */-export const LightLeakInternals = {+export {lightLeak,-} as const;+ lightLeakEffectSchema,+ type LightLeakEffectParams,+} from '@remotion/effects/light-leak';diff --git a/packages/light-leaks/src/test/light-leak-component-params.test.ts b/packages/light-leaks/src/test/light-leak-component-params.test.tsnew file mode 100644index 0000000000..38b6ccbe1f--- /dev/null+++ b/packages/light-leaks/src/test/light-leak-component-params.test.ts@@ -0,0 +1,17 @@+import {expect, test} from 'bun:test';+import {LightLeakInternals, lightLeak} from '../index.js';+import {lightLeakSchema} from '../LightLeak.js';++test('<LightLeak> exposes background and border controls', () => {+ expect('style.backgroundColor' in lightLeakSchema).toBe(true);+ expect('style.borderWidth' in lightLeakSchema).toBe(true);+ expect('style.borderStyle' in lightLeakSchema).toBe(true);+ expect('style.borderColor' in lightLeakSchema).toBe(true);+});++test('@remotion/light-leaks re-exports the migrated effect', () => {+ expect(LightLeakInternals.lightLeak).toBe(lightLeak);+ expect(lightLeak().definition.documentationLink).toBe(+ 'https://www.remotion.dev/docs/effects/light-leak',+ );+});diff --git a/packages/skills/skills/remotion-markup/effects.md b/packages/skills/skills/remotion-markup/effects.mdindex 7c6136bd92..f8d54974d6 100644--- a/packages/skills/skills/remotion-markup/effects.md+++ b/packages/skills/skills/remotion-markup/effects.md@@ -18,8 +18,6 @@ Install the package that provides the chosen effect:npx remotion add @remotion/effects```-Use `npx remotion add @remotion/light-leaks` for `lightLeak()`.-Effects are functions passed to the `effects` prop of canvas-based components such as `<Video>` from `@remotion/media`, `<Solid>`, `<CanvasImage>`, and `<HtmlInCanvas>`.```tsx@@ -29,7 +27,7 @@ import {blur} from '@remotion/effects/blur';<Video src="https://remotion.media/video.mp4" effects={[blur({radius: 8})]} />;```-Use the effect docs for exact props and imports. Most `@remotion/effects` imports use `@remotion/effects/<effect-slug>`; `uvTranslate()` and `xyTranslate()` use `@remotion/effects/translate`; `lightLeak()` uses `@remotion/light-leaks`.+Use the effect docs for exact props and imports. Most `@remotion/effects` imports use `@remotion/effects/<effect-slug>`; `uvTranslate()` and `xyTranslate()` use `@remotion/effects/translate`.These effects use WebGL2. During renders, enable WebGL with:@@ -51,7 +49,6 @@ import {brightness} from "@remotion/effects";<Video src="https://remotion.media/video.mp4" effects={[brightness({})]} />;```-## Custom effectsUse `createEffect()` from `remotion` when the user wants a reusable effect factory that works in the same `effects` array as `@remotion/effects`.diff --git a/packages/studio-shared/src/effect-catalog.ts b/packages/studio-shared/src/effect-catalog.tsindex 5252ad0dd7..a443ed4bb1 100644--- a/packages/studio-shared/src/effect-catalog.ts+++ b/packages/studio-shared/src/effect-catalog.ts@@ -14,10 +14,6 @@ export type EffectCatalogCategory = {};export const getEffectDocumentationPath = (item: EffectCatalogItem) => {- if (item.id === 'effects-light-leak') {- return '/docs/light-leaks/light-leak-effect';- }-return `/docs/effects/${item.id.slice('effects-'.length)}`;};@@ -777,7 +773,7 @@ export const EFFECT_CATALOG: readonly EffectCatalogItem[] = [description: 'Light leak overlay effect',effect: {name: 'lightLeak',- importPath: '@remotion/light-leaks',+ importPath: '@remotion/effects/light-leak',config: {},},},diff --git a/packages/studio/src/test/effect-catalog.test.ts b/packages/studio/src/test/effect-catalog.test.tsindex e34d570f12..374b2bb6e1 100644--- a/packages/studio/src/test/effect-catalog.test.ts+++ b/packages/studio/src/test/effect-catalog.test.ts@@ -34,7 +34,7 @@ test('effect catalog exposes documentation links for picker context menu', () =>'https://www.remotion.dev/docs/effects/shrinkwrap',);expect(links.get('lightLeak()')).toBe(- 'https://www.remotion.dev/docs/light-leaks/light-leak-effect',+ 'https://www.remotion.dev/docs/effects/light-leak',);expect(links.get('starburst()')).toBe('https://www.remotion.dev/docs/effects/starburst',