Skip to content

Production-ready animations, transitions, backgrounds, and scenes for Remotion

feat: ember burn

kapishdima12ca2bfc9451
diff --git a/components/docs/examples/ember-burn-example.tsx b/components/docs/examples/ember-burn-example.tsx
new file mode 100644
index 00000000..b9c60faa
--- /dev/null
+++ b/components/docs/examples/ember-burn-example.tsx
@@ -0,0 +1,100 @@
+"use client";
+
+import { linearTiming, TransitionSeries } from "@remotion/transitions";
+import { AbsoluteFill } from "remotion";
+import { emberBurn } from "@/registry/remocn/ember-burn";
+
+const FONT_FAMILY =
+ "var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif";
+
+function Scene({ label, background }: { label: string; background: string }) {
+ return (
+ <AbsoluteFill
+ style={{
+ background,
+ alignItems: "center",
+ justifyContent: "center",
+ }}
+ >
+ <span
+ style={{
+ fontFamily: FONT_FAMILY,
+ fontSize: 96,
+ fontWeight: 600,
+ letterSpacing: "-0.03em",
+ color: "#f2f2f2",
+ }}
+ >
+ {label}
+ </span>
+ </AbsoluteFill>
+ );
+}
+
+interface EmberBurnExampleProps {
+ patches?: number;
+ edgeSoftness?: number;
+ contentBias?: number;
+ heat?: number;
+ glowColor?: string;
+ emberAmount?: number;
+}
+
+export function EmberBurnExampleScene({
+ patches,
+ edgeSoftness,
+ contentBias,
+ heat,
+ glowColor,
+ emberAmount,
+}: EmberBurnExampleProps) {
+ return (
+ <TransitionSeries>
+ <TransitionSeries.Sequence durationInFrames={60}>
+ <Scene label="Scene A" background="#0a0a0a" />
+ </TransitionSeries.Sequence>
+ <TransitionSeries.Transition
+ timing={linearTiming({ durationInFrames: 40 })}
+ presentation={emberBurn({
+ patches,
+ edgeSoftness,
+ contentBias,
+ heat,
+ glowColor,
+ emberAmount,
+ })}
+ />
+ <TransitionSeries.Sequence durationInFrames={60}>
+ <Scene label="Scene B" background="#161014" />
+ </TransitionSeries.Sequence>
+ </TransitionSeries>
+ );
+}
+
+export const emberBurnExampleCode = (
+ values: Record<string, unknown>,
+): string => {
+ const patches = (values.patches as number) ?? 5;
+ const edgeSoftness = (values.edgeSoftness as number) ?? 0.07;
+ const contentBias = (values.contentBias as number) ?? 0.6;
+ const heat = (values.heat as number) ?? 0.5;
+ const glowColor = (values.glowColor as string) ?? "#ff7a2f";
+ const emberAmount = (values.emberAmount as number) ?? 0.5;
+ return `import { TransitionSeries, linearTiming } from "@remotion/transitions";
+import { emberBurn } from "@/components/remocn/ember-burn";
+
+export const MyVideo = () => (
+ <TransitionSeries>
+ <TransitionSeries.Sequence durationInFrames={60}>
+ <SceneA />
+ </TransitionSeries.Sequence>
+ <TransitionSeries.Transition
+ timing={linearTiming({ durationInFrames: 40 })}
+ presentation={emberBurn({ patches: ${patches}, edgeSoftness: ${edgeSoftness}, contentBias: ${contentBias}, heat: ${heat}, glowColor: "${glowColor}", emberAmount: ${emberAmount} })}
+ />
+ <TransitionSeries.Sequence durationInFrames={60}>
+ <SceneB />
+ </TransitionSeries.Sequence>
+ </TransitionSeries>
+);`;
+};
diff --git a/config/site.ts b/config/site.ts
index 34d06872..34131c24 100644
--- a/config/site.ts
+++ b/config/site.ts
@@ -84,6 +84,7 @@ export const NEW_BADGE_PATHS = new Set<string>([
"/docs/shaders/components/shader-weave",
"/docs/ui-blocks/reel",
"/docs/transitions/glitch-cut",
+ "/docs/transitions/ember-burn",
]);
export type FooterGroup = {
diff --git a/content/changelog/2026-08-02-canvas-transitions.mdx b/content/changelog/2026-08-02-canvas-transitions.mdx
index 7fac82af..b76c8177 100644
--- a/content/changelog/2026-08-02-canvas-transitions.mdx
+++ b/content/changelog/2026-08-02-canvas-transitions.mdx
@@ -10,6 +10,7 @@ Every transition in the catalog so far animates a scene from the outside — opa
### New components
- [Glitch Cut](/docs/transitions/glitch-cut) — the frame breaks into horizontal slices that slide apart, the colour channels separate, and blocks of the picture corrupt into the wrong scene. Each slice hands over to the incoming scene on its own beat around the midpoint, so the cut is torn rather than flat. Built for short timings — 12 frames is the recommended default.
+- [Ember Burn](/docs/transitions/ember-burn) — the outgoing frame catches fire where it is brightest, so a headline burns away before the background it sits on. Ahead of the flame the picture boils in the heat; at the rim it chars to black; behind it the frame blows away as sparks that carry the colour of the pixels they destroyed. Remotion's own `filmBurn()` is a different thing — a full-frame warm flash that never consumes the frame and never looks at what is in it — and the two can live in one project.
- Canvas Presentation — the shared scaffolding behind the category, installed alongside any canvas transition. It owns the support check, a full-screen WebGL2 scene shader that receives both sides of the cut as textures, and the routing that swaps in a CSS fallback where the browser has no html-in-canvas.
### Improvements
diff --git a/content/docs/components.mdx b/content/docs/components.mdx
index b9d45f34..adcea799 100644
--- a/content/docs/components.mdx
+++ b/content/docs/components.mdx
@@ -505,6 +505,12 @@ Scene transitions, camera moves, and stylized wipes.
status: "stable",
href: "/docs/transitions/glitch-cut",
},
+ {
+ name: "EmberBurn",
+ description: "Set the outgoing frame on fire so it boils, chars, and blows away as sparks that carry its own colour",
+ status: "stable",
+ href: "/docs/transitions/ember-burn",
+ },
]}
/>
diff --git a/content/docs/transitions/ember-burn.mdx b/content/docs/transitions/ember-burn.mdx
new file mode 100644
index 00000000..ee6fbe11
--- /dev/null
+++ b/content/docs/transitions/ember-burn.mdx
@@ -0,0 +1,167 @@
+---
+title: Ember Burn
+description: Set the outgoing frame on fire so it boils, chars, and blows away as sparks that carry its own colour
+component: ember-burn
+vibe: premium
+length: 40
+useWhen:
+ - "A scene change should feel cinematic and physical — the frame is destroyed rather than blended away."
+ - "The moment can afford well over a second; the burn is meant to be watched, not blinked through."
+ - "The outgoing scene has real content worth consuming — the fire takes the bright parts first, so text and highlights go before the background."
+avoidWhen:
+ - "The cut has to be quick — a burn compressed under 24 frames reads as a smear; use `zoom-blur`."
+ - "The scenes are cool-toned or clinical and a warm flare would fight the palette — use `grain-dissolve`."
+---
+
+<ComponentPreview name="ember-burn" />
+
+<CanvasTransitionNote />
+
+## Installation
+
+<InstallBlock name="ember-burn" />
+
+## Usage
+
+`emberBurn()` is a Remotion transition presentation. Pass it to a
+`TransitionSeries.Transition` between two sequences. The outgoing frame catches
+fire where it is brightest, boils in the heat just ahead of the flame, chars to
+black at the rim, and blows away as sparks that carry the colour of the pixels
+they destroyed. The burn accelerates as it spreads, so it starts as a few small
+holes and finishes in a rush.
+
+Give it room. `linearTiming({ durationInFrames: 40 })` is the recommended
+default — this is a transition you are meant to watch, and the detail that
+makes it work (the boil, the rim, the sparks) only registers if each part of
+the frame spends real time in the fire. Under about 24 frames it stops reading
+as fire and turns into a smear.
+
+```tsx
+import { TransitionSeries, linearTiming } from "@remotion/transitions";
+import { emberBurn } from "@/components/remocn/ember-burn";
+
+export const MyVideo = () => (
+ <TransitionSeries>
+ <TransitionSeries.Sequence durationInFrames={60}>
+ <SceneA />
+ </TransitionSeries.Sequence>
+ <TransitionSeries.Transition
+ timing={linearTiming({ durationInFrames: 40 })}
+ presentation={emberBurn()}
+ />
+ <TransitionSeries.Sequence durationInFrames={60}>
+ <SceneB />
+ </TransitionSeries.Sequence>
+ </TransitionSeries>
+);
+```
+
+## Why this one needs the canvas
+
+Three of its behaviours read the outgoing scene's actual pixels, and none of
+them can be approximated by masking a layer:
+
+- **The fire eats content, not a pattern.** The burn threshold is biased by the
+ luminance of the outgoing frame, so bright areas ignite first. A headline
+ burns away before the background it sits on. The mask is a function of the
+ scene, which is why it cannot be authored ahead of time.
+- **Heat refracts what has not burned yet.** Just ahead of the flame the
+ outgoing scene is sampled at a displaced coordinate, so the image boils and
+ swims before it goes.
+- **Sparks carry the colour they destroyed.** Each ember samples the frame from
+ the point it rose out of, so the frame comes apart into its own colours
+ instead of into generic orange dots.
+
+## The entrance mirrors the exit
+
+The incoming scene is not simply uncovered underneath the hole. It gets the
+same treatment as the outgoing one, with the sign flipped, so both halves of
+the cut carry the same event:
+
+| Outgoing scene | Incoming scene |
+| --- | --- |
+| Boils ahead of the rim | Boils just behind it, displaced the opposite way |
+| Chars to black as it leaves | Arrives incandescent and cools as it settles |
+
+Play the transition backwards and it reads as the same effect applied to the
+other scene. That symmetry is the whole point: without it the outgoing frame
+does all the work while the incoming one lies flat underneath, which reads as a
+hole punched in a picture rather than as one frame becoming another.
+
+`patches` is the knob that changes the character most: low values give a few
+large holes that swallow the frame in one gesture, high values a fine even burn.
+`contentBias` at 0 ignores the content and burns the frame as an abstract
+pattern; at 1 the fire is fully led by the picture.
+
+Remotion ships its own `filmBurn()` presentation in `@remotion/transitions`.
+That one is a full-frame warm flash — a light leak over a blurred crossfade,
+which never consumes the frame and never looks at what is in it. The two do not
+overlap, and both can live in one project.
+
+## Determinism
+
+The burn field, the heat shimmer, the char, the rims, and the ember drift are
+all pure functions of the transition's progress. The field is a value-noise fBm
+seeded on position and on the scene's own luminance; the shimmer and the spark
+drift advance with progress rather than with a clock — no wall-clock time, no
+state between frames. The same frame renders identically in every chunk of a
+parallel render.
+
+## Fallback
+
+Where html-in-canvas is unavailable the presentation renders a warm-flash
+crossfade: the incoming scene resolves through a flare of the glow colour that
+peaks at the middle of the cut. It keeps the timing and the colour, which is as
+close as CSS gets — every other part of this transition is defined by the
+outgoing scene's pixels. `glowColor` still applies there; the rest do not.
+
+## Props
+
+`emberBurn(props)` accepts:
+
+<PropsTable
+ rows={[
+ {
+ name: "patches",
+ type: "number",
+ default: "5",
+ description:
+ "How finely the burn breaks up across the frame. Low values open a few large holes, high values a fine even burn closer to a textured dissolve.",
+ },
+ {
+ name: "edgeSoftness",
+ type: "number",
+ default: "0.07",
+ description:
+ "Width of the burning rim as a fraction of the frame. This is the second pacing knob: a wider band keeps each part of the frame in the fire for longer, so raise it if the burn reads as too quick even at a generous duration.",
+ },
+ {
+ name: "contentBias",
+ type: "number",
+ default: "0.6",
+ description:
+ "How strongly the fire follows the outgoing scene's brightness. 0 burns the frame as an abstract pattern; 1 lets the picture lead entirely, so highlights go first.",
+ },
+ {
+ name: "heat",
+ type: "number",
+ default: "0.5",
+ description:
+ "Strength of the refraction ahead of the flame. 0 keeps the unburnt image sharp right up to the rim.",
+ },
+ {
+ name: "glowColor",
+ type: "string",
+ default: '"#ff7a2f"',
+ description:
+ "Colour of the rims, the afterglow, and the light the sparks add on top of the colour they carry. Set it to a brand accent to tint the whole burn.",
+ },
+ {
+ name: "emberAmount",
+ type: "number",
+ default: "0.5",
+ description:
+ "Density of the sparks rising out of the burn. 0 leaves a clean burn with only the glowing edges.",
+ },
+ ]}
+/>
diff --git a/content/docs/transitions/index.mdx b/content/docs/transitions/index.mdx
index 0a511d4d..8bf626c8 100644
--- a/content/docs/transitions/index.mdx
+++ b/content/docs/transitions/index.mdx
@@ -134,6 +134,12 @@ Pixel-level transitions. These read the actual pixels of both scenes through the
status: "stable",
href: "/docs/transitions/glitch-cut",
},
+ {
+ name: "EmberBurn",
+ description: "Set the outgoing frame on fire so it boils, chars, and blows away as sparks that carry its own colour",
+ status: "stable",
+ href: "/docs/transitions/ember-burn",
+ },
]}
/>
diff --git a/content/docs/transitions/meta.json b/content/docs/transitions/meta.json
index a6592d20..af4157f5 100644
--- a/content/docs/transitions/meta.json
+++ b/content/docs/transitions/meta.json
@@ -20,6 +20,7 @@
"caret-wipe",
"icon-scatter",
"glitch-cut",
+ "ember-burn",
"slide-swap",
"spring-settle"
]
diff --git a/registry-artifacts/canvas-presentation.json b/registry-artifacts/canvas-presentation.json
index ae802f48..4b2924d9 100644
--- a/registry-artifacts/canvas-presentation.json
+++ b/registry-artifacts/canvas-presentation.json
@@ -7,7 +7,7 @@
"files": [
{
"path": "registry/remocn/canvas-presentation/index.tsx",
- "content": "\"use client\";\n\nimport type {\n TransitionPresentation,\n TransitionPresentationComponentProps,\n} from \"@remotion/transitions\";\nimport React from \"react\";\nimport {\n AbsoluteFill,\n isHtmlInCanvasSupported,\n useDelayRender,\n} from \"remotion\";\n\nconst QUAD = new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]);\n\nconst VERTEX_SHADER = `#version 300 es\nin vec2 a_pos;\nout vec2 v_uv;\nvoid main() {\n v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}`;\n\nconst LAYER: React.CSSProperties = {\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n};\n\nconst OUTPUT_LAYER: React.CSSProperties = { ...LAYER, pointerEvents: \"none\" };\n\nexport const isCanvasTransitionSupported = (): boolean =>\n isHtmlInCanvasSupported();\n\nexport type SceneShaderFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\nexport type SceneShaderDrawParams<Props> = {\n from: OffscreenCanvas | null;\n to: OffscreenCanvas | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\nexport type SceneShaderInstance<Props> = {\n draw: (params: SceneShaderDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\nexport type SceneShader<Props> = (\n canvas: OffscreenCanvas,\n) => SceneShaderInstance<Props>;\n\nfunction compileShader(\n gl: WebGL2RenderingContext,\n source: string,\n type: GLenum,\n): WebGLShader {\n const shader = gl.createShader(type);\n if (!shader) {\n throw new Error(\"canvas-presentation: failed to create shader\");\n }\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`canvas-presentation: failed to compile shader: ${log}`);\n }\n return shader;\n}\n\nfunction createProgram(\n gl: WebGL2RenderingContext,\n fragment: string,\n): WebGLProgram {\n const program = gl.createProgram();\n if (!program) {\n throw new Error(\"canvas-presentation: failed to create program\");\n }\n const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);\n const fs = compileShader(gl, fragment, gl.FRAGMENT_SHADER);\n gl.attachShader(program, vs);\n gl.attachShader(program, fs);\n gl.linkProgram(program);\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const log = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw new Error(`canvas-presentation: failed to link program: ${log}`);\n }\n return program;\n}\n\nfunction createSceneTexture(gl: WebGL2RenderingContext): WebGLTexture {\n const texture = gl.createTexture();\n if (!texture) {\n throw new Error(\"canvas-presentation: failed to create texture\");\n }\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n 1,\n 1,\n 0,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n new Uint8Array([0, 0, 0, 0]),\n );\n return texture;\n}\n\nexport function makeSceneShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneShaderFrame<Props>) => void,\n): SceneShader<Props> {\n return (canvas) => {\n const gl = canvas.getContext(\"webgl2\", { premultipliedAlpha: true });\n if (!gl) {\n throw new Error(\"canvas-presentation: WebGL2 is unavailable\");\n }\n\n const program = createProgram(gl, fragment);\n const fromTexture = createSceneTexture(gl);\n const toTexture = createSceneTexture(gl);\n const vao = gl.createVertexArray();\n gl.bindVertexArray(vao);\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.bufferData(gl.ARRAY_BUFFER, QUAD, gl.STATIC_DRAW);\n const aPos = gl.getAttribLocation(program, \"a_pos\");\n gl.enableVertexAttribArray(aPos);\n gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);\n\n const locations = new Map<string, WebGLUniformLocation | null>();\n const uniform = (name: string) => {\n const cached = locations.get(name);\n if (cached !== undefined) {\n return cached;\n }\n const location = gl.getUniformLocation(program, name);\n locations.set(name, location);\n return location;\n };\n\n const clear = () => {\n gl.clearColor(0, 0, 0, 0);\n gl.clear(gl.COLOR_BUFFER_BIT);\n };\n\n const bindScene = (\n image: OffscreenCanvas | null,\n texture: WebGLTexture,\n unit: number,\n name: string,\n ) => {\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n if (image) {\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n image,\n );\n }\n gl.uniform1i(uniform(name), unit);\n };\n\n return {\n clear,\n cleanup: () => {\n gl.deleteProgram(program);\n gl.deleteTexture(fromTexture);\n gl.deleteTexture(toTexture);\n gl.deleteBuffer(buffer);\n gl.deleteVertexArray(vao);\n },\n draw: ({ from, to, width, height, progress, passedProps }) => {\n gl.viewport(0, 0, width, height);\n clear();\n gl.useProgram(program);\n gl.bindVertexArray(vao);\n\n bindScene(from, fromTexture, 0, \"u_from\");\n bindScene(to, toTexture, 1, \"u_to\");\n\n gl.uniform1f(uniform(\"u_progress\"), progress);\n gl.uniform1f(uniform(\"u_aspect\"), width / height);\n setUniforms?.({ gl, uniform, width, height, progress, passedProps });\n\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n },\n };\n };\n}\n\nconst transferred = new WeakMap<HTMLCanvasElement, OffscreenCanvas>();\n\nfunction takeOffscreen(canvas: HTMLCanvasElement): OffscreenCanvas {\n const existing = transferred.get(canvas);\n if (existing) {\n return existing;\n }\n const created = canvas.transferControlToOffscreen();\n transferred.set(canvas, created);\n return created;\n}\n\nfunction makeCanvasComponent<Props extends Record<string, unknown>>(\n shader: SceneShader<Props>,\n): React.FC<TransitionPresentationComponentProps<Props>> {\n return function CanvasScenePresentation({\n children,\n presentationProgress,\n presentationDirection,\n passedProps,\n onElementImage,\n onUnmount,\n bothEnteringAndExiting,\n }) {\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneShaderInstance<Props> | null>(null);\n const passedPropsRef = React.useRef(passedProps);\n passedPropsRef.current = passedProps;\n\n const { delayRender, continueRender } = useDelayRender();\n const passThrough =\n bothEnteringAndExiting && presentationDirection === \"exiting\";\n\n const draw = React.useCallback(\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => {\n const instance = instanceRef.current;\n if (!instance) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: paint\");\n const to = prevImage;\n const from = nextImage;\n const width = from?.width ?? to?.width ?? 0;\n const height = from?.height ?? to?.height ?? 0;\n if (width === 0 || height === 0) {\n instance.clear();\n continueRender(handle);\n return;\n }\n instance.draw({\n from,\n to,\n width,\n height,\n progress: !to ? 0 : !from ? 1 : progress,\n passedProps: passedPropsRef.current,\n });\n continueRender(handle);\n },\n [delayRender, continueRender],\n );\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [passThrough, shader]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n if (!scene || !capture || !context) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n onElementImage(capture, draw);\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, [passThrough, onElementImage, draw]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, [passThrough]);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: presentationProgress is the intentional trigger — a new progress value is what schedules the next paint\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n layoutRef.current?.requestPaint?.();\n }, [passThrough, presentationProgress]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n return () => onUnmount();\n }, [passThrough, onUnmount]);\n\n if (passThrough) {\n return <>{children}</>;\n }\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\nexport type CanvasPresentationOptions<Props extends Record<string, unknown>> = {\n shader: SceneShader<Props>;\n fallback: React.FC<TransitionPresentationComponentProps<Props>>;\n};\n\nexport function makeCanvasPresentation<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasPresentationOptions<Props>): (\n props: Props,\n) => TransitionPresentation<Props> {\n const Canvas = makeCanvasComponent(shader);\n\n const Presentation: React.FC<TransitionPresentationComponentProps<Props>> = (\n props,\n ) =>\n isCanvasTransitionSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n\n return (props) => ({ component: Presentation, props });\n}\n",
+ "content": "\"use client\";\n\nimport type {\n TransitionPresentation,\n TransitionPresentationComponentProps,\n} from \"@remotion/transitions\";\nimport React from \"react\";\nimport {\n AbsoluteFill,\n isHtmlInCanvasSupported,\n useDelayRender,\n} from \"remotion\";\n\nconst QUAD = new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]);\n\nconst VERTEX_SHADER = `#version 300 es\nin vec2 a_pos;\nout vec2 v_uv;\nvoid main() {\n v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}`;\n\nconst LAYER: React.CSSProperties = {\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n};\n\nconst OUTPUT_LAYER: React.CSSProperties = { ...LAYER, pointerEvents: \"none\" };\n\nexport const isCanvasTransitionSupported = (): boolean =>\n isHtmlInCanvasSupported();\n\nexport type SceneShaderFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\nexport type SceneShaderDrawParams<Props> = {\n from: OffscreenCanvas | null;\n to: OffscreenCanvas | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\nexport type SceneShaderInstance<Props> = {\n draw: (params: SceneShaderDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\nexport type SceneShader<Props> = (\n canvas: OffscreenCanvas,\n) => SceneShaderInstance<Props>;\n\nfunction compileShader(\n gl: WebGL2RenderingContext,\n source: string,\n type: GLenum,\n): WebGLShader {\n const shader = gl.createShader(type);\n if (!shader) {\n throw new Error(\"canvas-presentation: failed to create shader\");\n }\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`canvas-presentation: failed to compile shader: ${log}`);\n }\n return shader;\n}\n\nfunction createProgram(\n gl: WebGL2RenderingContext,\n fragment: string,\n): WebGLProgram {\n const program = gl.createProgram();\n if (!program) {\n throw new Error(\"canvas-presentation: failed to create program\");\n }\n const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);\n const fs = compileShader(gl, fragment, gl.FRAGMENT_SHADER);\n gl.attachShader(program, vs);\n gl.attachShader(program, fs);\n gl.linkProgram(program);\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const log = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw new Error(`canvas-presentation: failed to link program: ${log}`);\n }\n return program;\n}\n\nfunction createSceneTexture(gl: WebGL2RenderingContext): WebGLTexture {\n const texture = gl.createTexture();\n if (!texture) {\n throw new Error(\"canvas-presentation: failed to create texture\");\n }\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n 1,\n 1,\n 0,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n new Uint8Array([0, 0, 0, 0]),\n );\n return texture;\n}\n\nexport function makeSceneShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneShaderFrame<Props>) => void,\n): SceneShader<Props> {\n return (canvas) => {\n const gl = canvas.getContext(\"webgl2\", { premultipliedAlpha: true });\n if (!gl) {\n throw new Error(\"canvas-presentation: WebGL2 is unavailable\");\n }\n\n const program = createProgram(gl, fragment);\n const fromTexture = createSceneTexture(gl);\n const toTexture = createSceneTexture(gl);\n const vao = gl.createVertexArray();\n gl.bindVertexArray(vao);\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.bufferData(gl.ARRAY_BUFFER, QUAD, gl.STATIC_DRAW);\n const aPos = gl.getAttribLocation(program, \"a_pos\");\n gl.enableVertexAttribArray(aPos);\n gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);\n\n const locations = new Map<string, WebGLUniformLocation | null>();\n const uniform = (name: string) => {\n const cached = locations.get(name);\n if (cached !== undefined) {\n return cached;\n }\n const location = gl.getUniformLocation(program, name);\n locations.set(name, location);\n return location;\n };\n\n const clear = () => {\n gl.clearColor(0, 0, 0, 0);\n gl.clear(gl.COLOR_BUFFER_BIT);\n };\n\n const bindScene = (\n image: OffscreenCanvas | null,\n texture: WebGLTexture,\n unit: number,\n name: string,\n ) => {\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n if (image) {\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n image,\n );\n }\n gl.uniform1i(uniform(name), unit);\n };\n\n return {\n clear,\n cleanup: () => {\n gl.deleteProgram(program);\n gl.deleteTexture(fromTexture);\n gl.deleteTexture(toTexture);\n gl.deleteBuffer(buffer);\n gl.deleteVertexArray(vao);\n },\n draw: ({ from, to, width, height, progress, passedProps }) => {\n gl.viewport(0, 0, width, height);\n clear();\n gl.useProgram(program);\n gl.bindVertexArray(vao);\n\n bindScene(from, fromTexture, 0, \"u_from\");\n bindScene(to, toTexture, 1, \"u_to\");\n\n gl.uniform1f(uniform(\"u_progress\"), progress);\n gl.uniform1f(uniform(\"u_aspect\"), width / height);\n setUniforms?.({ gl, uniform, width, height, progress, passedProps });\n\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n },\n };\n };\n}\n\nconst transferred = new WeakMap<HTMLCanvasElement, OffscreenCanvas>();\n\nfunction takeOffscreen(canvas: HTMLCanvasElement): OffscreenCanvas {\n const existing = transferred.get(canvas);\n if (existing) {\n return existing;\n }\n const created = canvas.transferControlToOffscreen();\n transferred.set(canvas, created);\n return created;\n}\n\nfunction makeCanvasComponent<Props extends Record<string, unknown>>(\n shader: SceneShader<Props>,\n): React.FC<TransitionPresentationComponentProps<Props>> {\n return function CanvasScenePresentation({\n children,\n presentationProgress,\n presentationDirection,\n passedProps,\n onElementImage,\n onUnmount,\n bothEnteringAndExiting,\n }) {\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneShaderInstance<Props> | null>(null);\n const passedPropsRef = React.useRef(passedProps);\n passedPropsRef.current = passedProps;\n const onElementImageRef = React.useRef(onElementImage);\n onElementImageRef.current = onElementImage;\n const onUnmountRef = React.useRef(onUnmount);\n onUnmountRef.current = onUnmount;\n\n const { delayRender, continueRender } = useDelayRender();\n const passThrough =\n bothEnteringAndExiting && presentationDirection === \"exiting\";\n\n const drawRef = React.useRef<\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => void\n >(() => undefined);\n drawRef.current = (prevImage, nextImage, progress) => {\n const instance = instanceRef.current;\n if (!instance) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: paint\");\n const to = prevImage;\n const from = nextImage;\n const width = from?.width ?? to?.width ?? 0;\n const height = from?.height ?? to?.height ?? 0;\n if (width === 0 || height === 0) {\n instance.clear();\n continueRender(handle);\n return;\n }\n instance.draw({\n from,\n to,\n width,\n height,\n progress: !to ? 0 : !from ? 1 : progress,\n passedProps: passedPropsRef.current,\n });\n continueRender(handle);\n };\n\n const draw = React.useCallback(\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => drawRef.current(prevImage, nextImage, progress),\n [],\n );\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [passThrough, shader]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n if (!scene || !capture || !context) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n onElementImageRef.current(capture, draw);\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, [passThrough, draw]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, [passThrough]);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: presentationProgress is the intentional trigger — a new progress value is what schedules the next paint\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n layoutRef.current?.requestPaint?.();\n }, [passThrough, presentationProgress]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n return () => onUnmountRef.current();\n }, [passThrough]);\n\n if (passThrough) {\n return <>{children}</>;\n }\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\nexport type CanvasPresentationOptions<Props extends Record<string, unknown>> = {\n shader: SceneShader<Props>;\n fallback: React.FC<TransitionPresentationComponentProps<Props>>;\n};\n\nexport function makeCanvasPresentation<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasPresentationOptions<Props>): (\n props: Props,\n) => TransitionPresentation<Props> {\n const Canvas = makeCanvasComponent(shader);\n\n const Presentation: React.FC<TransitionPresentationComponentProps<Props>> = (\n props,\n ) =>\n isCanvasTransitionSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n\n return (props) => ({ component: Presentation, props });\n}\n",
"type": "registry:lib",
"target": "lib/remocn/canvas-presentation.tsx"
}
diff --git a/registry-artifacts/ember-burn.json b/registry-artifacts/ember-burn.json
new file mode 100644
index 00000000..60e8cd57
--- /dev/null
+++ b/registry-artifacts/ember-burn.json
@@ -0,0 +1,17 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "ember-burn",
+ "title": "Ember Burn",
+ "description": "The outgoing frame catches fire where it is brightest, boils in the heat, chars at the rim, and blows away as sparks carrying its own colour.",
+ "dependencies": ["remotion", "@remotion/transitions"],
+ "registryDependencies": ["@remocn/canvas-presentation"],
+ "files": [
+ {
+ "path": "registry/remocn/ember-burn/index.tsx",
+ "content": "\"use client\";\n\nimport type {\n TransitionPresentation,\n TransitionPresentationComponentProps,\n} from \"@remotion/transitions\";\nimport type React from \"react\";\nimport { AbsoluteFill } from \"remotion\";\nimport {\n makeCanvasPresentation,\n makeSceneShader,\n} from \"@/lib/remocn/canvas-presentation\";\n\nexport type EmberBurnProps = {\n patches?: number;\n edgeSoftness?: number;\n contentBias?: number;\n heat?: number;\n glowColor?: string;\n emberAmount?: number;\n};\n\nconst DEFAULTS = {\n patches: 5,\n edgeSoftness: 0.07,\n contentBias: 0.6,\n heat: 0.5,\n glowColor: \"#ff7a2f\",\n emberAmount: 0.5,\n};\n\nfunction hexToRgb(hex: string): [number, number, number] {\n const value = hex.replace(\"#\", \"\");\n const full =\n value.length === 3\n ? value\n .split(\"\")\n .map((c) => c + c)\n .join(\"\")\n : value;\n const int = Number.parseInt(full, 16);\n if (Number.isNaN(int)) {\n return [1, 0.48, 0.18];\n }\n return [\n ((int >> 16) & 255) / 255,\n ((int >> 8) & 255) / 255,\n (int & 255) / 255,\n ];\n}\n\nconst FRAGMENT_SHADER = `#version 300 es\nprecision highp float;\n\nuniform sampler2D u_from;\nuniform sampler2D u_to;\nuniform float u_progress;\nuniform float u_aspect;\nuniform float u_patches;\nuniform float u_softness;\nuniform float u_content;\nuniform float u_heat;\nuniform vec3 u_glow;\nuniform float u_embers;\n\nin vec2 v_uv;\nout vec4 outColor;\n\nconst float EMBER_GRID = 110.0;\n\nfloat hash(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);\n}\n\nfloat noise(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n vec2 u = f * f * (3.0 - 2.0 * f);\n return mix(\n mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x),\n mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x),\n u.y\n );\n}\n\nfloat fbm(vec2 p) {\n float sum = 0.0;\n float amp = 0.5;\n for (int i = 0; i < 5; i++) {\n sum += noise(p) * amp;\n p *= 2.03;\n amp *= 0.5;\n }\n return sum * 1.032;\n}\n\nfloat luma(vec3 c) {\n return dot(c, vec3(0.2126, 0.7152, 0.0722));\n}\n\nvoid main() {\n vec2 skewed = vec2(v_uv.x * u_aspect, v_uv.y);\n float alive =\n smoothstep(0.0, 0.06, u_progress) * smoothstep(1.0, 0.94, u_progress);\n\n float brightness = luma(texture(u_from, v_uv).rgb);\n float field = clamp(\n clamp(fbm(skewed * u_patches), 0.0, 1.0) *\n (1.0 - u_content * brightness * 0.9),\n 0.0,\n 1.0\n );\n\n float soft = max(u_softness, 0.004);\n float margin = soft * 3.0 + 0.02;\n float front = mix(-margin, 1.0 + margin, pow(u_progress, 1.2));\n float depth = field - front;\n\n float intact = smoothstep(-soft, soft, depth);\n float arrived = 1.0 - intact;\n\n vec2 shimmer = vec2(\n noise(skewed * u_patches * 2.4 + vec2(0.0, u_progress * 3.1)) - 0.5,\n noise(skewed * u_patches * 2.4 + vec2(5.2, 1.7 + u_progress * 4.3)) - 0.5\n );\n float boil = exp(-pow(depth / (soft * 6.0), 2.0)) * alive * u_heat * 0.14;\n vec4 from = texture(u_from, v_uv + shimmer * boil * intact);\n vec4 to = texture(u_to, v_uv - shimmer * boil * arrived);\n\n float ramp = depth / (soft * 2.2);\n float charred = intact * exp(-pow((ramp - 0.55) * 1.5, 2.0)) * alive;\n float molten = arrived * exp(-pow((ramp + 0.55) * 1.5, 2.0)) * alive;\n float rim = exp(-pow(depth / (soft * 1.1), 2.0));\n\n float since = clamp(-depth / (soft * 3.0), 0.0, 1.0);\n vec2 emberSpace = skewed + vec2(0.0, u_progress * 0.42);\n float cellSeed = hash(floor(emberSpace * EMBER_GRID));\n float ember =\n step(1.0 - u_embers * 0.08, cellSeed) *\n arrived *\n exp(-pow(depth / (soft * 2.6), 2.0)) *\n alive;\n vec3 sparkSource = texture(u_from, v_uv + vec2(0.0, since * 0.07)).rgb;\n\n vec4 color = mix(to, from, intact);\n color.rgb *= 1.0 - charred * 0.92;\n color.rgb += (color.rgb * 1.2 + u_glow * 0.6) * molten;\n\n vec3 spark = mix(u_glow, sparkSource * 1.4 + u_glow * 0.3, 0.5);\n float light = min(rim * 0.85, 1.4);\n color.rgb += u_glow * light + spark * ember * 1.3;\n color.a = clamp(color.a + light + molten + ember, 0.0, 1.0);\n\n outColor = color;\n}`;\n\nconst shader = makeSceneShader<EmberBurnProps>(\n FRAGMENT_SHADER,\n ({ gl, uniform, passedProps }) => {\n const {\n patches = DEFAULTS.patches,\n edgeSoftness = DEFAULTS.edgeSoftness,\n contentBias = DEFAULTS.contentBias,\n heat = DEFAULTS.heat,\n glowColor = DEFAULTS.glowColor,\n emberAmount = DEFAULTS.emberAmount,\n } = passedProps;\n const glow = hexToRgb(glowColor);\n gl.uniform1f(uniform(\"u_patches\"), patches);\n gl.uniform1f(uniform(\"u_softness\"), edgeSoftness);\n gl.uniform1f(uniform(\"u_content\"), contentBias);\n gl.uniform1f(uniform(\"u_heat\"), heat);\n gl.uniform3f(uniform(\"u_glow\"), glow[0], glow[1], glow[2]);\n gl.uniform1f(uniform(\"u_embers\"), emberAmount);\n },\n);\n\nconst EmberBurnFallback: React.FC<\n TransitionPresentationComponentProps<EmberBurnProps>\n> = ({\n children,\n presentationProgress,\n presentationDirection,\n passedProps,\n}) => {\n const { glowColor = DEFAULTS.glowColor } = passedProps;\n\n if (presentationDirection === \"exiting\") {\n return <AbsoluteFill>{children}</AbsoluteFill>;\n }\n\n const p = presentationProgress;\n const reveal = Math.min(1, Math.max(0, (p - 0.25) / 0.5));\n const flash = Math.max(0, Math.sin(p * Math.PI)) ** 0.6 * 0.4;\n\n return (\n <AbsoluteFill>\n <AbsoluteFill style={{ opacity: reveal }}>{children}</AbsoluteFill>\n <AbsoluteFill\n style={{\n background: glowColor,\n mixBlendMode: \"screen\",\n opacity: flash,\n pointerEvents: \"none\",\n }}\n />\n </AbsoluteFill>\n );\n};\n\nconst presentation = makeCanvasPresentation<EmberBurnProps>({\n shader,\n fallback: EmberBurnFallback,\n});\n\nexport function emberBurn(\n props: EmberBurnProps = {},\n): TransitionPresentation<EmberBurnProps> {\n return presentation(props);\n}\n",
+ "type": "registry:component",
+ "target": "components/remocn/ember-burn.tsx"
+ }
+ ],
+ "type": "registry:component"
+}
diff --git a/registry-artifacts/registry.json b/registry-artifacts/registry.json
index 720cf7d9..1ea6fbb6 100644
--- a/registry-artifacts/registry.json
+++ b/registry-artifacts/registry.json
@@ -1644,6 +1644,21 @@
],
"type": "registry:lib"
},
+ {
+ "name": "ember-burn",
+ "title": "Ember Burn",
+ "description": "The outgoing frame catches fire where it is brightest, boils in the heat, chars at the rim, and blows away as sparks carrying its own colour.",
+ "dependencies": ["remotion", "@remotion/transitions"],
+ "registryDependencies": ["@remocn/canvas-presentation"],
+ "files": [
+ {
+ "path": "registry/remocn/ember-burn/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/ember-burn.tsx"
+ }
+ ],
+ "type": "registry:component"
+ },
{
"name": "glitch-cut",
"title": "Glitch Cut",
diff --git a/registry/__index__.tsx b/registry/__index__.tsx
index b79e5cc6..7c87d312 100644
--- a/registry/__index__.tsx
+++ b/registry/__index__.tsx
@@ -19,6 +19,7 @@ import { dataFlowPipesConfig } from "@/registry/remocn/data-flow-pipes/config";
import { ditherDissolveConfig } from "@/registry/remocn/dither-dissolve/config";
import { driftConfig } from "@/registry/remocn/drift/config";
import { ecosystemConstellationConfig } from "@/registry/remocn/ecosystem-constellation/config";
+import { emberBurnConfig } from "@/registry/remocn/ember-burn/config";
import { fadeThroughConfig } from "@/registry/remocn/fade-through/config";
import { focusBlurResolveConfig } from "@/registry/remocn/focus-blur-resolve/config";
import { focusPullConfig } from "@/registry/remocn/focus-pull/config";
@@ -1425,6 +1426,13 @@ const registry: Record<string, RegistryEntry> = {
})),
config: glitchCutConfig,
},
+ "ember-burn": {
+ load: () =>
+ import("@/components/docs/examples/ember-burn-example").then((m) => ({
+ default: m.EmberBurnExampleScene,
+ })),
+ config: emberBurnConfig,
+ },
"slide-swap": {
load: () =>
import("@/components/docs/examples/slide-swap-example").then((m) => ({
diff --git a/registry/remocn/canvas-presentation/index.tsx b/registry/remocn/canvas-presentation/index.tsx
index 587d7501..7286f5f5 100644
--- a/registry/remocn/canvas-presentation/index.tsx
+++ b/registry/remocn/canvas-presentation/index.tsx
@@ -247,42 +247,55 @@ function makeCanvasComponent<Props extends Record<string, unknown>>(
const instanceRef = React.useRef<SceneShaderInstance<Props> | null>(null);
const passedPropsRef = React.useRef(passedProps);
passedPropsRef.current = passedProps;
+ const onElementImageRef = React.useRef(onElementImage);
+ onElementImageRef.current = onElementImage;
+ const onUnmountRef = React.useRef(onUnmount);
+ onUnmountRef.current = onUnmount;
const { delayRender, continueRender } = useDelayRender();
const passThrough =
bothEnteringAndExiting && presentationDirection === "exiting";
- const draw = React.useCallback(
+ const drawRef = React.useRef<
(
prevImage: OffscreenCanvas | null,
nextImage: OffscreenCanvas | null,
progress: number,
- ) => {
- const instance = instanceRef.current;
- if (!instance) {
- return;
- }
- const handle = delayRender("canvas-presentation: paint");
- const to = prevImage;
- const from = nextImage;
- const width = from?.width ?? to?.width ?? 0;
- const height = from?.height ?? to?.height ?? 0;
- if (width === 0 || height === 0) {
- instance.clear();
- continueRender(handle);
- return;
- }
- instance.draw({
- from,
- to,
- width,
- height,
- progress: !to ? 0 : !from ? 1 : progress,
- passedProps: passedPropsRef.current,
- });
+ ) => void
+ >(() => undefined);
+ drawRef.current = (prevImage, nextImage, progress) => {
+ const instance = instanceRef.current;
+ if (!instance) {
+ return;
+ }
+ const handle = delayRender("canvas-presentation: paint");
+ const to = prevImage;
+ const from = nextImage;
+ const width = from?.width ?? to?.width ?? 0;
+ const height = from?.height ?? to?.height ?? 0;
+ if (width === 0 || height === 0) {
+ instance.clear();
continueRender(handle);
- },
- [delayRender, continueRender],
+ return;
+ }
+ instance.draw({
+ from,
+ to,
+ width,
+ height,
+ progress: !to ? 0 : !from ? 1 : progress,
+ passedProps: passedPropsRef.current,
+ });
+ continueRender(handle);
+ };
+
+ const draw = React.useCallback(
+ (
+ prevImage: OffscreenCanvas | null,
+ nextImage: OffscreenCanvas | null,
+ progress: number,
+ ) => drawRef.current(prevImage, nextImage, progress),
+ [],
);
React.useLayoutEffect(() => {
@@ -337,11 +350,11 @@ function makeCanvasComponent<Props extends Record<string, unknown>>(
} finally {
elementImage.close();
}
- onElementImage(capture, draw);
+ onElementImageRef.current(capture, draw);
};
layout.addEventListener("paint", handlePaint);
return () => layout.removeEventListener("paint", handlePaint);
- }, [passThrough, onElementImage, draw]);
+ }, [passThrough, draw]);
React.useLayoutEffect(() => {
if (passThrough) {
@@ -381,8 +394,8 @@ function makeCanvasComponent<Props extends Record<string, unknown>>(
if (passThrough) {
return;
}
- return () => onUnmount();
- }, [passThrough, onUnmount]);
+ return () => onUnmountRef.current();
+ }, [passThrough]);
if (passThrough) {
return <>{children}</>;
diff --git a/registry/remocn/ember-burn/config.ts b/registry/remocn/ember-burn/config.ts
new file mode 100644
index 00000000..65e6bcf4
--- /dev/null
+++ b/registry/remocn/ember-burn/config.ts
@@ -0,0 +1,56 @@
+import { emberBurnExampleCode } from "@/components/docs/examples/ember-burn-example";
+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";
+
+export const emberBurnConfig: ComponentConfig = {
+ componentName: "emberBurn",
+ importPath: "@/components/remocn/ember-burn",
+ controls: {
+ patches: {
+ type: "number",
+ default: 5,
+ min: 2,
+ max: 16,
+ step: 1,
+ label: "Patches",
+ },
+ edgeSoftness: {
+ type: "number",
+ default: 0.07,
+ min: 0.005,
+ max: 0.2,
+ step: 0.005,
+ label: "Edge softness",
+ },
+ contentBias: {
+ type: "number",
+ default: 0.6,
+ min: 0,
+ max: 1,
+ step: 0.05,
+ label: "Eats bright first",
+ },
+ heat: {
+ type: "number",
+ default: 0.5,
+ min: 0,
+ max: 1.5,
+ step: 0.05,
+ label: "Heat distortion",
+ },
+ glowColor: { type: "color", default: "#ff7a2f", label: "Glow" },
+ emberAmount: {
+ type: "number",
+ default: 0.5,
+ min: 0,
+ max: 1,
+ step: 0.05,
+ label: "Embers",
+ },
+ },
+ durationInFrames: 80,
+ fps: FPS,
+ compositionWidth: W,
+ compositionHeight: H,
+ previewBackdrop: { type: "color", value: "#0a0a0a" },
+ snippet: emberBurnExampleCode,
+};
diff --git a/registry/remocn/ember-burn/index.tsx b/registry/remocn/ember-burn/index.tsx
new file mode 100644
index 00000000..eceaacd6
--- /dev/null
+++ b/registry/remocn/ember-burn/index.tsx
@@ -0,0 +1,220 @@
+"use client";
+
+import type {
+ TransitionPresentation,
+ TransitionPresentationComponentProps,
+} from "@remotion/transitions";
+import type React from "react";
+import { AbsoluteFill } from "remotion";
+import {
+ makeCanvasPresentation,
+ makeSceneShader,
+} from "@/lib/remocn/canvas-presentation";
+
+export type EmberBurnProps = {
+ patches?: number;
+ edgeSoftness?: number;
+ contentBias?: number;
+ heat?: number;
+ glowColor?: string;
+ emberAmount?: number;
+};
+
+const DEFAULTS = {
+ patches: 5,
+ edgeSoftness: 0.07,
+ contentBias: 0.6,
+ heat: 0.5,
+ glowColor: "#ff7a2f",
+ emberAmount: 0.5,
+};
+
+function hexToRgb(hex: string): [number, number, number] {
+ const value = hex.replace("#", "");
+ const full =
+ value.length === 3
+ ? value
+ .split("")
+ .map((c) => c + c)
+ .join("")
+ : value;
+ const int = Number.parseInt(full, 16);
+ if (Number.isNaN(int)) {
+ return [1, 0.48, 0.18];
+ }
+ return [
+ ((int >> 16) & 255) / 255,
+ ((int >> 8) & 255) / 255,
+ (int & 255) / 255,
+ ];
+}
+
+const FRAGMENT_SHADER = `#version 300 es
+precision highp float;
+
+uniform sampler2D u_from;
+uniform sampler2D u_to;
+uniform float u_progress;
+uniform float u_aspect;
+uniform float u_patches;
+uniform float u_softness;
+uniform float u_content;
+uniform float u_heat;
+uniform vec3 u_glow;
+uniform float u_embers;
+
+in vec2 v_uv;
+out vec4 outColor;
+
+const float EMBER_GRID = 110.0;
+
+float hash(vec2 p) {
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
+}
+
+float noise(vec2 p) {
+ vec2 i = floor(p);
+ vec2 f = fract(p);
+ vec2 u = f * f * (3.0 - 2.0 * f);
+ return mix(
+ mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x),
+ mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x),
+ u.y
+ );
+}
+
+float fbm(vec2 p) {
+ float sum = 0.0;
+ float amp = 0.5;
+ for (int i = 0; i < 5; i++) {
+ sum += noise(p) * amp;
+ p *= 2.03;
+ amp *= 0.5;
+ }
+ return sum * 1.032;
+}
+
+float luma(vec3 c) {
+ return dot(c, vec3(0.2126, 0.7152, 0.0722));
+}
+
+void main() {
+ vec2 skewed = vec2(v_uv.x * u_aspect, v_uv.y);
+ float alive =
+ smoothstep(0.0, 0.06, u_progress) * smoothstep(1.0, 0.94, u_progress);
+
+ float brightness = luma(texture(u_from, v_uv).rgb);
+ float field = clamp(
+ clamp(fbm(skewed * u_patches), 0.0, 1.0) *
+ (1.0 - u_content * brightness * 0.9),
+ 0.0,
+ 1.0
+ );
+
+ float soft = max(u_softness, 0.004);
+ float margin = soft * 3.0 + 0.02;
+ float front = mix(-margin, 1.0 + margin, pow(u_progress, 1.2));
+ float depth = field - front;
+
+ float intact = smoothstep(-soft, soft, depth);
+ float arrived = 1.0 - intact;
+
+ vec2 shimmer = vec2(
+ noise(skewed * u_patches * 2.4 + vec2(0.0, u_progress * 3.1)) - 0.5,
+ noise(skewed * u_patches * 2.4 + vec2(5.2, 1.7 + u_progress * 4.3)) - 0.5
+ );
+ float boil = exp(-pow(depth / (soft * 6.0), 2.0)) * alive * u_heat * 0.14;
+ vec4 from = texture(u_from, v_uv + shimmer * boil * intact);
+ vec4 to = texture(u_to, v_uv - shimmer * boil * arrived);
+
+ float ramp = depth / (soft * 2.2);
+ float charred = intact * exp(-pow((ramp - 0.55) * 1.5, 2.0)) * alive;
+ float molten = arrived * exp(-pow((ramp + 0.55) * 1.5, 2.0)) * alive;
+ float rim = exp(-pow(depth / (soft * 1.1), 2.0));
+
+ float since = clamp(-depth / (soft * 3.0), 0.0, 1.0);
+ vec2 emberSpace = skewed + vec2(0.0, u_progress * 0.42);
+ float cellSeed = hash(floor(emberSpace * EMBER_GRID));
+ float ember =
+ step(1.0 - u_embers * 0.08, cellSeed) *
+ arrived *
+ exp(-pow(depth / (soft * 2.6), 2.0)) *
+ alive;
+ vec3 sparkSource = texture(u_from, v_uv + vec2(0.0, since * 0.07)).rgb;
+
+ vec4 color = mix(to, from, intact);
+ color.rgb *= 1.0 - charred * 0.92;
+ color.rgb += (color.rgb * 1.2 + u_glow * 0.6) * molten;
+
+ vec3 spark = mix(u_glow, sparkSource * 1.4 + u_glow * 0.3, 0.5);
+ float light = min(rim * 0.85, 1.4);
+ color.rgb += u_glow * light + spark * ember * 1.3;
+ color.a = clamp(color.a + light + molten + ember, 0.0, 1.0);
+
+ outColor = color;
+}`;
+
+const shader = makeSceneShader<EmberBurnProps>(
+ FRAGMENT_SHADER,
+ ({ gl, uniform, passedProps }) => {
+ const {
+ patches = DEFAULTS.patches,
+ edgeSoftness = DEFAULTS.edgeSoftness,
+ contentBias = DEFAULTS.contentBias,
+ heat = DEFAULTS.heat,
+ glowColor = DEFAULTS.glowColor,
+ emberAmount = DEFAULTS.emberAmount,
+ } = passedProps;
+ const glow = hexToRgb(glowColor);
+ gl.uniform1f(uniform("u_patches"), patches);
+ gl.uniform1f(uniform("u_softness"), edgeSoftness);
+ gl.uniform1f(uniform("u_content"), contentBias);
+ gl.uniform1f(uniform("u_heat"), heat);
+ gl.uniform3f(uniform("u_glow"), glow[0], glow[1], glow[2]);
+ gl.uniform1f(uniform("u_embers"), emberAmount);
+ },
+);
+
+const EmberBurnFallback: React.FC<
+ TransitionPresentationComponentProps<EmberBurnProps>
+> = ({
+ children,
+ presentationProgress,
+ presentationDirection,
+ passedProps,
+}) => {
+ const { glowColor = DEFAULTS.glowColor } = passedProps;
+
+ if (presentationDirection === "exiting") {
+ return <AbsoluteFill>{children}</AbsoluteFill>;
+ }
+
+ const p = presentationProgress;
+ const reveal = Math.min(1, Math.max(0, (p - 0.25) / 0.5));
+ const flash = Math.max(0, Math.sin(p * Math.PI)) ** 0.6 * 0.4;
+
+ return (
+ <AbsoluteFill>
+ <AbsoluteFill style={{ opacity: reveal }}>{children}</AbsoluteFill>
+ <AbsoluteFill
+ style={{
+ background: glowColor,
+ mixBlendMode: "screen",
+ opacity: flash,
+ pointerEvents: "none",
+ }}
+ />
+ </AbsoluteFill>
+ );
+};
+
+const presentation = makeCanvasPresentation<EmberBurnProps>({
+ shader,
+ fallback: EmberBurnFallback,
+});
+
+export function emberBurn(
+ props: EmberBurnProps = {},
+): TransitionPresentation<EmberBurnProps> {
+ return presentation(props);
+}
diff --git a/registry/remocn/registry.json b/registry/remocn/registry.json
index b0b81aee..6359470d 100644
--- a/registry/remocn/registry.json
+++ b/registry/remocn/registry.json
@@ -1644,6 +1644,21 @@
}
]
},
+ {
+ "name": "ember-burn",
+ "type": "registry:component",
+ "title": "Ember Burn",
+ "description": "The outgoing frame catches fire where it is brightest, boils in the heat, chars at the rim, and blows away as sparks carrying its own colour.",
+ "dependencies": ["remotion", "@remotion/transitions"],
+ "registryDependencies": ["@remocn/canvas-presentation"],
+ "files": [
+ {
+ "path": "ember-burn/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/ember-burn.tsx"
+ }
+ ]
+ },
{
"name": "glitch-cut",
"type": "registry:component",
diff --git a/src/remotion/canvas-spike-root.tsx b/src/remotion/canvas-spike-root.tsx
index 64b1b1e7..4b9b29a1 100644
--- a/src/remotion/canvas-spike-root.tsx
+++ b/src/remotion/canvas-spike-root.tsx
@@ -6,8 +6,10 @@ import {
isHtmlInCanvasSupported,
registerRoot,
} from "remotion";
+import { EmberBurnExampleScene } from "@/components/docs/examples/ember-burn-example";
import { GlitchCutExampleScene } from "@/components/docs/examples/glitch-cut-example";
import type { ComponentConfig } from "@/lib/customizer-config";
+import { emberBurnConfig } from "@/registry/remocn/ember-burn/config";
import { glitchCutConfig } from "@/registry/remocn/glitch-cut/config";
const { fontFamily: GEIST } = loadFont();
@@ -24,6 +26,7 @@ const SCENES: Record<
{ Scene: ComponentType; config: ComponentConfig }
> = {
"glitch-cut": { Scene: GlitchCutExampleScene, config: glitchCutConfig },
+ "ember-burn": { Scene: EmberBurnExampleScene, config: emberBurnConfig },
};
function makeStage(Scene: ComponentType) {