🎥 Make videos programmatically with React
`@remotion/effects`: Add `longShadows()` for directional shadows
Jonny Burgere846684d3995
diff --git a/packages/docs/components/effects-demos/registry.ts b/packages/docs/components/effects-demos/registry.tsindex cf08fbf9c5..9524e89aa3 100644--- a/packages/docs/components/effects-demos/registry.ts+++ b/packages/docs/components/effects-demos/registry.ts@@ -33,6 +33,7 @@ import {linearProgressiveBlur} from '@remotion/effects/linear-progressive-blur';import {linearProgressivePixelate} from '@remotion/effects/linear-progressive-pixelate';import {lines} from '@remotion/effects/lines';import {liquidContours} from '@remotion/effects/liquid-contours';+import {longShadows} from '@remotion/effects/long-shadows';import {lut} from '@remotion/effects/lut';import {mirror} from '@remotion/effects/mirror';import {noise} from '@remotion/effects/noise';@@ -109,6 +110,7 @@ import {EffectsLinearProgressiveBlurPreview} from '../effects/effects-linear-proimport {EffectsLinearProgressivePixelatePreview} from '../effects/effects-linear-progressive-pixelate-preview';import {EffectsLinesPreview} from '../effects/effects-lines-preview';import {EffectsLiquidContoursPreview} from '../effects/effects-liquid-contours-preview';+import {EffectsLongShadowsPreview} from '../effects/effects-long-shadows-preview';import {EffectsLutPreview,LUT_PREVIEW_CONTENT,@@ -332,6 +334,14 @@ export const effectsDemos: EffectsDemoType[] = [comp: EffectsDropShadowPreview,schema: dropShadow().definition.schema,},+ {+ ...defaults,+ id: 'effects-long-shadows',+ effectName: 'longShadows',+ effectImportPath: '@remotion/effects/long-shadows',+ comp: EffectsLongShadowsPreview,+ schema: longShadows().definition.schema,+ },{...defaults,id: 'effects-glow',diff --git a/packages/docs/components/effects/effects-long-shadows-preview.tsx b/packages/docs/components/effects/effects-long-shadows-preview.tsxnew file mode 100644index 0000000000..92b1e9cae3--- /dev/null+++ b/packages/docs/components/effects/effects-long-shadows-preview.tsx@@ -0,0 +1,56 @@+import {longShadows} from '@remotion/effects/long-shadows';+import React from 'react';+import {AbsoluteFill, CanvasImage, staticFile} from 'remotion';++export const LONG_SHADOWS_PREVIEW_PARAMS = {+ length: 240,+ angle: 45,+ color: '#777777',+ opacity: 1,+} as const;++export const LongShadowsTextSource: React.FC = () => {+ return (+ <AbsoluteFill+ style={{+ justifyContent: 'center',+ paddingLeft: 140,+ paddingBottom: 120,+ }}+ >+ <div+ style={{+ color: 'white',+ fontFamily: 'Arial, Helvetica, sans-serif',+ fontSize: 170,+ fontWeight: 900,+ letterSpacing: -6,+ lineHeight: 0.95,+ }}+ >+ LONG+ <br />+ SHADOWS+ </div>+ </AbsoluteFill>+ );+};++export const EffectsLongShadowsPreview: React.FC<{+ readonly length: number;+ readonly angle: number;+ readonly color: string;+ readonly opacity: number;+}> = ({length, angle, color, opacity}) => {+ return (+ <AbsoluteFill style={{backgroundColor: '#b8b8b8'}}>+ <CanvasImage+ src={staticFile('img/effects-long-shadows-text.png')}+ width={1280}+ height={720}+ fit="cover"+ effects={[longShadows({length, angle, color, opacity})]}+ />+ </AbsoluteFill>+ );+};diff --git a/packages/docs/docs/effects/long-shadows.mdx b/packages/docs/docs/effects/long-shadows.mdxnew file mode 100644index 0000000000..980d4ffa8b--- /dev/null+++ b/packages/docs/docs/effects/long-shadows.mdx@@ -0,0 +1,92 @@+---+image: /generated/articles-docs-effects-long-shadows.png+slug: /effects/long-shadows+title: longShadows()+sidebar_label: longShadows()+crumb: '@remotion/effects'+---++# longShadows()<AvailableFrom v="4.0.537" />++_Part of the [`@remotion/effects`](/docs/effects/api) package._++Extends the alpha silhouette of a canvas-based component into a solid directional shadow. Use it for long shadows behind text, logos, and shapes, or for a faux 3D extrusion.++## Preview++<EffectsDemo type="effects-long-shadows" />++## Example++```tsx twoslash title="MyComp.tsx"+import {AbsoluteFill, HtmlInCanvas} from 'remotion';+import {longShadows} from '@remotion/effects/long-shadows';++export const MyComp: React.FC = () => {+ return (+ <AbsoluteFill style={{backgroundColor: '#b8b8b8'}}>+ <HtmlInCanvas+ width={1280}+ height={720}+ effects={[+ longShadows({+ length: 240,+ angle: 45,+ color: '#777777',+ opacity: 1,+ }),+ ]}+ >+ <div+ style={{+ color: 'white',+ fontSize: 160,+ fontWeight: 900,+ padding: 100,+ }}+ >+ LONG SHADOWS+ </div>+ </HtmlInCanvas>+ </AbsoluteFill>+ );+};+```++Keep the background outside the component receiving the effect so the shadow follows the text's transparency. Shadows are clipped to the component's canvas bounds; leave room around the source for the shadow.++## API++Pass an object with the following properties. You can also call `longShadows()` without arguments.++### `length?`++Length of the shadow in pixels. Defaults to `240`. Must be at least `0`. A value of `0` leaves the source unchanged.++### `angle?`++Direction of the shadow in degrees, clockwise from the right. Defaults to `45`, pointing down and right. `90` points down, `180` points left, and `270` points up.++### `color?`++CSS color of the shadow. Defaults to `'#777777'`. The color's alpha is multiplied by `opacity`.++### `opacity?`++Opacity of the shadow from `0` to `1`. Defaults to `1`. Source transparency is preserved in the shadow, and overlapping shadow regions do not accumulate opacity.++### `disabled?`++When `true`, the effect is skipped. Defaults to `false`.++## Requirements++`longShadows()` uses a WebGL2 backend. See [Using WebGL and WebGPU during renders](/docs/webgl).++## See also++- [`@remotion/effects`](/docs/effects/api)+- [`dropShadow()`](/docs/effects/drop-shadow)+- [HTML-in-canvas guide](/docs/html-in-canvas)+- [Jake In Motion's Minimax & Long Shadows tutorial](https://www.youtube.com/watch?v=ibfYiy--9Hs&t=235s)+- [Source code for this effect](https://github.com/remotion-dev/remotion/blob/main/packages/effects/src/long-shadows.ts)diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.tsindex d1cfed9e0d..1189795750 100644--- a/packages/docs/sidebars.ts+++ b/packages/docs/sidebars.ts@@ -317,6 +317,7 @@ const sidebars: SidebarsConfig = {'effects/light-trail','effects/lines','effects/liquid-contours',+ 'effects/long-shadows','effects/lut','effects/mirror','effects/noise',diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.tsindex 6e536850a1..1b6877bf20 100644--- a/packages/docs/src/data/articles.ts+++ b/packages/docs/src/data/articles.ts@@ -3708,6 +3708,15 @@ export const articles = [noAi: false,slug: 'effects/liquid-contours',},+ {+ id: 'effects/long-shadows',+ title: 'longShadows()',+ relativePath: 'docs/effects/long-shadows.mdx',+ compId: 'articles-docs-effects-long-shadows',+ crumb: '@remotion/effects',+ noAi: false,+ slug: 'effects/long-shadows',+ },{id: 'effects/lut',title: 'lut()',diff --git a/packages/docs/src/remotion/Root.tsx b/packages/docs/src/remotion/Root.tsxindex 03b090112a..b29ff5d823 100644--- a/packages/docs/src/remotion/Root.tsx+++ b/packages/docs/src/remotion/Root.tsx@@ -45,6 +45,11 @@ import {} from '../../components/effects/effects-linear-progressive-pixelate-preview';import {EffectsLinesPreview} from '../../components/effects/effects-lines-preview';import {EffectsLiquidContoursPreview} from '../../components/effects/effects-liquid-contours-preview';+import {+ EffectsLongShadowsPreview,+ LongShadowsTextSource,+ LONG_SHADOWS_PREVIEW_PARAMS,+} from '../../components/effects/effects-long-shadows-preview';import {EffectsLutPreview,LUT_PREVIEW_CONTENT,@@ -409,6 +414,19 @@ export const RemotionRoot: React.FC = () => {slats: 14,}}/>+ <Still+ id="effects-long-shadows-text-source"+ component={LongShadowsTextSource}+ width={1280}+ height={720}+ />+ <Still+ id="effects-long-shadows-preview"+ component={EffectsLongShadowsPreview}+ width={1280}+ height={720}+ defaultProps={LONG_SHADOWS_PREVIEW_PARAMS}+ /><Stillid="effects-drop-shadow-preview"component={EffectsDropShadowPreview}diff --git a/packages/docs/static/generated/articles-docs-effects-long-shadows.png b/packages/docs/static/generated/articles-docs-effects-long-shadows.pngnew file mode 100644index 0000000000..4a8794a14cBinary files /dev/null and b/packages/docs/static/generated/articles-docs-effects-long-shadows.png differdiff --git a/packages/docs/static/img/effects-long-shadows-preview.png b/packages/docs/static/img/effects-long-shadows-preview.pngnew file mode 100644index 0000000000..b8d556694bBinary files /dev/null and b/packages/docs/static/img/effects-long-shadows-preview.png differdiff --git a/packages/docs/static/img/effects-long-shadows-text.png b/packages/docs/static/img/effects-long-shadows-text.pngnew file mode 100644index 0000000000..bbef4f5c53Binary files /dev/null and b/packages/docs/static/img/effects-long-shadows-text.png differdiff --git a/packages/effects/bundle.ts b/packages/effects/bundle.tsindex 50450fe454..92cc716429 100644--- a/packages/effects/bundle.ts+++ b/packages/effects/bundle.ts@@ -44,6 +44,7 @@ const effectEntrypoints = ['src/light-leak.ts','src/light-trail.ts','src/levels.ts',+ 'src/long-shadows.ts','src/lut.ts','src/mirror.ts','src/noise.ts',diff --git a/packages/effects/package.json b/packages/effects/package.jsonindex 1869383420..4129440552 100644--- a/packages/effects/package.json+++ b/packages/effects/package.json@@ -204,6 +204,11 @@"module": "./dist/esm/levels.mjs","import": "./dist/esm/levels.mjs"},+ "./long-shadows": {+ "types": "./dist/long-shadows.d.ts",+ "module": "./dist/esm/long-shadows.mjs",+ "import": "./dist/esm/long-shadows.mjs"+ },"./lut": {"types": "./dist/lut.d.ts","module": "./dist/esm/lut.mjs",@@ -505,6 +510,9 @@"levels": ["dist/levels.d.ts"],+ "long-shadows": [+ "dist/long-shadows.d.ts"+ ],"lut": ["dist/lut.d.ts"],diff --git a/packages/effects/src/long-shadows.ts b/packages/effects/src/long-shadows.tsnew file mode 100644index 0000000000..8781fa467c--- /dev/null+++ b/packages/effects/src/long-shadows.ts@@ -0,0 +1,422 @@+import type {InteractivitySchema} from 'remotion';+import {Internals} from 'remotion';+import {+ assertOptionalFiniteNumber,+ parseColorRgba,+ type ParsedColorRgba,+ validateNonNegative,+ validateUnitInterval,+} from './color-utils.js';+import {+ assertEffectParamsObject,+ assertOptionalColor,+} from './validate-effect-param.js';++const {createEffect, createWebGL2ContextError} = Internals;++const DEFAULT_LENGTH = 240 as const;+const DEFAULT_ANGLE = 45 as const;+const DEFAULT_COLOR = '#777777' as const;+const DEFAULT_OPACITY = 1 as const;++const longShadowsSchema = {+ length: {+ type: 'number',+ min: 0,+ max: 1000,+ step: 1,+ default: DEFAULT_LENGTH,+ description: 'Length',+ hiddenFromList: false,+ },+ angle: {+ type: 'rotation-degrees',+ step: 1,+ default: DEFAULT_ANGLE,+ description: 'Angle',+ },+ color: {+ type: 'color',+ default: DEFAULT_COLOR,+ description: 'Color',+ },+ opacity: {+ type: 'number',+ min: 0,+ max: 1,+ step: 0.01,+ default: DEFAULT_OPACITY,+ description: 'Opacity',+ hiddenFromList: false,+ },+} as const satisfies InteractivitySchema;++export type LongShadowsParams = {+ /** Length of the shadow in pixels. Defaults to `240`. */+ readonly length?: number;+ /** Clockwise angle in degrees, with `0` pointing right. Defaults to `45`. */+ readonly angle?: number;+ /** CSS color of the shadow. Defaults to `'#777777'`. */+ readonly color?: string;+ /** Shadow opacity from `0` to `1`. Defaults to `1`. */+ readonly opacity?: number;+};++const resolve = (params: LongShadowsParams) => ({+ length: params.length ?? DEFAULT_LENGTH,+ angle: params.angle ?? DEFAULT_ANGLE,+ color: params.color ?? DEFAULT_COLOR,+ opacity: params.opacity ?? DEFAULT_OPACITY,+});++const validateLongShadowsParams = (params: LongShadowsParams): void => {+ assertEffectParamsObject(params, 'Long shadows');+ assertOptionalFiniteNumber(params.length, 'length');+ assertOptionalFiniteNumber(params.angle, 'angle');+ assertOptionalFiniteNumber(params.opacity, 'opacity');+ assertOptionalColor(params.color, 'color');+ const resolved = resolve(params);+ validateNonNegative(resolved.length, 'length');+ validateUnitInterval(resolved.opacity, 'opacity');+};++type LongShadowsState = {+ readonly gl: WebGL2RenderingContext;+ readonly extendProgram: WebGLProgram;+ readonly compositeProgram: WebGLProgram;+ readonly vao: WebGLVertexArrayObject;+ readonly vbo: WebGLBuffer;+ readonly sourceTexture: WebGLTexture;+ readonly shadowTextures: readonly [WebGLTexture, WebGLTexture];+ readonly framebuffer: WebGLFramebuffer;+ readonly extendSource: WebGLUniformLocation | null;+ readonly extendOffset: WebGLUniformLocation | null;+ readonly compositeSource: WebGLUniformLocation | null;+ readonly compositeShadow: WebGLUniformLocation | null;+ readonly compositeColor: WebGLUniformLocation | null;+ readonly colorCtx: CanvasRenderingContext2D;+ cachedColor: string;+ cachedRgba: ParsedColorRgba;+ width: number;+ height: number;+};++const VERTEX_SHADER = /* glsl */ `#version 300 es+layout(location = 0) in vec2 aPos;+layout(location = 1) in vec2 aUv;+out vec2 vUv;++void main() {+ vUv = aUv;+ gl_Position = vec4(aPos, 0.0, 1.0);+}+`;++const EXTEND_SHADER = /* glsl */ `#version 300 es+precision highp float;+in vec2 vUv;+out vec4 fragColor;+uniform sampler2D uSource;+uniform vec2 uOffset;++float alphaAt(ivec2 pixel) {+ ivec2 size = textureSize(uSource, 0);+ if (any(lessThan(pixel, ivec2(0))) || any(greaterThanEqual(pixel, size))) {+ return 0.0;+ }+ return texelFetch(uSource, pixel, 0).a;+}++void main() {+ // Interpolate with transparent pixels outside the canvas instead of+ // clamping the border, which would stretch edge pixels into the shadow.+ vec2 pixel = (vUv - uOffset) * vec2(textureSize(uSource, 0)) - 0.5;+ ivec2 base = ivec2(floor(pixel));+ vec2 fraction = fract(pixel);+ float shifted = mix(+ mix(alphaAt(base), alphaAt(base + ivec2(1, 0)), fraction.x),+ mix(alphaAt(base + ivec2(0, 1)), alphaAt(base + ivec2(1, 1)), fraction.x),+ fraction.y+ );+ fragColor = vec4(0.0, 0.0, 0.0, max(texture(uSource, vUv).a, shifted));+}+`;++const COMPOSITE_SHADER = /* glsl */ `#version 300 es+precision highp float;+in vec2 vUv;+out vec4 fragColor;+uniform sampler2D uSource;+uniform sampler2D uShadow;+uniform vec4 uColor;++void main() {+ vec4 source = texture(uSource, vUv);+ float alpha = texture(uShadow, vUv).a * uColor.a;+ fragColor = source + vec4(uColor.rgb * alpha, alpha) * (1.0 - source.a);+}+`;++const createProgram = (+ gl: WebGL2RenderingContext,+ fragmentSource: string,+): WebGLProgram => {+ const program = gl.createProgram();+ if (!program) {+ throw new Error('Failed to create long shadows program');+ }++ for (const [type, source] of [+ [gl.VERTEX_SHADER, VERTEX_SHADER],+ [gl.FRAGMENT_SHADER, fragmentSource],+ ] as const) {+ const shader = gl.createShader(type);+ if (!shader) {+ gl.deleteProgram(program);+ throw new Error('Failed to create long shadows shader');+ }++ gl.shaderSource(shader, source);+ gl.compileShader(shader);+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {+ const log = gl.getShaderInfoLog(shader);+ gl.deleteShader(shader);+ gl.deleteProgram(program);+ throw new Error(+ `Long shadows shader compile failed: ${log ?? '(no log)'}`,+ );+ }++ gl.attachShader(program, shader);+ gl.deleteShader(shader);+ }++ gl.linkProgram(program);+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {+ const log = gl.getProgramInfoLog(program);+ gl.deleteProgram(program);+ throw new Error(`Long shadows program link failed: ${log ?? '(no log)'}`);+ }++ return program;+};++export const longShadows = createEffect<LongShadowsParams, LongShadowsState>({+ type: 'remotion/long-shadows',+ label: 'longShadows()',+ documentationLink: 'https://www.remotion.dev/docs/effects/long-shadows',+ backend: 'webgl2',+ calculateKey: (params) => {+ const {length, angle, color, opacity} = resolve(params);+ return `long-shadows-${length}-${angle}-${color}-${opacity}`;+ },+ setup: (target) => {+ const gl = target.getContext('webgl2', {+ premultipliedAlpha: true,+ alpha: true,+ preserveDrawingBuffer: true,+ });+ if (!gl) {+ throw createWebGL2ContextError('long shadows effect');+ }++ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);+ const extendProgram = createProgram(gl, EXTEND_SHADER);+ const compositeProgram = createProgram(gl, COMPOSITE_SHADER);+ const vao = gl.createVertexArray();+ const vbo = gl.createBuffer();+ const framebuffer = gl.createFramebuffer();+ if (!vao || !vbo || !framebuffer) {+ throw new Error('Failed to create long shadows buffers');+ }++ gl.bindVertexArray(vao);+ gl.bindBuffer(gl.ARRAY_BUFFER, vbo);+ gl.bufferData(+ gl.ARRAY_BUFFER,+ new Float32Array([-1, -1, 0, 0, 1, -1, 1, 0, -1, 1, 0, 1, 1, 1, 1, 1]),+ gl.STATIC_DRAW,+ );+ gl.enableVertexAttribArray(0);+ gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 16, 0);+ gl.enableVertexAttribArray(1);+ gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 16, 8);+ gl.bindVertexArray(null);++ const textures = [0, 1, 2].map(() => {+ const texture = gl.createTexture();+ if (!texture) {+ throw new Error('Failed to create long shadows texture');+ }++ 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.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);+ return texture;+ });+ gl.bindTexture(gl.TEXTURE_2D, null);++ const colorCanvas = document.createElement('canvas');+ colorCanvas.width = 1;+ colorCanvas.height = 1;+ const colorCtx = colorCanvas.getContext('2d', {willReadFrequently: true});+ if (!colorCtx) {+ throw new Error('Failed to acquire 2D context for color parsing');+ }++ return {+ gl,+ extendProgram,+ compositeProgram,+ vao,+ vbo,+ framebuffer,+ sourceTexture: textures[0],+ shadowTextures: [textures[1], textures[2]],+ extendSource: gl.getUniformLocation(extendProgram, 'uSource'),+ extendOffset: gl.getUniformLocation(extendProgram, 'uOffset'),+ compositeSource: gl.getUniformLocation(compositeProgram, 'uSource'),+ compositeShadow: gl.getUniformLocation(compositeProgram, 'uShadow'),+ compositeColor: gl.getUniformLocation(compositeProgram, 'uColor'),+ colorCtx,+ cachedColor: '',+ cachedRgba: [0, 0, 0, 0],+ width: 0,+ height: 0,+ };+ },+ apply: ({source, width, height, params, state, flipSourceY}) => {+ const {length, angle, color, opacity} = resolve(params);+ const {gl, sourceTexture, shadowTextures, framebuffer} = state;+ if (state.cachedColor !== color) {+ state.cachedRgba = parseColorRgba(state.colorCtx, color);+ state.cachedColor = color;+ }++ gl.viewport(0, 0, width, height);+ gl.activeTexture(gl.TEXTURE0);+ gl.bindTexture(gl.TEXTURE_2D, sourceTexture);+ 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 (state.width !== width || state.height !== height) {+ for (const texture of shadowTextures) {+ gl.bindTexture(gl.TEXTURE_2D, texture);+ gl.texImage2D(+ gl.TEXTURE_2D,+ 0,+ gl.RGBA,+ width,+ height,+ 0,+ gl.RGBA,+ gl.UNSIGNED_BYTE,+ null,+ );+ }++ state.width = width;+ state.height = height;+ }++ gl.bindVertexArray(state.vao);+ gl.useProgram(state.extendProgram);+ gl.uniform1i(state.extendSource, 0);++ // No in-canvas source can cast farther than the canvas diagonal.+ const distance =+ opacity === 0 || state.cachedRgba[3] === 0+ ? 0+ : Math.min(length, Math.hypot(width, height));+ const steps = Math.ceil(distance);+ const radians = ((angle % 360) * Math.PI) / 180;+ const stepLength = steps === 0 ? 0 : distance / steps;+ let shadow = sourceTexture;+ let covered = 0;+ let pass = 0;++ // Each pass extends the existing interval by up to its own size.+ // This covers every step with logarithmic passes, even for long shadows.+ while (covered < steps) {+ const extension = Math.min(covered + 1, steps - covered);+ const output = shadowTextures[pass % 2];+ gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);+ gl.framebufferTexture2D(+ gl.FRAMEBUFFER,+ gl.COLOR_ATTACHMENT0,+ gl.TEXTURE_2D,+ output,+ 0,+ );+ if (+ gl.checkFramebufferStatus(gl.FRAMEBUFFER) !== gl.FRAMEBUFFER_COMPLETE+ ) {+ throw new Error('Long shadows framebuffer incomplete');+ }++ gl.bindTexture(gl.TEXTURE_2D, shadow);+ gl.uniform2f(+ state.extendOffset,+ (Math.cos(radians) * extension * stepLength) / width,+ (-Math.sin(radians) * extension * stepLength) / height,+ );+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);+ shadow = output;+ covered += extension;+ pass++;+ }++ gl.bindFramebuffer(gl.FRAMEBUFFER, null);+ gl.useProgram(state.compositeProgram);+ gl.bindTexture(gl.TEXTURE_2D, sourceTexture);+ gl.activeTexture(gl.TEXTURE1);+ gl.bindTexture(gl.TEXTURE_2D, shadow);+ gl.uniform1i(state.compositeSource, 0);+ gl.uniform1i(state.compositeShadow, 1);+ const [r, g, b, a] = state.cachedRgba;+ gl.uniform4f(+ state.compositeColor,+ r / 255,+ g / 255,+ b / 255,+ length === 0 ? 0 : (a / 255) * opacity,+ );+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);+ gl.bindVertexArray(null);+ gl.bindTexture(gl.TEXTURE_2D, null);+ gl.activeTexture(gl.TEXTURE0);+ gl.bindTexture(gl.TEXTURE_2D, null);+ gl.useProgram(null);+ },+ cleanup: ({+ gl,+ extendProgram,+ compositeProgram,+ vao,+ vbo,+ framebuffer,+ sourceTexture,+ shadowTextures,+ }) => {+ gl.deleteProgram(extendProgram);+ gl.deleteProgram(compositeProgram);+ gl.deleteVertexArray(vao);+ gl.deleteBuffer(vbo);+ gl.deleteFramebuffer(framebuffer);+ gl.deleteTexture(sourceTexture);+ for (const texture of shadowTextures) {+ gl.deleteTexture(texture);+ }+ },+ schema: longShadowsSchema,+ validateParams: validateLongShadowsParams,+});diff --git a/packages/studio-shared/src/effect-catalog.ts b/packages/studio-shared/src/effect-catalog.tsindex 33f9db2201..a2a50ce760 100644--- a/packages/studio-shared/src/effect-catalog.ts+++ b/packages/studio-shared/src/effect-catalog.ts@@ -359,6 +359,17 @@ export const EFFECT_CATALOG: readonly EffectCatalogItem[] = [config: {},},},+ {+ id: 'effects-long-shadows',+ category: 'Blur & Shadow',+ label: 'longShadows()',+ description: 'Solid directional shadow or faux extrusion',+ effect: {+ name: 'longShadows',+ importPath: '@remotion/effects/long-shadows',+ config: {},+ },+ },{id: 'effects-glow',category: 'Blur & Shadow',