🎥 Make videos programmatically with React
nice
JonnyBurger9a71576a4bec
diff --git a/packages/example/src/LightLeak/AnimatedSize.tsx b/packages/example/src/LightLeak/AnimatedSize.tsxnew file mode 100644index 0000000000..bfaa8603fb--- /dev/null+++ b/packages/example/src/LightLeak/AnimatedSize.tsx@@ -0,0 +1,29 @@+import {LightLeak} from '@remotion/light-leaks';+import React from 'react';+import {AbsoluteFill, interpolate, useCurrentFrame, useVideoConfig} from 'remotion';++export const LightLeakAnimatedSize: React.FC = () => {+ const frame = useCurrentFrame();+ const {durationInFrames, width, height} = useVideoConfig();++ const scale = interpolate(+ frame,+ [0, durationInFrames / 2, durationInFrames - 1],+ [0.3, 1, 0.5],+ );++ const w = Math.round(width * scale);+ const h = Math.round(height * scale);++ return (+ <AbsoluteFill style={{backgroundColor: 'black'}}>+ <LightLeak+ durationInFrames={durationInFrames}+ seed={3}+ hueShift={30}+ width={w}+ height={h}+ />+ </AbsoluteFill>+ );+};diff --git a/packages/example/src/Root.tsx b/packages/example/src/Root.tsxindex d70461bb85..a8ead4949a 100644--- a/packages/example/src/Root.tsx+++ b/packages/example/src/Root.tsx@@ -156,6 +156,7 @@ import {RemotionMediaVideoTexture} from './VideoTexture';import {VisualControls} from './VisualControls';import {VoiceVisualization} from './voice-visualization';import {LightLeakExample} from './LightLeak';+import {LightLeakAnimatedSize} from './LightLeak/AnimatedSize';import {WhisperWeb} from './WhisperWeb';class Vector2 {@@ -1813,14 +1814,24 @@ export const Index: React.FC = () => {fps={30}durationInFrames={600}/>- <Composition- id="light-leak"- component={LightLeakExample}- width={1080}- height={1080}- fps={30}- durationInFrames={90}- />+ <Folder name="light-leaks">+ <Composition+ id="light-leak"+ component={LightLeakExample}+ width={1080}+ height={1080}+ fps={30}+ durationInFrames={90}+ />+ <Composition+ id="light-leak-animated-size"+ component={LightLeakAnimatedSize}+ width={1080}+ height={1080}+ fps={30}+ durationInFrames={120}+ />+ </Folder><ChangingTrimBeforeValue /><Compositionid="browser-test"diff --git a/packages/light-leaks/src/LightLeak.tsx b/packages/light-leaks/src/LightLeak.tsxindex 76eecda2aa..706b646b1b 100644--- a/packages/light-leaks/src/LightLeak.tsx+++ b/packages/light-leaks/src/LightLeak.tsx@@ -63,13 +63,14 @@ vec3 computePattern(vec2 uv, float s, float t) {void main(){- vec2 uv = 0.001 * gl_FragCoord.xy;+ 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 = 0.001 * resolution;+ 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;@@ -200,7 +201,7 @@ const LightLeakCanvas: React.FC<{hueShiftLoc,} = ctx;- const normalized = frame / (durationInFrames - 1);+ const normalized = durationInFrames <= 1 ? 0 : frame / (durationInFrames - 1);const evolveProgress = Math.min(1, normalized * 2);const retractProgress = Math.max(0, normalized * 2 - 1);@@ -214,7 +215,7 @@ const LightLeakCanvas: React.FC<{gl.uniform1f(hueShiftLoc, hueShift);gl.uniform2f(resLoc, gl.canvas.width, gl.canvas.height);gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);- }, [frame, durationInFrames, seed, hueShift]);+ }, [frame, durationInFrames, seed, hueShift, width, height]);return (<AbsoluteFill>