Skip to content

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

feat: htmlincanvas lib, glitch transition

kapishdimac91f6c25eac3
diff --git a/components/docs/canvas-transition-note.tsx b/components/docs/canvas-transition-note.tsx
new file mode 100644
index 00000000..3c915e5a
--- /dev/null
+++ b/components/docs/canvas-transition-note.tsx
@@ -0,0 +1,23 @@
+import { Warning } from "@/components/docs/callout";
+
+export function CanvasTransitionNote() {
+ return (
+ <Warning title="Experimental — html-in-canvas">
+ <p>
+ This transition post-processes the real pixels of both scenes through
+ the experimental html-in-canvas browser API. The preview above shows the
+ true effect in Chrome 149+ with{" "}
+ <code>chrome://flags/#canvas-draw-element</code> enabled (nested
+ canvases need 152.0.7944.0+). Every other browser — Safari, Firefox,
+ Chrome without the flag — falls back to a CSS approximation of the same
+ cut, so the page and your video still play.
+ </p>
+ <p>
+ Rendering is supported through the CLI, Studio, Lambda and SSR with{" "}
+ <code>--gl=angle</code>, or <code>--gl=swangle</code> on a machine
+ without a GPU. Chrome may change or discontinue the API; the CSS
+ fallback is what keeps your composition renderable if that happens.
+ </p>
+ </Warning>
+ );
+}
diff --git a/components/docs/examples/glitch-cut-example.tsx b/components/docs/examples/glitch-cut-example.tsx
new file mode 100644
index 00000000..dc50b324
--- /dev/null
+++ b/components/docs/examples/glitch-cut-example.tsx
@@ -0,0 +1,87 @@
+"use client";
+
+import { linearTiming, TransitionSeries } from "@remotion/transitions";
+import { AbsoluteFill } from "remotion";
+import { glitchCut } from "@/registry/remocn/glitch-cut";
+
+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 GlitchCutExampleProps {
+ intensity?: number;
+ slices?: number;
+ rgbSplit?: number;
+ blockNoise?: number;
+}
+
+export function GlitchCutExampleScene({
+ intensity,
+ slices,
+ rgbSplit,
+ blockNoise,
+}: GlitchCutExampleProps) {
+ return (
+ <TransitionSeries>
+ <TransitionSeries.Sequence durationInFrames={45}>
+ <Scene label="Scene A" background="#0a0a0a" />
+ </TransitionSeries.Sequence>
+ <TransitionSeries.Transition
+ timing={linearTiming({ durationInFrames: 12 })}
+ presentation={glitchCut({ intensity, slices, rgbSplit, blockNoise })}
+ />
+ <TransitionSeries.Sequence durationInFrames={45}>
+ <Scene label="Scene B" background="#141318" />
+ </TransitionSeries.Sequence>
+ </TransitionSeries>
+ );
+}
+
+export const glitchCutExampleCode = (
+ values: Record<string, unknown>,
+): string => {
+ const intensity = (values.intensity as number) ?? 1;
+ const slices = (values.slices as number) ?? 24;
+ const rgbSplit = (values.rgbSplit as number) ?? 1;
+ const blockNoise = (values.blockNoise as number) ?? 0.6;
+ return `import { TransitionSeries, linearTiming } from "@remotion/transitions";
+import { glitchCut } from "@/components/remocn/glitch-cut";
+
+export const MyVideo = () => (
+ <TransitionSeries>
+ <TransitionSeries.Sequence durationInFrames={45}>
+ <SceneA />
+ </TransitionSeries.Sequence>
+ <TransitionSeries.Transition
+ timing={linearTiming({ durationInFrames: 12 })}
+ presentation={glitchCut({ intensity: ${intensity}, slices: ${slices}, rgbSplit: ${rgbSplit}, blockNoise: ${blockNoise} })}
+ />
+ <TransitionSeries.Sequence durationInFrames={45}>
+ <SceneB />
+ </TransitionSeries.Sequence>
+ </TransitionSeries>
+);`;
+};
diff --git a/config/site.ts b/config/site.ts
index 9f0a0167..34d06872 100644
--- a/config/site.ts
+++ b/config/site.ts
@@ -83,6 +83,7 @@ export const NEW_BADGE_PATHS = new Set<string>([
"/docs/shaders/components/shader-strata",
"/docs/shaders/components/shader-weave",
"/docs/ui-blocks/reel",
+ "/docs/transitions/glitch-cut",
]);
export type FooterGroup = {
diff --git a/content/changelog/2026-08-02-canvas-transitions.mdx b/content/changelog/2026-08-02-canvas-transitions.mdx
new file mode 100644
index 00000000..7fac82af
--- /dev/null
+++ b/content/changelog/2026-08-02-canvas-transitions.mdx
@@ -0,0 +1,18 @@
+---
+title: Canvas transitions, a new category
+date: 2026-08-02
+---
+
+Every transition in the catalog so far animates a scene from the outside — opacity, transform, filter, or a layer drawn over the cut. None of them could touch the pixels of the scenes being blended, which is why the effects real video editors are known for — tearing, burning, shattering — were missing. Canvas transitions sample both scenes as textures through the experimental html-in-canvas browser API and post-process them per frame, and this is the first one.
+
+<ChangelogPreview name="glitch-cut" />
+
+### 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.
+- 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
+
+- Canvas transitions never present a broken demo. In Chrome 149+ with `chrome://flags/#canvas-draw-element` enabled you get the real pixel effect; in Safari, Firefox, and Chrome without the flag the presentation degrades to a CSS approximation of the same edit, so docs previews stay live and your video still renders. Rendering runs through the CLI, Studio, Lambda, and SSR with `--gl=angle`, or `--gl=swangle` without a GPU.
+- Output is deterministic by construction. Displacement, corruption, and the per-slice handover all come from a hash seeded on the slice index and on a clock derived from the transition's progress — no wall-clock time, no state between frames — so parallel and server-side renders come out seam-free.
diff --git a/content/docs/components.mdx b/content/docs/components.mdx
index 8cb88315..b9d45f34 100644
--- a/content/docs/components.mdx
+++ b/content/docs/components.mdx
@@ -499,6 +499,12 @@ Scene transitions, camera moves, and stylized wipes.
status: "stable",
href: "/docs/transitions/icon-scatter",
},
+ {
+ name: "GlitchCut",
+ description: "Tear a hard cut into displaced slices with channel split and corrupted blocks",
+ status: "stable",
+ href: "/docs/transitions/glitch-cut",
+ },
]}
/>
diff --git a/content/docs/transitions/glitch-cut.mdx b/content/docs/transitions/glitch-cut.mdx
new file mode 100644
index 00000000..0d5551ba
--- /dev/null
+++ b/content/docs/transitions/glitch-cut.mdx
@@ -0,0 +1,117 @@
+---
+title: Glitch Cut
+description: Tear a hard cut into displaced slices with channel split and corrupted blocks
+component: glitch-cut
+vibe: tech
+length: 12
+useWhen:
+ - "The cut lands in a tech or developer-facing demo and should read as a deliberate broadcast artifact instead of a smooth blend."
+ - "The rhythm is fast — it holds up at 8 to 14 frames, where softer presentations read as sluggish."
+ - "The two scenes are visually unrelated and the hard cut between them needs an excuse."
+avoidWhen:
+ - "Only a headline should glitch while the scene around it stays intact — use `rgb-glitch-text`."
+ - "The demo needs a calm, general-purpose cut — use `zoom-blur`."
+---
+
+<ComponentPreview name="glitch-cut" />
+
+<CanvasTransitionNote />
+
+## Installation
+
+<InstallBlock name="glitch-cut" />
+
+## Usage
+
+`glitchCut()` is a Remotion transition presentation. Pass it to a
+`TransitionSeries.Transition` between two sequences. The frame breaks into
+horizontal slices that slide apart, the colour channels separate, and blocks of
+the frame corrupt into the wrong scene — then each slice hands over to the
+incoming scene on its own beat around the midpoint, so the cut itself is torn
+rather than flat. Both ends of the transition settle to untouched pixels, so
+nothing bleeds into the scenes on either side.
+
+It is built for short timings. `linearTiming({ durationInFrames: 12 })` is the
+recommended default; past roughly 20 frames the tearing stops reading as an
+artifact and starts reading as an effect.
+
+```tsx
+import { TransitionSeries, linearTiming } from "@remotion/transitions";
+import { glitchCut } from "@/components/remocn/glitch-cut";
+
+export const MyVideo = () => (
+ <TransitionSeries>
+ <TransitionSeries.Sequence durationInFrames={45}>
+ <SceneA />
+ </TransitionSeries.Sequence>
+ <TransitionSeries.Transition
+ timing={linearTiming({ durationInFrames: 12 })}
+ presentation={glitchCut()}
+ />
+ <TransitionSeries.Sequence durationInFrames={45}>
+ <SceneB />
+ </TransitionSeries.Sequence>
+ </TransitionSeries>
+);
+```
+
+Installing it also installs `lib/remocn/canvas-presentation.tsx`, the shared
+scaffolding behind every canvas transition. It owns the support check, the
+WebGL2 scene shader that receives both sides of the cut as textures, and the
+routing that swaps in the CSS fallback where the browser has no html-in-canvas.
+
+## Determinism
+
+Every pixel is a pure function of the transition's progress. The slice
+displacement, the block corruption and the per-slice handover all come from a
+hash seeded on the slice index and on a 22-step clock derived from progress —
+no wall-clock time, no state carried between frames. The same frame renders
+identically on every machine and in every chunk, so parallel and server-side
+renders come out seam-free.
+
+## Fallback
+
+Where html-in-canvas is unavailable the presentation renders a CSS
+approximation instead: the frame is clipped into bands that shift horizontally
+on the same seeded clock, each band tinted alternately red and cyan to stand in
+for the channel split, and each band hands over to the incoming scene at its own
+staggered cut point. It reads as the same edit — a torn hard cut — without
+touching pixels. `slices` still drives how many bands there are; `blockNoise`
+has no effect there.
+
+## Props
+
+`glitchCut(props)` accepts:
+
+<PropsTable
+ rows={[
+ {
+ name: "intensity",
+ type: "number",
+ default: "1",
+ description:
+ "Overall displacement. Scales how far slices and corrupted blocks slide sideways. 0 leaves the geometry intact and keeps only the channel split.",
+ },
+ {
+ name: "slices",
+ type: "number",
+ default: "24",
+ description:
+ "How many horizontal slices the frame is cut into. Low counts read as chunky tape damage, high counts as fine scanline tearing.",
+ },
+ {
+ name: "rgbSplit",
+ type: "number",
+ default: "1",
+ description:
+ "Chromatic separation of the red and blue channels at the peak of the glitch. 0 keeps the colour clean.",
+ },
+ {
+ name: "blockNoise",
+ type: "number",
+ default: "0.6",
+ description:
+ "How much of the frame corrupts into displaced blocks that leak the other scene. 0 keeps the tearing purely horizontal.",
+ },
+ ]}
+/>
diff --git a/content/docs/transitions/index.mdx b/content/docs/transitions/index.mdx
index a616a981..0a511d4d 100644
--- a/content/docs/transitions/index.mdx
+++ b/content/docs/transitions/index.mdx
@@ -122,6 +122,21 @@ Kinetic, interface-flavored transitions — typed wipes, scattering icons, and m
]}
/>
+## Canvas
+
+Pixel-level transitions. These read the actual pixels of both scenes through the experimental html-in-canvas browser API and post-process them per frame, which is what makes tearing, burning, and shattering possible at all. Chrome 149+ behind `chrome://flags/#canvas-draw-element` shows the real effect; every other browser degrades to a CSS approximation of the same edit, so previews and renders never break.
+
+<ComponentCardGrid
+ items={[
+ {
+ name: "GlitchCut",
+ description: "Tear a hard cut into displaced slices with channel split and corrupted blocks",
+ status: "stable",
+ href: "/docs/transitions/glitch-cut",
+ },
+ ]}
+/>
+
## Scene Sequencers
Not presentations. Each of these takes the whole list of scenes and runs the timeline itself, so the boundary is a property of the film rather than something dropped between two sequences. Scenes never overlap and the stage is continuous, which is what makes a run of them read as one cut instead of a slideshow.
diff --git a/content/docs/transitions/meta.json b/content/docs/transitions/meta.json
index 83c1075e..a6592d20 100644
--- a/content/docs/transitions/meta.json
+++ b/content/docs/transitions/meta.json
@@ -19,6 +19,7 @@
"ascii-dissolve",
"caret-wipe",
"icon-scatter",
+ "glitch-cut",
"slide-swap",
"spring-settle"
]
diff --git a/content/docs/typography/rgb-glitch-text.mdx b/content/docs/typography/rgb-glitch-text.mdx
index 29ca7646..91b55452 100644
--- a/content/docs/typography/rgb-glitch-text.mdx
+++ b/content/docs/typography/rgb-glitch-text.mdx
@@ -12,6 +12,7 @@ avoidWhen:
- "You need a full text entrance animation — the glitch is a momentary effect, not a reveal; use `tracking-in` or `soft-blur-in` to bring text in."
- "The brand aesthetic is clean or premium — RGB splits read as intentionally broken; use `shimmer-sweep` for a high-end shimmer moment instead."
- "The text is long — offset copies of a full paragraph are illegible during the glitch window; keep it to a short word or phrase."
+ - "The whole frame should break at a scene change rather than a headline mid-scene — use `glitch-cut`."
---
<ComponentPreview name="rgb-glitch-text" />
diff --git a/lib/docs-meta.test.ts b/lib/docs-meta.test.ts
index 6c8a016a..c84ca3e4 100644
--- a/lib/docs-meta.test.ts
+++ b/lib/docs-meta.test.ts
@@ -10,6 +10,7 @@ const UNDOCUMENTED: Record<string, string> = {
"remocn-ui": "shared core lib, not installed directly",
"stop-motion": "shared lib behind the paper tier",
"scene-motion": "shared motion vocabulary lib",
+ "canvas-presentation": "shared html-in-canvas scaffolding lib",
brush: "ribbon primitive consumed by the ink marks, not used on its own",
"select-item": "folds into the select page",
"dropdown-menu-item": "folds into the dropdown-menu page",
diff --git a/mdx-components.tsx b/mdx-components.tsx
index 80d5c855..7b2ab9ce 100644
--- a/mdx-components.tsx
+++ b/mdx-components.tsx
@@ -3,6 +3,7 @@ import type { MDXComponents } from "mdx/types";
import type { ComponentProps } from "react";
import { BlockPreview } from "@/components/docs/block-preview";
import { Note, Warning } from "@/components/docs/callout";
+import { CanvasTransitionNote } from "@/components/docs/canvas-transition-note";
import { getIconForLanguage } from "@/components/docs/code-icons";
import { ComponentCardGrid } from "@/components/docs/component-card-grid";
import { ComponentExample } from "@/components/docs/component-example";
@@ -111,6 +112,7 @@ export function getMDXComponents(components?: MDXComponents): MDXComponents {
PropsTable,
Note,
Warning,
+ CanvasTransitionNote,
Dependencies,
ComponentCardGrid,
IconsGallery,
diff --git a/registry-artifacts/canvas-presentation.json b/registry-artifacts/canvas-presentation.json
new file mode 100644
index 00000000..ae802f48
--- /dev/null
+++ b/registry-artifacts/canvas-presentation.json
@@ -0,0 +1,16 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "canvas-presentation",
+ "title": "Canvas Presentation",
+ "description": "The html-in-canvas scaffolding the canvas transitions share: support detection, a full-screen WebGL2 scene shader over both sides of the cut, and routing to a CSS fallback where the browser lacks the API.",
+ "dependencies": ["remotion", "@remotion/transitions"],
+ "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",
+ "type": "registry:lib",
+ "target": "lib/remocn/canvas-presentation.tsx"
+ }
+ ],
+ "type": "registry:lib"
+}
diff --git a/registry-artifacts/glitch-cut.json b/registry-artifacts/glitch-cut.json
new file mode 100644
index 00000000..9d2b8c05
--- /dev/null
+++ b/registry-artifacts/glitch-cut.json
@@ -0,0 +1,17 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "glitch-cut",
+ "title": "Glitch Cut",
+ "description": "A broadcast-glitch hard cut: the frame tears into displaced slices with channel split and corrupted blocks, and the incoming scene takes over slice by slice at the peak.",
+ "dependencies": ["remotion", "@remotion/transitions"],
+ "registryDependencies": ["@remocn/canvas-presentation"],
+ "files": [
+ {
+ "path": "registry/remocn/glitch-cut/index.tsx",
+ "content": "\"use client\";\n\nimport type {\n TransitionPresentation,\n TransitionPresentationComponentProps,\n} from \"@remotion/transitions\";\nimport type React from \"react\";\nimport { AbsoluteFill, random } from \"remotion\";\nimport {\n makeCanvasPresentation,\n makeSceneShader,\n} from \"@/lib/remocn/canvas-presentation\";\n\nexport type GlitchCutProps = {\n intensity?: number;\n slices?: number;\n rgbSplit?: number;\n blockNoise?: number;\n};\n\nconst DEFAULTS = {\n intensity: 1,\n slices: 24,\n rgbSplit: 1,\n blockNoise: 0.6,\n};\n\nconst STEPS = 22;\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_intensity;\nuniform float u_slices;\nuniform float u_rgb_split;\nuniform float u_block_noise;\n\nin vec2 v_uv;\nout vec4 outColor;\n\nconst float PI = 3.141592653589793;\nconst float STEPS = ${STEPS}.0;\nconst float BLOCK_COLUMNS = 16.0;\n\nfloat hash(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);\n}\n\nvec4 sampleSplit(sampler2D tex, vec2 uv, float split) {\n vec4 center = texture(tex, uv);\n float r = texture(tex, vec2(uv.x + split, uv.y)).r;\n float b = texture(tex, vec2(uv.x - split, uv.y)).b;\n return vec4(r, center.g, b, center.a);\n}\n\nvoid main() {\n float energy = pow(max(sin(u_progress * PI), 0.0), 0.7);\n float clock = floor(u_progress * STEPS);\n\n float row = floor(v_uv.y * u_slices);\n float torn = step(0.45, hash(vec2(row, clock)));\n float amount = hash(vec2(row + 17.0, clock * 1.7 + 3.0)) - 0.5;\n float sliceShift = amount * 0.3 * u_intensity * energy * torn;\n\n vec2 block = vec2(floor(v_uv.x * BLOCK_COLUMNS), row);\n float corrupt = step(\n 1.0 - u_block_noise * 0.5 * energy,\n hash(block + clock * 7.3)\n );\n float blockShift =\n (hash(block + clock * 3.1 + 5.0) - 0.5) * 0.2 * u_intensity * corrupt;\n\n vec2 uv = vec2(fract(v_uv.x + sliceShift + blockShift), v_uv.y);\n float split = u_rgb_split * 0.018 * energy * (0.35 + abs(amount));\n\n float cut = 0.5 + (hash(vec2(row, 91.0)) - 0.5) * 0.32;\n float handed = step(cut, u_progress);\n\n vec4 from = sampleSplit(u_from, uv, split);\n vec4 to = sampleSplit(u_to, uv, split);\n vec4 color = mix(from, to, handed);\n vec4 leaked = mix(to, from, handed);\n\n float leak = corrupt * step(0.55, hash(block + clock * 11.0 + 13.0));\n color = mix(color, leaked, leak * 0.8);\n\n color.rgb +=\n vec3(0.05, 0.015, 0.09) *\n energy *\n torn *\n hash(vec2(row, clock + 41.0)) *\n color.a;\n\n outColor = color;\n}`;\n\nconst shader = makeSceneShader<GlitchCutProps>(\n FRAGMENT_SHADER,\n ({ gl, uniform, passedProps }) => {\n const {\n intensity = DEFAULTS.intensity,\n slices = DEFAULTS.slices,\n rgbSplit = DEFAULTS.rgbSplit,\n blockNoise = DEFAULTS.blockNoise,\n } = passedProps;\n gl.uniform1f(uniform(\"u_intensity\"), intensity);\n gl.uniform1f(uniform(\"u_slices\"), slices);\n gl.uniform1f(uniform(\"u_rgb_split\"), rgbSplit);\n gl.uniform1f(uniform(\"u_block_noise\"), blockNoise);\n },\n);\n\nconst bandCut = (band: number) =>\n 0.5 + (random(`glitch-cut-handoff-${band}`) - 0.5) * 0.32;\n\nconst GlitchCutFallback: React.FC<\n TransitionPresentationComponentProps<GlitchCutProps>\n> = ({\n children,\n presentationProgress,\n presentationDirection,\n passedProps,\n}) => {\n const {\n intensity = DEFAULTS.intensity,\n slices = DEFAULTS.slices,\n rgbSplit = DEFAULTS.rgbSplit,\n } = passedProps;\n const entering = presentationDirection === \"entering\";\n const p = presentationProgress;\n const energy = Math.max(0, Math.sin(p * Math.PI)) ** 0.7;\n\n if (energy < 0.002) {\n const settled = entering ? (p >= 0.5 ? 1 : 0) : p < 0.5 ? 1 : 0;\n return <AbsoluteFill style={{ opacity: settled }}>{children}</AbsoluteFill>;\n }\n\n const clock = Math.floor(p * STEPS);\n const bands = Math.max(2, Math.min(6, Math.round(slices / 5)));\n const height = 100 / bands;\n\n return (\n <AbsoluteFill>\n {Array.from({ length: bands }, (_, band) => {\n const shown = p >= bandCut(band) ? entering : !entering;\n if (!shown) {\n return null;\n }\n const shift =\n (random(`glitch-cut-shift-${clock}-${band}`) - 0.5) *\n 52 *\n intensity *\n energy;\n const tint = band % 2 === 0 ? \"rgb(255, 42, 90)\" : \"rgb(0, 224, 255)\";\n const tintOpacity =\n rgbSplit * 0.2 * energy * random(`glitch-cut-tint-${clock}-${band}`);\n return (\n <AbsoluteFill\n key={band}\n style={{\n clipPath: `inset(${band * height}% 0 ${100 - (band + 1) * height}% 0)`,\n transform: `translateX(${shift}px)`,\n }}\n >\n {children}\n <AbsoluteFill\n style={{\n background: tint,\n mixBlendMode: \"screen\",\n opacity: tintOpacity,\n }}\n />\n </AbsoluteFill>\n );\n })}\n </AbsoluteFill>\n );\n};\n\nconst presentation = makeCanvasPresentation<GlitchCutProps>({\n shader,\n fallback: GlitchCutFallback,\n});\n\nexport function glitchCut(\n props: GlitchCutProps = {},\n): TransitionPresentation<GlitchCutProps> {\n return presentation(props);\n}\n",
+ "type": "registry:component",
+ "target": "components/remocn/glitch-cut.tsx"
+ }
+ ],
+ "type": "registry:component"
+}
diff --git a/registry-artifacts/registry.json b/registry-artifacts/registry.json
index 22b9c199..720cf7d9 100644
--- a/registry-artifacts/registry.json
+++ b/registry-artifacts/registry.json
@@ -1630,6 +1630,35 @@
],
"type": "registry:component"
},
+ {
+ "name": "canvas-presentation",
+ "title": "Canvas Presentation",
+ "description": "The html-in-canvas scaffolding the canvas transitions share: support detection, a full-screen WebGL2 scene shader over both sides of the cut, and routing to a CSS fallback where the browser lacks the API.",
+ "dependencies": ["remotion", "@remotion/transitions"],
+ "files": [
+ {
+ "path": "registry/remocn/canvas-presentation/index.tsx",
+ "type": "registry:lib",
+ "target": "lib/remocn/canvas-presentation.tsx"
+ }
+ ],
+ "type": "registry:lib"
+ },
+ {
+ "name": "glitch-cut",
+ "title": "Glitch Cut",
+ "description": "A broadcast-glitch hard cut: the frame tears into displaced slices with channel split and corrupted blocks, and the incoming scene takes over slice by slice at the peak.",
+ "dependencies": ["remotion", "@remotion/transitions"],
+ "registryDependencies": ["@remocn/canvas-presentation"],
+ "files": [
+ {
+ "path": "registry/remocn/glitch-cut/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/glitch-cut.tsx"
+ }
+ ],
+ "type": "registry:component"
+ },
{
"name": "remocn-ui",
"title": "remocn UI Core",
diff --git a/registry/__index__.tsx b/registry/__index__.tsx
index 449a4e59..b79e5cc6 100644
--- a/registry/__index__.tsx
+++ b/registry/__index__.tsx
@@ -26,6 +26,7 @@ import { githubSponsorsConfig } from "@/registry/remocn/github-sponsors/config";
import { githubStarsConfig } from "@/registry/remocn/github-stars/config";
import { glassCodeBlockConfig } from "@/registry/remocn/glass-code-block/config";
import { glassCodeWalkConfig } from "@/registry/remocn/glass-code-walk/config";
+import { glitchCutConfig } from "@/registry/remocn/glitch-cut/config";
import { grainDissolveConfig } from "@/registry/remocn/grain-dissolve/config";
import { handCountConfig } from "@/registry/remocn/hand-count/config";
import { handwriteConfig } from "@/registry/remocn/handwrite/config";
@@ -1417,6 +1418,13 @@ const registry: Record<string, RegistryEntry> = {
})),
config: zoomBlurConfig,
},
+ "glitch-cut": {
+ load: () =>
+ import("@/components/docs/examples/glitch-cut-example").then((m) => ({
+ default: m.GlitchCutExampleScene,
+ })),
+ config: glitchCutConfig,
+ },
"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
new file mode 100644
index 00000000..587d7501
--- /dev/null
+++ b/registry/remocn/canvas-presentation/index.tsx
@@ -0,0 +1,425 @@
+"use client";
+
+import type {
+ TransitionPresentation,
+ TransitionPresentationComponentProps,
+} from "@remotion/transitions";
+import React from "react";
+import {
+ AbsoluteFill,
+ isHtmlInCanvasSupported,
+ useDelayRender,
+} from "remotion";
+
+const QUAD = new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]);
+
+const VERTEX_SHADER = `#version 300 es
+in vec2 a_pos;
+out vec2 v_uv;
+void main() {
+ v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
+ gl_Position = vec4(a_pos, 0.0, 1.0);
+}`;
+
+const LAYER: React.CSSProperties = {
+ position: "absolute",
+ inset: 0,
+ width: "100%",
+ height: "100%",
+};
+
+const OUTPUT_LAYER: React.CSSProperties = { ...LAYER, pointerEvents: "none" };
+
+export const isCanvasTransitionSupported = (): boolean =>
+ isHtmlInCanvasSupported();
+
+export type SceneShaderFrame<Props> = {
+ gl: WebGL2RenderingContext;
+ uniform: (name: string) => WebGLUniformLocation | null;
+ width: number;
+ height: number;
+ progress: number;
+ passedProps: Props;
+};
+
+export type SceneShaderDrawParams<Props> = {
+ from: OffscreenCanvas | null;
+ to: OffscreenCanvas | null;
+ width: number;
+ height: number;
+ progress: number;
+ passedProps: Props;
+};
+
+export type SceneShaderInstance<Props> = {
+ draw: (params: SceneShaderDrawParams<Props>) => void;
+ clear: () => void;
+ cleanup: () => void;
+};
+
+export type SceneShader<Props> = (
+ canvas: OffscreenCanvas,
+) => SceneShaderInstance<Props>;
+
+function compileShader(
+ gl: WebGL2RenderingContext,
+ source: string,
+ type: GLenum,
+): WebGLShader {
+ const shader = gl.createShader(type);
+ if (!shader) {
+ throw new Error("canvas-presentation: failed to create 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(`canvas-presentation: failed to compile shader: ${log}`);
+ }
+ return shader;
+}
+
+function createProgram(
+ gl: WebGL2RenderingContext,
+ fragment: string,
+): WebGLProgram {
+ const program = gl.createProgram();
+ if (!program) {
+ throw new Error("canvas-presentation: failed to create program");
+ }
+ const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);
+ const fs = compileShader(gl, fragment, gl.FRAGMENT_SHADER);
+ gl.attachShader(program, vs);
+ gl.attachShader(program, fs);
+ gl.linkProgram(program);
+ gl.deleteShader(vs);
+ gl.deleteShader(fs);
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
+ const log = gl.getProgramInfoLog(program);
+ gl.deleteProgram(program);
+ throw new Error(`canvas-presentation: failed to link program: ${log}`);
+ }
+ return program;
+}
+
+function createSceneTexture(gl: WebGL2RenderingContext): WebGLTexture {
+ const texture = gl.createTexture();
+ if (!texture) {
+ throw new Error("canvas-presentation: failed to create 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.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
+ gl.texImage2D(
+ gl.TEXTURE_2D,
+ 0,
+ gl.RGBA,
+ 1,
+ 1,
+ 0,
+ gl.RGBA,
+ gl.UNSIGNED_BYTE,
+ new Uint8Array([0, 0, 0, 0]),
+ );
+ return texture;
+}
+
+export function makeSceneShader<Props extends Record<string, unknown>>(
+ fragment: string,
+ setUniforms?: (frame: SceneShaderFrame<Props>) => void,
+): SceneShader<Props> {
+ return (canvas) => {
+ const gl = canvas.getContext("webgl2", { premultipliedAlpha: true });
+ if (!gl) {
+ throw new Error("canvas-presentation: WebGL2 is unavailable");
+ }
+
+ const program = createProgram(gl, fragment);
+ const fromTexture = createSceneTexture(gl);
+ const toTexture = createSceneTexture(gl);
+ const vao = gl.createVertexArray();
+ gl.bindVertexArray(vao);
+ const buffer = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
+ gl.bufferData(gl.ARRAY_BUFFER, QUAD, gl.STATIC_DRAW);
+ const aPos = gl.getAttribLocation(program, "a_pos");
+ gl.enableVertexAttribArray(aPos);
+ gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);
+
+ const locations = new Map<string, WebGLUniformLocation | null>();
+ const uniform = (name: string) => {
+ const cached = locations.get(name);
+ if (cached !== undefined) {
+ return cached;
+ }
+ const location = gl.getUniformLocation(program, name);
+ locations.set(name, location);
+ return location;
+ };
+
+ const clear = () => {
+ gl.clearColor(0, 0, 0, 0);
+ gl.clear(gl.COLOR_BUFFER_BIT);
+ };
+
+ const bindScene = (
+ image: OffscreenCanvas | null,
+ texture: WebGLTexture,
+ unit: number,
+ name: string,
+ ) => {
+ gl.activeTexture(gl.TEXTURE0 + unit);
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ if (image) {
+ gl.texImage2D(
+ gl.TEXTURE_2D,
+ 0,
+ gl.RGBA,
+ gl.RGBA,
+ gl.UNSIGNED_BYTE,
+ image,
+ );
+ }
+ gl.uniform1i(uniform(name), unit);
+ };
+
+ return {
+ clear,
+ cleanup: () => {
+ gl.deleteProgram(program);
+ gl.deleteTexture(fromTexture);
+ gl.deleteTexture(toTexture);
+ gl.deleteBuffer(buffer);
+ gl.deleteVertexArray(vao);
+ },
+ draw: ({ from, to, width, height, progress, passedProps }) => {
+ gl.viewport(0, 0, width, height);
+ clear();
+ gl.useProgram(program);
+ gl.bindVertexArray(vao);
+
+ bindScene(from, fromTexture, 0, "u_from");
+ bindScene(to, toTexture, 1, "u_to");
+
+ gl.uniform1f(uniform("u_progress"), progress);
+ gl.uniform1f(uniform("u_aspect"), width / height);
+ setUniforms?.({ gl, uniform, width, height, progress, passedProps });
+
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
+ },
+ };
+ };
+}
+
+const transferred = new WeakMap<HTMLCanvasElement, OffscreenCanvas>();
+
+function takeOffscreen(canvas: HTMLCanvasElement): OffscreenCanvas {
+ const existing = transferred.get(canvas);
+ if (existing) {
+ return existing;
+ }
+ const created = canvas.transferControlToOffscreen();
+ transferred.set(canvas, created);
+ return created;
+}
+
+function makeCanvasComponent<Props extends Record<string, unknown>>(
+ shader: SceneShader<Props>,
+): React.FC<TransitionPresentationComponentProps<Props>> {
+ return function CanvasScenePresentation({
+ children,
+ presentationProgress,
+ presentationDirection,
+ passedProps,
+ onElementImage,
+ onUnmount,
+ bothEnteringAndExiting,
+ }) {
+ const layoutRef = React.useRef<HTMLCanvasElement | null>(null);
+ const outputRef = React.useRef<HTMLCanvasElement | null>(null);
+ const captureRef = React.useRef<OffscreenCanvas | null>(null);
+ const captureContextRef =
+ React.useRef<OffscreenCanvasRenderingContext2D | null>(null);
+ const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);
+ const instanceRef = React.useRef<SceneShaderInstance<Props> | null>(null);
+ const passedPropsRef = React.useRef(passedProps);
+ passedPropsRef.current = passedProps;
+
+ const { delayRender, continueRender } = useDelayRender();
+ const passThrough =
+ bothEnteringAndExiting && presentationDirection === "exiting";
+
+ const draw = React.useCallback(
+ (
+ 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,
+ });
+ continueRender(handle);
+ },
+ [delayRender, continueRender],
+ );
+
+ React.useLayoutEffect(() => {
+ if (passThrough) {
+ return;
+ }
+ const layout = layoutRef.current;
+ const output = outputRef.current;
+ if (!layout || !output) {
+ return;
+ }
+ const capture = takeOffscreen(layout);
+ const context = capture.getContext("2d");
+ if (!context) {
+ throw new Error("canvas-presentation: failed to acquire a 2D context");
+ }
+ const surface = takeOffscreen(output);
+ captureRef.current = capture;
+ captureContextRef.current = context;
+ outputSurfaceRef.current = surface;
+ instanceRef.current = shader(surface);
+
+ return () => {
+ instanceRef.current?.cleanup();
+ instanceRef.current = null;
+ captureRef.current = null;
+ captureContextRef.current = null;
+ outputSurfaceRef.current = null;
+ };
+ }, [passThrough, shader]);
+
+ React.useLayoutEffect(() => {
+ if (passThrough) {
+ return;
+ }
+ const layout = layoutRef.current;
+ if (!layout) {
+ return;
+ }
+ layout.layoutSubtree = true;
+ const handlePaint = () => {
+ const scene = layout.firstElementChild;
+ const capture = captureRef.current;
+ const context = captureContextRef.current;
+ if (!scene || !capture || !context) {
+ return;
+ }
+ const elementImage = layout.captureElementImage(scene);
+ try {
+ context.reset();
+ context.drawElementImage(elementImage, 0, 0);
+ } finally {
+ elementImage.close();
+ }
+ onElementImage(capture, draw);
+ };
+ layout.addEventListener("paint", handlePaint);
+ return () => layout.removeEventListener("paint", handlePaint);
+ }, [passThrough, onElementImage, draw]);
+
+ React.useLayoutEffect(() => {
+ if (passThrough) {
+ return;
+ }
+ const layout = layoutRef.current;
+ if (!layout) {
+ return;
+ }
+ const observer = new ResizeObserver(([entry]) => {
+ const capture = captureRef.current;
+ const surface = outputSurfaceRef.current;
+ if (!capture || !surface) {
+ return;
+ }
+ const width = entry.devicePixelContentBoxSize[0].inlineSize;
+ const height = entry.devicePixelContentBoxSize[0].blockSize;
+ capture.width = width;
+ capture.height = height;
+ surface.width = width;
+ surface.height = height;
+ layout.requestPaint?.();
+ });
+ observer.observe(layout, { box: "device-pixel-content-box" });
+ return () => observer.disconnect();
+ }, [passThrough]);
+
+ // biome-ignore lint/correctness/useExhaustiveDependencies: presentationProgress is the intentional trigger — a new progress value is what schedules the next paint
+ React.useLayoutEffect(() => {
+ if (passThrough) {
+ return;
+ }
+ layoutRef.current?.requestPaint?.();
+ }, [passThrough, presentationProgress]);
+
+ React.useLayoutEffect(() => {
+ if (passThrough) {
+ return;
+ }
+ return () => onUnmount();
+ }, [passThrough, onUnmount]);
+
+ if (passThrough) {
+ return <>{children}</>;
+ }
+
+ return (
+ <AbsoluteFill>
+ <canvas ref={layoutRef} style={LAYER}>
+ {children}
+ </canvas>
+ <canvas ref={outputRef} style={OUTPUT_LAYER} />
+ </AbsoluteFill>
+ );
+ };
+}
+
+export type CanvasPresentationOptions<Props extends Record<string, unknown>> = {
+ shader: SceneShader<Props>;
+ fallback: React.FC<TransitionPresentationComponentProps<Props>>;
+};
+
+export function makeCanvasPresentation<Props extends Record<string, unknown>>({
+ shader,
+ fallback: Fallback,
+}: CanvasPresentationOptions<Props>): (
+ props: Props,
+) => TransitionPresentation<Props> {
+ const Canvas = makeCanvasComponent(shader);
+
+ const Presentation: React.FC<TransitionPresentationComponentProps<Props>> = (
+ props,
+ ) =>
+ isCanvasTransitionSupported() ? (
+ <Canvas {...props} />
+ ) : (
+ <Fallback {...props} />
+ );
+
+ return (props) => ({ component: Presentation, props });
+}
diff --git a/registry/remocn/glitch-cut/config.ts b/registry/remocn/glitch-cut/config.ts
new file mode 100644
index 00000000..c834a93b
--- /dev/null
+++ b/registry/remocn/glitch-cut/config.ts
@@ -0,0 +1,47 @@
+import { glitchCutExampleCode } from "@/components/docs/examples/glitch-cut-example";
+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";
+
+export const glitchCutConfig: ComponentConfig = {
+ componentName: "glitchCut",
+ importPath: "@/components/remocn/glitch-cut",
+ controls: {
+ intensity: {
+ type: "number",
+ default: 1,
+ min: 0,
+ max: 2,
+ step: 0.1,
+ label: "Intensity",
+ },
+ slices: {
+ type: "number",
+ default: 24,
+ min: 8,
+ max: 64,
+ step: 2,
+ label: "Slices",
+ },
+ rgbSplit: {
+ type: "number",
+ default: 1,
+ min: 0,
+ max: 2,
+ step: 0.1,
+ label: "RGB split",
+ },
+ blockNoise: {
+ type: "number",
+ default: 0.6,
+ min: 0,
+ max: 1,
+ step: 0.05,
+ label: "Block noise",
+ },
+ },
+ durationInFrames: 78,
+ fps: FPS,
+ compositionWidth: W,
+ compositionHeight: H,
+ previewBackdrop: { type: "color", value: "#0a0a0a" },
+ snippet: glitchCutExampleCode,
+};
diff --git a/registry/remocn/glitch-cut/index.tsx b/registry/remocn/glitch-cut/index.tsx
new file mode 100644
index 00000000..df2bec0b
--- /dev/null
+++ b/registry/remocn/glitch-cut/index.tsx
@@ -0,0 +1,192 @@
+"use client";
+
+import type {
+ TransitionPresentation,
+ TransitionPresentationComponentProps,
+} from "@remotion/transitions";
+import type React from "react";
+import { AbsoluteFill, random } from "remotion";
+import {
+ makeCanvasPresentation,
+ makeSceneShader,
+} from "@/lib/remocn/canvas-presentation";
+
+export type GlitchCutProps = {
+ intensity?: number;
+ slices?: number;
+ rgbSplit?: number;
+ blockNoise?: number;
+};
+
+const DEFAULTS = {
+ intensity: 1,
+ slices: 24,
+ rgbSplit: 1,
+ blockNoise: 0.6,
+};
+
+const STEPS = 22;
+
+const FRAGMENT_SHADER = `#version 300 es
+precision highp float;
+
+uniform sampler2D u_from;
+uniform sampler2D u_to;
+uniform float u_progress;
+uniform float u_intensity;
+uniform float u_slices;
+uniform float u_rgb_split;
+uniform float u_block_noise;
+
+in vec2 v_uv;
+out vec4 outColor;
+
+const float PI = 3.141592653589793;
+const float STEPS = ${STEPS}.0;
+const float BLOCK_COLUMNS = 16.0;
+
+float hash(vec2 p) {
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
+}
+
+vec4 sampleSplit(sampler2D tex, vec2 uv, float split) {
+ vec4 center = texture(tex, uv);
+ float r = texture(tex, vec2(uv.x + split, uv.y)).r;
+ float b = texture(tex, vec2(uv.x - split, uv.y)).b;
+ return vec4(r, center.g, b, center.a);
+}
+
+void main() {
+ float energy = pow(max(sin(u_progress * PI), 0.0), 0.7);
+ float clock = floor(u_progress * STEPS);
+
+ float row = floor(v_uv.y * u_slices);
+ float torn = step(0.45, hash(vec2(row, clock)));
+ float amount = hash(vec2(row + 17.0, clock * 1.7 + 3.0)) - 0.5;
+ float sliceShift = amount * 0.3 * u_intensity * energy * torn;
+
+ vec2 block = vec2(floor(v_uv.x * BLOCK_COLUMNS), row);
+ float corrupt = step(
+ 1.0 - u_block_noise * 0.5 * energy,
+ hash(block + clock * 7.3)
+ );
+ float blockShift =
+ (hash(block + clock * 3.1 + 5.0) - 0.5) * 0.2 * u_intensity * corrupt;
+
+ vec2 uv = vec2(fract(v_uv.x + sliceShift + blockShift), v_uv.y);
+ float split = u_rgb_split * 0.018 * energy * (0.35 + abs(amount));
+
+ float cut = 0.5 + (hash(vec2(row, 91.0)) - 0.5) * 0.32;
+ float handed = step(cut, u_progress);
+
+ vec4 from = sampleSplit(u_from, uv, split);
+ vec4 to = sampleSplit(u_to, uv, split);
+ vec4 color = mix(from, to, handed);
+ vec4 leaked = mix(to, from, handed);
+
+ float leak = corrupt * step(0.55, hash(block + clock * 11.0 + 13.0));
+ color = mix(color, leaked, leak * 0.8);
+
+ color.rgb +=
+ vec3(0.05, 0.015, 0.09) *
+ energy *
+ torn *
+ hash(vec2(row, clock + 41.0)) *
+ color.a;
+
+ outColor = color;
+}`;
+
+const shader = makeSceneShader<GlitchCutProps>(
+ FRAGMENT_SHADER,
+ ({ gl, uniform, passedProps }) => {
+ const {
+ intensity = DEFAULTS.intensity,
+ slices = DEFAULTS.slices,
+ rgbSplit = DEFAULTS.rgbSplit,
+ blockNoise = DEFAULTS.blockNoise,
+ } = passedProps;
+ gl.uniform1f(uniform("u_intensity"), intensity);
+ gl.uniform1f(uniform("u_slices"), slices);
+ gl.uniform1f(uniform("u_rgb_split"), rgbSplit);
+ gl.uniform1f(uniform("u_block_noise"), blockNoise);
+ },
+);
+
+const bandCut = (band: number) =>
+ 0.5 + (random(`glitch-cut-handoff-${band}`) - 0.5) * 0.32;
+
+const GlitchCutFallback: React.FC<
+ TransitionPresentationComponentProps<GlitchCutProps>
+> = ({
+ children,
+ presentationProgress,
+ presentationDirection,
+ passedProps,
+}) => {
+ const {
+ intensity = DEFAULTS.intensity,
+ slices = DEFAULTS.slices,
+ rgbSplit = DEFAULTS.rgbSplit,
+ } = passedProps;
+ const entering = presentationDirection === "entering";
+ const p = presentationProgress;
+ const energy = Math.max(0, Math.sin(p * Math.PI)) ** 0.7;
+
+ if (energy < 0.002) {
+ const settled = entering ? (p >= 0.5 ? 1 : 0) : p < 0.5 ? 1 : 0;
+ return <AbsoluteFill style={{ opacity: settled }}>{children}</AbsoluteFill>;
+ }
+
+ const clock = Math.floor(p * STEPS);
+ const bands = Math.max(2, Math.min(6, Math.round(slices / 5)));
+ const height = 100 / bands;
+
+ return (
+ <AbsoluteFill>
+ {Array.from({ length: bands }, (_, band) => {
+ const shown = p >= bandCut(band) ? entering : !entering;
+ if (!shown) {
+ return null;
+ }
+ const shift =
+ (random(`glitch-cut-shift-${clock}-${band}`) - 0.5) *
+ 52 *
+ intensity *
+ energy;
+ const tint = band % 2 === 0 ? "rgb(255, 42, 90)" : "rgb(0, 224, 255)";
+ const tintOpacity =
+ rgbSplit * 0.2 * energy * random(`glitch-cut-tint-${clock}-${band}`);
+ return (
+ <AbsoluteFill
+ key={band}
+ style={{
+ clipPath: `inset(${band * height}% 0 ${100 - (band + 1) * height}% 0)`,
+ transform: `translateX(${shift}px)`,
+ }}
+ >
+ {children}
+ <AbsoluteFill
+ style={{
+ background: tint,
+ mixBlendMode: "screen",
+ opacity: tintOpacity,
+ }}
+ />
+ </AbsoluteFill>
+ );
+ })}
+ </AbsoluteFill>
+ );
+};
+
+const presentation = makeCanvasPresentation<GlitchCutProps>({
+ shader,
+ fallback: GlitchCutFallback,
+});
+
+export function glitchCut(
+ props: GlitchCutProps = {},
+): TransitionPresentation<GlitchCutProps> {
+ return presentation(props);
+}
diff --git a/registry/remocn/registry.json b/registry/remocn/registry.json
index 72174826..b0b81aee 100644
--- a/registry/remocn/registry.json
+++ b/registry/remocn/registry.json
@@ -1629,6 +1629,35 @@
"target": "components/remocn/spring-settle.tsx"
}
]
+ },
+ {
+ "name": "canvas-presentation",
+ "type": "registry:lib",
+ "title": "Canvas Presentation",
+ "description": "The html-in-canvas scaffolding the canvas transitions share: support detection, a full-screen WebGL2 scene shader over both sides of the cut, and routing to a CSS fallback where the browser lacks the API.",
+ "dependencies": ["remotion", "@remotion/transitions"],
+ "files": [
+ {
+ "path": "canvas-presentation/index.tsx",
+ "type": "registry:lib",
+ "target": "lib/remocn/canvas-presentation.tsx"
+ }
+ ]
+ },
+ {
+ "name": "glitch-cut",
+ "type": "registry:component",
+ "title": "Glitch Cut",
+ "description": "A broadcast-glitch hard cut: the frame tears into displaced slices with channel split and corrupted blocks, and the incoming scene takes over slice by slice at the peak.",
+ "dependencies": ["remotion", "@remotion/transitions"],
+ "registryDependencies": ["@remocn/canvas-presentation"],
+ "files": [
+ {
+ "path": "glitch-cut/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/glitch-cut.tsx"
+ }
+ ]
}
]
}
diff --git a/tsconfig.json b/tsconfig.json
index f6bedaa8..61743722 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -25,6 +25,9 @@
"@/lib/remocn-ui/*": ["./registry/remocn-ui/core/*"],
"@/lib/remocn/stop-motion": ["./registry/remocn/stop-motion/index.ts"],
"@/lib/remocn/scene-motion": ["./registry/remocn/scene-motion/index.ts"],
+ "@/lib/remocn/canvas-presentation": [
+ "./registry/remocn/canvas-presentation/index.tsx"
+ ],
"@/components/remocn/brush": ["./registry/remocn/brush/index.tsx"],
"@/components/remocn/handwrite": [
"./registry/remocn/handwrite/index.tsx"