Skip to content

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

feat: displacement

kapishdimacf2879f91f02
diff --git a/components/docs/examples/displacement-example.tsx b/components/docs/examples/displacement-example.tsx
new file mode 100644
index 00000000..09fd74d9
--- /dev/null
+++ b/components/docs/examples/displacement-example.tsx
@@ -0,0 +1,76 @@
+"use client";
+
+import { linearTiming, TransitionSeries } from "@remotion/transitions";
+import {
+ CanvasSceneA,
+ CanvasSceneB,
+} from "@/components/docs/examples/canvas-scenes";
+import { displacement } from "@/registry/remocn/displacement";
+
+interface DisplacementExampleProps {
+ grid?: number;
+ cellAspect?: number;
+ shift?: number;
+ aberration?: number;
+ grain?: number;
+ stagger?: number;
+}
+
+export function DisplacementExampleScene({
+ grid,
+ cellAspect,
+ shift,
+ aberration,
+ grain,
+ stagger,
+}: DisplacementExampleProps) {
+ return (
+ <TransitionSeries>
+ <TransitionSeries.Sequence durationInFrames={45}>
+ <CanvasSceneA />
+ </TransitionSeries.Sequence>
+ <TransitionSeries.Transition
+ timing={linearTiming({ durationInFrames: 18 })}
+ presentation={displacement({
+ grid,
+ cellAspect,
+ shift,
+ aberration,
+ grain,
+ stagger,
+ })}
+ />
+ <TransitionSeries.Sequence durationInFrames={45}>
+ <CanvasSceneB />
+ </TransitionSeries.Sequence>
+ </TransitionSeries>
+ );
+}
+
+export const displacementExampleCode = (
+ values: Record<string, unknown>,
+): string => {
+ const grid = (values.grid as number) ?? 60;
+ const cellAspect = (values.cellAspect as number) ?? 1;
+ const shift = (values.shift as number) ?? 1;
+ const aberration = (values.aberration as number) ?? 1;
+ const grain = (values.grain as number) ?? 0.5;
+ const stagger = (values.stagger as number) ?? 0.45;
+ return `import { TransitionSeries, linearTiming } from "@remotion/transitions";
+import { displacement } from "@/components/remocn/displacement";
+
+export const MyVideo = () => (
+ <TransitionSeries>
+ <TransitionSeries.Sequence durationInFrames={45}>
+ <SceneA />
+ </TransitionSeries.Sequence>
+ <TransitionSeries.Transition
+ timing={linearTiming({ durationInFrames: 18 })}
+ presentation={displacement({ grid: ${grid}, cellAspect: ${cellAspect}, shift: ${shift}, aberration: ${aberration}, grain: ${grain}, stagger: ${stagger} })}
+ />
+ <TransitionSeries.Sequence durationInFrames={45}>
+ <SceneB />
+ </TransitionSeries.Sequence>
+ </TransitionSeries>
+);`;
+};
diff --git a/config/site.ts b/config/site.ts
index d710c859..832b5dbb 100644
--- a/config/site.ts
+++ b/config/site.ts
@@ -87,6 +87,7 @@ export const NEW_BADGE_PATHS = new Set<string>([
"/docs/transitions/ember-burn",
"/docs/transitions/particle-dissolve",
"/docs/transitions/grid-wave",
+ "/docs/transitions/displacement",
]);
export type FooterGroup = {
diff --git a/content/changelog/2026-08-02-canvas-transitions.mdx b/content/changelog/2026-08-02-canvas-transitions.mdx
index 40ca949d..75c95854 100644
--- a/content/changelog/2026-08-02-canvas-transitions.mdx
+++ b/content/changelog/2026-08-02-canvas-transitions.mdx
@@ -13,6 +13,7 @@ Every transition in the catalog so far animates a scene from the outside — opa
- [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.
- [Particle Dissolve](/docs/transitions/particle-dissolve) — the frame is ground into fine dust. Each speck wanders away from the pixel it came from, and how far it gets is set by that pixel's brightness, so highlights and text disintegrate before flat background does. Colour drains out of the grain as it flies, red and blue fringe apart, and then the whole motion reverses and the next scene gathers out of the same dust.
- [Grid Wave](/docs/transitions/grid-wave) — a wave travels across the frame and wherever it passes the picture divides into cells that rise off the surface as solid blocks: a lit top face carrying its piece of the picture, a shaded side extruded below it, blocks occluding each other by height. Each block goes up with the outgoing scene and comes down with the incoming one, the hand-over hidden at the crest. Blocks rise from their own footprint, so the frame stays anchored while the wave travels through it, and nothing fades.
+- [Displacement](/docs/transitions/displacement) — the frame divides into a grid and every cell shears out of place at once, each on its own beat: the picture inside a cell slides away from where it belongs, its red and blue channels separate along the direction of travel, and film grain settles over the distortion. At the peak the cells hand over and slide back into register on the next scene.
- 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 89e57907..0b20e6c6 100644
--- a/content/docs/components.mdx
+++ b/content/docs/components.mdx
@@ -523,6 +523,12 @@ Scene transitions, camera moves, and stylized wipes.
status: "stable",
href: "/docs/transitions/grid-wave",
},
+ {
+ name: "Displacement",
+ description: "Shear the frame into a grid of offset colour-fringed tiles and settle them back on the next scene",
+ status: "stable",
+ href: "/docs/transitions/displacement",
+ },
]}
/>
diff --git a/content/docs/transitions/displacement.mdx b/content/docs/transitions/displacement.mdx
new file mode 100644
index 00000000..8cc7ea6e
--- /dev/null
+++ b/content/docs/transitions/displacement.mdx
@@ -0,0 +1,149 @@
+---
+title: Displacement
+description: Shear the frame into a grid of offset colour-fringed tiles under film grain and let them settle back on the next scene
+component: displacement
+vibe: tech
+length: 18
+useWhen:
+ - "A cut in a tech or interface demo should read as the picture being knocked out of register rather than blended."
+ - "The rhythm is fast — the whole frame displaces at once, so this lands in well under a second."
+ - "The scenes are structured and graphic, so tiles sliding out of alignment are legible as displacement."
+avoidWhen:
+ - "You want the tearing concentrated in horizontal bands with a hard cut — use `glitch-cut`."
+ - "The moment should feel calm or premium — this is a deliberate malfunction; use `zoom-blur`."
+---
+
+<ComponentPreview name="displacement" />
+
+<CanvasTransitionNote />
+
+## Installation
+
+<InstallBlock name="displacement" />
+
+## Usage
+
+`displacement()` is a Remotion transition presentation. Pass it to a
+`TransitionSeries.Transition` between two sequences. The frame divides into a
+grid of cells and every one of them shears out of place at once, each on its own
+beat: the picture inside a cell slides away from where it belongs, its colour
+channels separate along the direction of travel, and film grain settles over the
+distortion. At the peak the cells hand over, then slide back into register on the
+next scene.
+
+```tsx
+import { TransitionSeries, linearTiming } from "@remotion/transitions";
+import { displacement } from "@/components/remocn/displacement";
+
+export const MyVideo = () => (
+ <TransitionSeries>
+ <TransitionSeries.Sequence durationInFrames={45}>
+ <SceneA />
+ </TransitionSeries.Sequence>
+ <TransitionSeries.Transition
+ timing={linearTiming({ durationInFrames: 18 })}
+ presentation={displacement()}
+ />
+ <TransitionSeries.Sequence durationInFrames={45}>
+ <SceneB />
+ </TransitionSeries.Sequence>
+ </TransitionSeries>
+);
+```
+
+## Why this one needs the canvas
+
+Each cell samples its scene at a coordinate pushed away from the pixel being
+written, by its own seeded direction and distance — so a cell shows a piece of
+the picture that belongs somewhere else, and the misalignment between
+neighbouring cells is the whole effect. On top of that the red and blue channels
+are sampled at two further offsets along the direction of travel, so a displaced
+tile fringes exactly the way a channel that has slipped does.
+
+A mask cannot move image data. Nothing here is a fade, a tint, or a shaped
+reveal.
+
+## The whole frame at once
+
+There is no band travelling across the picture. Every cell displaces
+simultaneously, spread only by `stagger`, and every cell recovers. That is
+deliberate: a boundary sweeping over one scene to reveal another is a wipe, and
+a wipe does not need pixels — it would make the html-in-canvas dependency
+decorative.
+
+## The entrance mirrors the exit
+
+The same cell carries both scenes. It shears out holding the outgoing frame and
+returns holding the incoming one, and the hand-over sits at the peak of the
+shear, where the frame is furthest out of register and least readable. Played
+backwards the transition is the same displacement carrying the other scene.
+
+Both ends are exact: the shear follows a half-sine over each cell's own phase,
+so it is zero at both ends and every cell sits in register on an undistorted
+frame.
+
+## Determinism
+
+Each cell's direction, distance, phase and grain are seeded from its grid
+coordinate and evaluated as closed-form functions of the transition's progress —
+the grain advances on a clock derived from progress rather than from wall time,
+so there is nothing carried between frames. The same frame renders identically in
+every chunk of a parallel render.
+
+## Fallback
+
+Where html-in-canvas is unavailable the two scenes cross with a short lateral
+jolt in opposite directions. It keeps the knocked-out-of-register feeling and the
+timing; the per-cell shear needs the scenes' pixels, so none of the props apply
+there.
+
+## Props
+
+`displacement(props)` accepts:
+
+<PropsTable
+ rows={[
+ {
+ name: "grid",
+ type: "number",
+ default: "60",
+ description:
+ "Cells spanning the width of the frame. The default is a fine mesh; drop it toward 10 to shear the picture into large slabs instead.",
+ },
+ {
+ name: "cellAspect",
+ type: "number",
+ default: "1",
+ description:
+ "Width-to-height ratio of one cell. Values above 1 give wide, letterbox cells that read as scanline tearing; below 1 gives tall columns.",
+ },
+ {
+ name: "shift",
+ type: "number",
+ default: "1",
+ description:
+ "How far a cell travels at the peak of the shear, measured in cells — 1 is roughly its own width, so changing `grid` does not change how violent the effect looks. 0 leaves the grid in register so only the grain remains.",
+ },
+ {
+ name: "aberration",
+ type: "number",
+ default: "1",
+ description:
+ "Colour separation on a displaced cell, measured along its direction of travel. 0 keeps the tiles clean.",
+ },
+ {
+ name: "grain",
+ type: "number",
+ default: "0.5",
+ description:
+ "Opacity of the film grain over displaced cells. It rises and falls with the shear, so a settled frame is always clean.",
+ },
+ {
+ name: "stagger",
+ type: "number",
+ default: "0.45",
+ description:
+ "How far apart cells start their shear, as a share of the transition. 0 displaces the whole grid as one plane; high values leave a long tail of cells still out of register.",
+ },
+ ]}
+/>
diff --git a/content/docs/transitions/index.mdx b/content/docs/transitions/index.mdx
index aced2ae7..9dba43e8 100644
--- a/content/docs/transitions/index.mdx
+++ b/content/docs/transitions/index.mdx
@@ -152,6 +152,12 @@ Pixel-level transitions. These read the actual pixels of both scenes through the
status: "stable",
href: "/docs/transitions/grid-wave",
},
+ {
+ name: "Displacement",
+ description: "Shear the frame into a grid of offset colour-fringed tiles and settle them back on the next scene",
+ status: "stable",
+ href: "/docs/transitions/displacement",
+ },
]}
/>
diff --git a/content/docs/transitions/meta.json b/content/docs/transitions/meta.json
index d9f3c23d..4cda207e 100644
--- a/content/docs/transitions/meta.json
+++ b/content/docs/transitions/meta.json
@@ -23,6 +23,7 @@
"ember-burn",
"particle-dissolve",
"grid-wave",
+ "displacement",
"slide-swap",
"spring-settle"
]
diff --git a/registry-artifacts/displacement.json b/registry-artifacts/displacement.json
new file mode 100644
index 00000000..b080e7cf
--- /dev/null
+++ b/registry-artifacts/displacement.json
@@ -0,0 +1,17 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "displacement",
+ "title": "Displacement",
+ "description": "The frame breaks into a grid of cells that shear apart into offset, colour-fringed tiles under film grain, then settle back carrying the next scene.",
+ "dependencies": ["remotion", "@remotion/transitions"],
+ "registryDependencies": ["@remocn/canvas-presentation"],
+ "files": [
+ {
+ "path": "registry/remocn/displacement/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 DisplacementProps = {\n grid?: number;\n cellAspect?: number;\n shift?: number;\n aberration?: number;\n grain?: number;\n stagger?: number;\n};\n\nconst DEFAULTS = {\n grid: 60,\n cellAspect: 1,\n shift: 1,\n aberration: 1,\n grain: 0.5,\n stagger: 0.45,\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 vec2 u_cells;\nuniform float u_shift;\nuniform float u_aberration;\nuniform float u_grain;\nuniform float u_stagger;\n\nin vec2 v_uv;\nout vec4 outColor;\n\nconst float PI = 3.141592653589793;\n\nfloat hash(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);\n}\n\nvoid main() {\n vec2 cell = floor(v_uv * u_cells);\n float h1 = hash(cell);\n float h2 = hash(cell + 7.3);\n float h3 = hash(cell + 13.1);\n\n float delay = h3 * u_stagger;\n float phase =\n clamp((u_progress - delay) / max(1.0 - u_stagger, 0.1), 0.0, 1.0);\n float shear = sin(phase * PI);\n\n vec2 aim = vec2((h1 - 0.5) * 2.0, (h2 - 0.5) * 0.7);\n vec2 dir = aim / max(length(aim), 0.0001);\n vec2 slide = dir * shear * u_shift * 1.4;\n vec2 off = slide / u_cells;\n vec2 fringe = off * u_aberration * 0.35;\n\n float swap = smoothstep(0.34, 0.66, phase);\n\n vec4 mid = mix(\n texture(u_from, v_uv - off),\n texture(u_to, v_uv - off),\n swap\n );\n float red = mix(\n texture(u_from, v_uv - off - fringe).r,\n texture(u_to, v_uv - off - fringe).r,\n swap\n );\n float blue = mix(\n texture(u_from, v_uv - off + fringe).b,\n texture(u_to, v_uv - off + fringe).b,\n swap\n );\n\n vec4 col = vec4(red, mid.g, blue, mid.a);\n\n float tick = floor(u_progress * 30.0);\n float speck =\n hash(floor(v_uv * vec2(u_aspect, 1.0) * 460.0) + tick * 1.7) - 0.5;\n col.rgb += vec3(speck * u_grain * shear * 0.5) * col.a;\n col.rgb *= 1.0 - 0.12 * shear;\n\n outColor = col;\n}`;\n\nconst shader = makeSceneShader<DisplacementProps>(\n FRAGMENT_SHADER,\n ({ gl, uniform, width, height, passedProps }) => {\n const {\n grid = DEFAULTS.grid,\n cellAspect = DEFAULTS.cellAspect,\n shift = DEFAULTS.shift,\n aberration = DEFAULTS.aberration,\n grain = DEFAULTS.grain,\n stagger = DEFAULTS.stagger,\n } = passedProps;\n const across = Math.max(grid, 4);\n const ratio = Math.max(cellAspect, 0.25);\n gl.uniform2f(\n uniform(\"u_cells\"),\n across,\n Math.max((across * ratio * height) / width, 2),\n );\n gl.uniform1f(uniform(\"u_shift\"), shift);\n gl.uniform1f(uniform(\"u_aberration\"), aberration);\n gl.uniform1f(uniform(\"u_grain\"), grain);\n gl.uniform1f(uniform(\"u_stagger\"), Math.min(Math.max(stagger, 0), 0.85));\n },\n);\n\nconst DisplacementFallback: React.FC<\n TransitionPresentationComponentProps<DisplacementProps>\n> = ({ children, presentationProgress, presentationDirection }) => {\n const p = presentationProgress;\n const entering = presentationDirection === \"entering\";\n const t = entering ? p : 1 - p;\n const settle = Math.min(1, Math.max(0, (t - 0.3) / 0.4));\n const jolt = Math.max(0, Math.sin(t * Math.PI)) * 10;\n\n return (\n <AbsoluteFill\n style={{\n opacity: settle,\n transform: `translateX(${entering ? jolt : -jolt}px)`,\n }}\n >\n {children}\n </AbsoluteFill>\n );\n};\n\nconst presentation = makeCanvasPresentation<DisplacementProps>({\n shader,\n fallback: DisplacementFallback,\n});\n\nexport function displacement(\n props: DisplacementProps = {},\n): TransitionPresentation<DisplacementProps> {\n return presentation(props);\n}\n",
+ "type": "registry:component",
+ "target": "components/remocn/displacement.tsx"
+ }
+ ],
+ "type": "registry:component"
+}
diff --git a/registry-artifacts/registry.json b/registry-artifacts/registry.json
index 0b903afe..20e6fc13 100644
--- a/registry-artifacts/registry.json
+++ b/registry-artifacts/registry.json
@@ -1659,6 +1659,21 @@
],
"type": "registry:component"
},
+ {
+ "name": "displacement",
+ "title": "Displacement",
+ "description": "The frame breaks into a grid of cells that shear apart into offset, colour-fringed tiles under film grain, then settle back carrying the next scene.",
+ "dependencies": ["remotion", "@remotion/transitions"],
+ "registryDependencies": ["@remocn/canvas-presentation"],
+ "files": [
+ {
+ "path": "registry/remocn/displacement/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/displacement.tsx"
+ }
+ ],
+ "type": "registry:component"
+ },
{
"name": "grid-wave",
"title": "Grid Wave",
diff --git a/registry/__index__.tsx b/registry/__index__.tsx
index 2e156ec4..1ecb7601 100644
--- a/registry/__index__.tsx
+++ b/registry/__index__.tsx
@@ -16,6 +16,7 @@ import { claudeCodeConfig } from "@/registry/remocn/claude-code/config";
import { confettiConfig } from "@/registry/remocn/confetti/config";
import { crumpleTossConfig } from "@/registry/remocn/crumple-toss/config";
import { dataFlowPipesConfig } from "@/registry/remocn/data-flow-pipes/config";
+import { displacementConfig } from "@/registry/remocn/displacement/config";
import { ditherDissolveConfig } from "@/registry/remocn/dither-dissolve/config";
import { driftConfig } from "@/registry/remocn/drift/config";
import { ecosystemConstellationConfig } from "@/registry/remocn/ecosystem-constellation/config";
@@ -1449,6 +1450,13 @@ const registry: Record<string, RegistryEntry> = {
})),
config: gridWaveConfig,
},
+ displacement: {
+ load: () =>
+ import("@/components/docs/examples/displacement-example").then((m) => ({
+ default: m.DisplacementExampleScene,
+ })),
+ config: displacementConfig,
+ },
"slide-swap": {
load: () =>
import("@/components/docs/examples/slide-swap-example").then((m) => ({
diff --git a/registry/remocn/displacement/config.ts b/registry/remocn/displacement/config.ts
new file mode 100644
index 00000000..0b4353de
--- /dev/null
+++ b/registry/remocn/displacement/config.ts
@@ -0,0 +1,63 @@
+import { displacementExampleCode } from "@/components/docs/examples/displacement-example";
+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";
+
+export const displacementConfig: ComponentConfig = {
+ componentName: "displacement",
+ importPath: "@/components/remocn/displacement",
+ controls: {
+ grid: {
+ type: "number",
+ default: 60,
+ min: 4,
+ max: 100,
+ step: 2,
+ label: "Grid",
+ },
+ cellAspect: {
+ type: "number",
+ default: 1,
+ min: 0.25,
+ max: 4,
+ step: 0.25,
+ label: "Cell aspect",
+ },
+ shift: {
+ type: "number",
+ default: 1,
+ min: 0,
+ max: 4,
+ step: 0.1,
+ label: "Shift",
+ },
+ aberration: {
+ type: "number",
+ default: 1,
+ min: 0,
+ max: 3,
+ step: 0.1,
+ label: "Aberration",
+ },
+ grain: {
+ type: "number",
+ default: 0.5,
+ min: 0,
+ max: 1,
+ step: 0.05,
+ label: "Grain",
+ },
+ stagger: {
+ type: "number",
+ default: 0.45,
+ min: 0,
+ max: 0.85,
+ step: 0.05,
+ label: "Stagger",
+ },
+ },
+ durationInFrames: 72,
+ fps: FPS,
+ compositionWidth: W,
+ compositionHeight: H,
+ previewBackdrop: { type: "color", value: "#0a0a0a" },
+ snippet: displacementExampleCode,
+};
diff --git a/registry/remocn/displacement/index.tsx b/registry/remocn/displacement/index.tsx
new file mode 100644
index 00000000..fcef7e50
--- /dev/null
+++ b/registry/remocn/displacement/index.tsx
@@ -0,0 +1,155 @@
+"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 DisplacementProps = {
+ grid?: number;
+ cellAspect?: number;
+ shift?: number;
+ aberration?: number;
+ grain?: number;
+ stagger?: number;
+};
+
+const DEFAULTS = {
+ grid: 60,
+ cellAspect: 1,
+ shift: 1,
+ aberration: 1,
+ grain: 0.5,
+ stagger: 0.45,
+};
+
+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 vec2 u_cells;
+uniform float u_shift;
+uniform float u_aberration;
+uniform float u_grain;
+uniform float u_stagger;
+
+in vec2 v_uv;
+out vec4 outColor;
+
+const float PI = 3.141592653589793;
+
+float hash(vec2 p) {
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
+}
+
+void main() {
+ vec2 cell = floor(v_uv * u_cells);
+ float h1 = hash(cell);
+ float h2 = hash(cell + 7.3);
+ float h3 = hash(cell + 13.1);
+
+ float delay = h3 * u_stagger;
+ float phase =
+ clamp((u_progress - delay) / max(1.0 - u_stagger, 0.1), 0.0, 1.0);
+ float shear = sin(phase * PI);
+
+ vec2 aim = vec2((h1 - 0.5) * 2.0, (h2 - 0.5) * 0.7);
+ vec2 dir = aim / max(length(aim), 0.0001);
+ vec2 slide = dir * shear * u_shift * 1.4;
+ vec2 off = slide / u_cells;
+ vec2 fringe = off * u_aberration * 0.35;
+
+ float swap = smoothstep(0.34, 0.66, phase);
+
+ vec4 mid = mix(
+ texture(u_from, v_uv - off),
+ texture(u_to, v_uv - off),
+ swap
+ );
+ float red = mix(
+ texture(u_from, v_uv - off - fringe).r,
+ texture(u_to, v_uv - off - fringe).r,
+ swap
+ );
+ float blue = mix(
+ texture(u_from, v_uv - off + fringe).b,
+ texture(u_to, v_uv - off + fringe).b,
+ swap
+ );
+
+ vec4 col = vec4(red, mid.g, blue, mid.a);
+
+ float tick = floor(u_progress * 30.0);
+ float speck =
+ hash(floor(v_uv * vec2(u_aspect, 1.0) * 460.0) + tick * 1.7) - 0.5;
+ col.rgb += vec3(speck * u_grain * shear * 0.5) * col.a;
+ col.rgb *= 1.0 - 0.12 * shear;
+
+ outColor = col;
+}`;
+
+const shader = makeSceneShader<DisplacementProps>(
+ FRAGMENT_SHADER,
+ ({ gl, uniform, width, height, passedProps }) => {
+ const {
+ grid = DEFAULTS.grid,
+ cellAspect = DEFAULTS.cellAspect,
+ shift = DEFAULTS.shift,
+ aberration = DEFAULTS.aberration,
+ grain = DEFAULTS.grain,
+ stagger = DEFAULTS.stagger,
+ } = passedProps;
+ const across = Math.max(grid, 4);
+ const ratio = Math.max(cellAspect, 0.25);
+ gl.uniform2f(
+ uniform("u_cells"),
+ across,
+ Math.max((across * ratio * height) / width, 2),
+ );
+ gl.uniform1f(uniform("u_shift"), shift);
+ gl.uniform1f(uniform("u_aberration"), aberration);
+ gl.uniform1f(uniform("u_grain"), grain);
+ gl.uniform1f(uniform("u_stagger"), Math.min(Math.max(stagger, 0), 0.85));
+ },
+);
+
+const DisplacementFallback: React.FC<
+ TransitionPresentationComponentProps<DisplacementProps>
+> = ({ children, presentationProgress, presentationDirection }) => {
+ const p = presentationProgress;
+ const entering = presentationDirection === "entering";
+ const t = entering ? p : 1 - p;
+ const settle = Math.min(1, Math.max(0, (t - 0.3) / 0.4));
+ const jolt = Math.max(0, Math.sin(t * Math.PI)) * 10;
+
+ return (
+ <AbsoluteFill
+ style={{
+ opacity: settle,
+ transform: `translateX(${entering ? jolt : -jolt}px)`,
+ }}
+ >
+ {children}
+ </AbsoluteFill>
+ );
+};
+
+const presentation = makeCanvasPresentation<DisplacementProps>({
+ shader,
+ fallback: DisplacementFallback,
+});
+
+export function displacement(
+ props: DisplacementProps = {},
+): TransitionPresentation<DisplacementProps> {
+ return presentation(props);
+}
diff --git a/registry/remocn/registry.json b/registry/remocn/registry.json
index 8d1d8fdd..3251d7d4 100644
--- a/registry/remocn/registry.json
+++ b/registry/remocn/registry.json
@@ -1659,6 +1659,21 @@
}
]
},
+ {
+ "name": "displacement",
+ "type": "registry:component",
+ "title": "Displacement",
+ "description": "The frame breaks into a grid of cells that shear apart into offset, colour-fringed tiles under film grain, then settle back carrying the next scene.",
+ "dependencies": ["remotion", "@remotion/transitions"],
+ "registryDependencies": ["@remocn/canvas-presentation"],
+ "files": [
+ {
+ "path": "displacement/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/displacement.tsx"
+ }
+ ]
+ },
{
"name": "grid-wave",
"type": "registry:component",
diff --git a/src/remotion/canvas-spike-root.tsx b/src/remotion/canvas-spike-root.tsx
index 651a3f09..ecf7d2a9 100644
--- a/src/remotion/canvas-spike-root.tsx
+++ b/src/remotion/canvas-spike-root.tsx
@@ -6,11 +6,13 @@ import {
isHtmlInCanvasSupported,
registerRoot,
} from "remotion";
+import { DisplacementExampleScene } from "@/components/docs/examples/displacement-example";
import { EmberBurnExampleScene } from "@/components/docs/examples/ember-burn-example";
import { GlitchCutExampleScene } from "@/components/docs/examples/glitch-cut-example";
import { GridWaveExampleScene } from "@/components/docs/examples/grid-wave-example";
import { ParticleDissolveExampleScene } from "@/components/docs/examples/particle-dissolve-example";
import type { ComponentConfig } from "@/lib/customizer-config";
+import { displacementConfig } from "@/registry/remocn/displacement/config";
import { emberBurnConfig } from "@/registry/remocn/ember-burn/config";
import { glitchCutConfig } from "@/registry/remocn/glitch-cut/config";
import { gridWaveConfig } from "@/registry/remocn/grid-wave/config";
@@ -36,6 +38,10 @@ const SCENES: Record<
config: particleDissolveConfig,
},
"grid-wave": { Scene: GridWaveExampleScene, config: gridWaveConfig },
+ displacement: {
+ Scene: DisplacementExampleScene,
+ config: displacementConfig,
+ },
};
function makeStage(Scene: ComponentType) {