Skip to content

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

feat: camera lens

kapishdima2d77903e9515
diff --git a/components/docs/examples/camera-lens-example.tsx b/components/docs/examples/camera-lens-example.tsx
new file mode 100644
index 00000000..b90af44b
--- /dev/null
+++ b/components/docs/examples/camera-lens-example.tsx
@@ -0,0 +1,55 @@
+"use client";
+
+import { CanvasSceneB } from "@/components/docs/examples/canvas-scenes";
+import { CameraLens } from "@/registry/remocn/camera-lens";
+
+interface CameraLensExampleProps {
+ softness?: number;
+ bloom?: number;
+ aberration?: number;
+ vignette?: number;
+ distortion?: number;
+}
+
+export function CameraLensExampleScene({
+ softness,
+ bloom,
+ aberration,
+ vignette,
+ distortion,
+}: CameraLensExampleProps) {
+ return (
+ <CameraLens
+ softness={softness}
+ bloom={bloom}
+ aberration={aberration}
+ vignette={vignette}
+ distortion={distortion}
+ >
+ <CanvasSceneB />
+ </CameraLens>
+ );
+}
+
+export const cameraLensExampleCode = (
+ values: Record<string, unknown>,
+): string => {
+ const softness = (values.softness as number) ?? 0.5;
+ const bloom = (values.bloom as number) ?? 0.5;
+ const aberration = (values.aberration as number) ?? 0.5;
+ const vignette = (values.vignette as number) ?? 0.5;
+ const distortion = (values.distortion as number) ?? 0.05;
+ return `import { CameraLens } from "@/components/remocn/camera-lens";
+
+export const MyScene = () => (
+ <CameraLens
+ softness={${softness}}
+ bloom={${bloom}}
+ aberration={${aberration}}
+ vignette={${vignette}}
+ distortion={${distortion}}
+ >
+ <Scene />
+ </CameraLens>
+);`;
+};
diff --git a/components/docs/examples/camera-lens-recipes.tsx b/components/docs/examples/camera-lens-recipes.tsx
new file mode 100644
index 00000000..a215248a
--- /dev/null
+++ b/components/docs/examples/camera-lens-recipes.tsx
@@ -0,0 +1,36 @@
+"use client";
+
+import { interpolate, useCurrentFrame } from "remotion";
+import {
+ CanvasSceneA,
+ CanvasSceneB,
+} from "@/components/docs/examples/canvas-scenes";
+import { CameraLens } from "@/registry/remocn/camera-lens";
+import { Drift } from "@/registry/remocn/drift";
+
+export function LensContributionExampleScene() {
+ const frame = useCurrentFrame();
+ const amount = interpolate(frame, [0, 34, 62, 96], [0, 1, 1, 0]);
+
+ return (
+ <CameraLens
+ softness={0.5 * amount}
+ bloom={0.5 * amount}
+ aberration={0.5 * amount}
+ vignette={0.5 * amount}
+ distortion={0.05 * amount}
+ >
+ <CanvasSceneB />
+ </CameraLens>
+ );
+}
+
+export function LensHandheldExampleScene() {
+ return (
+ <CameraLens>
+ <Drift grow={0.06}>
+ <CanvasSceneA />
+ </Drift>
+ </CameraLens>
+ );
+}
diff --git a/components/docs/examples/index.tsx b/components/docs/examples/index.tsx
index 6d7314b7..f5d91c9d 100644
--- a/components/docs/examples/index.tsx
+++ b/components/docs/examples/index.tsx
@@ -16,6 +16,10 @@ import {
} from "./ascii-render-recipes";
import { BlurInExampleScene, blurInExampleCode } from "./blur-in-example";
import { ButtonExampleScene, buttonExampleCode } from "./button-example";
+import {
+ LensContributionExampleScene,
+ LensHandheldExampleScene,
+} from "./camera-lens-recipes";
import { CheckboxExampleScene, checkboxExampleCode } from "./checkbox-example";
import { ComboboxExampleScene, comboboxExampleCode } from "./combobox-example";
import {
@@ -515,6 +519,25 @@ export const examples: Record<string, ExampleEntry> = {
height: H,
previewBackdrop: { type: "color", value: "#06171c" },
},
+ "lens-contribution-example": {
+ Component: LensContributionExampleScene,
+ code: "<CameraLens softness={0.5} bloom={0.5} aberration={0.5} />",
+ // Ramps the whole lens on and back off so the contribution is visible.
+ durationInFrames: 96,
+ fps: FPS,
+ width: W,
+ height: H,
+ previewBackdrop: { type: "color", value: "#0a0a0a" },
+ },
+ "lens-handheld-example": {
+ Component: LensHandheldExampleScene,
+ code: "<CameraLens><Drift grow={0.06} /></CameraLens>",
+ durationInFrames: 120,
+ fps: FPS,
+ width: W,
+ height: H,
+ previewBackdrop: { type: "color", value: "#0a0a0a" },
+ },
"ripple-backdrop-example": {
Component: RippleBackdropExampleScene,
code: "<UnderwaterRipple amplitude={14} scale={0.8} speed={2} />",
diff --git a/content/changelog/2026-08-02-filters-optics.mdx b/content/changelog/2026-08-02-filters-optics.mdx
new file mode 100644
index 00000000..d2c828b1
--- /dev/null
+++ b/content/changelog/2026-08-02-filters-optics.mdx
@@ -0,0 +1,16 @@
+---
+title: Filters gain optics
+date: 2026-08-02
+---
+
+The first seven filters were looks you put on a scene deliberately — tape, a tube, print, water. This next run is quieter and aimed at the thing most demos actually need: making a recording stop looking like a render. It starts with the lens.
+
+<ChangelogPreview name="camera-lens" />
+
+### New components
+
+- [Camera Lens](/docs/filters/components/camera-lens) — a scene put behind real glass. Resolution falls off toward the corners while the middle stays fully sharp, highlights bloom out into what surrounds them, colour fringes where the channels stop agreeing at the edges, and light drops away on the cos⁴ curve real optics follow. The obvious way to build a lens is to bend the frame, but bending is what a tube does — what separates glass from a display is light, not geometry, so `distortion` starts near zero and the defaults are made of softness and bloom. Quiet enough to leave running under a whole demo; you notice it by switching it off.
+
+### Improvements
+
+- The filters that could be mistaken for each other are now split by what they are, not by how they look. `crt-screen` is a tube you watch — uniformly sharp behind a mask. `camera-lens` is glass you shoot through — sharp in one place and losing resolution everywhere else. `vhs-filter` is the signal arriving. Each one's `avoidWhen` names the others, so an agent picking a treatment cannot stack two that tell the same story.
diff --git a/content/docs/filters/components/camera-lens.mdx b/content/docs/filters/components/camera-lens.mdx
new file mode 100644
index 00000000..7c1d0389
--- /dev/null
+++ b/content/docs/filters/components/camera-lens.mdx
@@ -0,0 +1,162 @@
+---
+title: Camera Lens
+description: Put a scene behind real glass — resolution falling toward the corners, blooming highlights, edge fringing
+component: camera-lens
+vibe: premium
+length: sustained
+useWhen:
+ - "A screencast looks sterile and you want it to read as filmed — this is the cheapest way to stop a recording looking like a render."
+ - "You want a treatment subtle enough to leave running under a whole demo rather than an effect that announces itself."
+ - "A camera move lives inside it — the scene travels behind stationary glass, so different parts of the picture take their turn in the soft corners."
+avoidWhen:
+ - "The story is a tube being watched — use `crt-screen`, which is uniformly sharp behind a phosphor mask and scanlines."
+ - "The story is a worn signal rather than the optics carrying it — use `vhs-filter`."
+ - "You want a band of the frame sharp and the rest thrown out — that is depth of field, not lens character."
+---
+
+<ComponentPreview name="camera-lens" />
+
+<CanvasFilterNote />
+
+## Installation
+
+<InstallBlock name="camera-lens" />
+
+## Usage
+
+`CameraLens` is a wrapper. Put a scene inside it and it comes back as something
+that was photographed: sharp in the middle and softening toward the corners,
+highlights blooming out through the glass, colour fringing where the channels
+stop agreeing at the edges, and light falling off gently at the rim.
+
+```tsx
+import { CameraLens } from "@/components/remocn/camera-lens";
+
+export const MyScene = () => (
+ <CameraLens>
+ <Scene />
+ </CameraLens>
+);
+```
+
+## Why this is not a curved screen
+
+The obvious way to build a lens is to bend the frame, but bending is what a tube
+does — reach for that and you get `crt-screen` with the scanlines missing. What
+separates glass from a display is **light**, not geometry.
+
+A CRT is uniformly sharp across its whole surface and puts a mask over it. A lens
+is sharp in one place and loses resolution everywhere else, and it scatters
+bright light into the area around it. Those two things are what the defaults here
+are made of; `distortion` exists but starts near zero, because modern glass barely
+bends anything and leaning on it is exactly what makes a lens read as a monitor.
+
+## What to reach for it for
+
+### The pass that stops it looking rendered
+
+The defaults are quiet on purpose — quiet enough to leave on for a whole demo.
+The preview ramps the whole lens on and back off, because the honest way to judge
+it is to see what disappears when you turn it off rather than what appears when
+you turn it on.
+
+<ComponentExample name="lens-contribution" />
+
+```tsx
+<CameraLens>
+ <Screencast />
+</CameraLens>
+```
+
+### Hand it a camera move
+
+The lens is optics, not motion — it never moves on its own. Put a slow push
+inside it and the two together read as a shot: the scene travels, and the
+travelling content passes through stationary glass, so different parts of the
+picture take their turn in the soft corners.
+
+<ComponentExample name="lens-handheld" />
+
+```tsx
+import { CameraLens } from "@/components/remocn/camera-lens";
+import { Drift } from "@/components/remocn/drift";
+
+export const MyScene = () => (
+ <CameraLens>
+ <Drift grow={0.06}>
+ <Scene />
+ </Drift>
+ </CameraLens>
+);
+```
+
+Order matters. `Drift` goes inside so the scene moves behind stationary glass. Put
+the lens inside the drift instead and you would be scaling the optics themselves,
+which is a lens breathing rather than a camera pushing in.
+
+## Props
+
+<PropsTable
+ rows={[
+ {
+ name: "softness",
+ type: "number",
+ default: "0.5",
+ description:
+ "How much resolution the corners lose. The blur radius grows with distance from centre, so the middle of the frame stays fully sharp — this is the single strongest signal that a picture came through glass.",
+ },
+ {
+ name: "bloom",
+ type: "number",
+ default: "0.5",
+ description:
+ "How far bright areas scatter into what surrounds them. Only the highlights bloom, so dark UI stays clean and a white panel glows at its edges.",
+ },
+ {
+ name: "aberration",
+ type: "number",
+ default: "0.5",
+ description:
+ "How far the colour channels stop agreeing. Scales with radius, so the centre stays neutral and the fringing lives at the edges where a real lens puts it.",
+ },
+ {
+ name: "vignette",
+ type: "number",
+ default: "0.5",
+ description:
+ "Light falloff toward the rim, on the cos⁴ curve real optics follow. Smooth rather than drawn, so it reads as the lens rather than as a dark ring.",
+ },
+ {
+ name: "distortion",
+ type: "number",
+ default: "0.05",
+ description:
+ "Barrel bend. Near zero by default because modern glass barely bends anything, and because leaning on it is what makes a lens start reading as a CRT. Raise it for a wide-angle look or during a punch.",
+ },
+ {
+ name: "children",
+ type: "React.ReactNode",
+ description: "The scene the filter wraps and re-reads every frame.",
+ },
+ ]}
+/>
+
+## Notes
+
+Nothing animates. The lens is fixed optics re-reading the scene every frame, so a
+still scene is pixel-identical frame to frame and any movement belongs to what you
+put inside the wrapper.
+
+This is the heaviest shader in the pack so far — the corner blur and the bloom
+are both multi-tap gathers, and the aberration runs the blur three times. It is
+comfortable on a GPU; on a software renderer (`--gl=swangle`) expect it to be
+noticeably slower than the rest of the category.
+
+The filter expects a full-bleed scene. It reads pixels from displaced
+coordinates, so where the scene is transparent it has nothing to gather — put a
+background inside the wrapper rather than behind it.
+
+In browsers without html-in-canvas the scene keeps a bloom approximation and the
+vignette but not the per-pixel corner softness. CSS has one blur radius for a
+whole element, and a radius that varies across the frame is precisely the part
+that cannot be faked.
diff --git a/content/docs/filters/components/crt-screen.mdx b/content/docs/filters/components/crt-screen.mdx
index 9076eeea..f02fb274 100644
--- a/content/docs/filters/components/crt-screen.mdx
+++ b/content/docs/filters/components/crt-screen.mdx
@@ -10,6 +10,7 @@ useWhen:
- "The scene is high contrast — bright text on a dark field is what the phosphor mask and bloom were built to render."
avoidWhen:
- "The story is worn tape rather than a monitor — use `vhs-filter`, which degrades the signal instead of the display."
+ - "You want the scene to read as photographed rather than displayed — use `camera-lens`, which loses resolution toward the corners and blooms highlights instead of masking the picture."
- "Content sits close to the frame edge, since the barrel warp pushes the corners past the picture and they fall into the rim."
---
diff --git a/content/docs/filters/components/meta.json b/content/docs/filters/components/meta.json
index 4c6467c5..0c5fa541 100644
--- a/content/docs/filters/components/meta.json
+++ b/content/docs/filters/components/meta.json
@@ -2,6 +2,7 @@
"title": "Filters",
"collapsible": false,
"pages": [
+ "camera-lens",
"vhs-filter",
"crt-screen",
"sustained-glitch",
diff --git a/content/docs/filters/components/vhs-filter.mdx b/content/docs/filters/components/vhs-filter.mdx
index e936bf96..f3c7a62a 100644
--- a/content/docs/filters/components/vhs-filter.mdx
+++ b/content/docs/filters/components/vhs-filter.mdx
@@ -11,7 +11,7 @@ useWhen:
avoidWhen:
- "The artifact should live only at the cut between two scenes — use `glitch-cut`."
- "Only a headline should break up while the scene behind it stays clean — use `rgb-glitch-text`."
- - "The story is the display the scene sits on rather than the signal reaching it — use `crt-screen`."
+ - "The story is the display the scene sits on or the glass it was shot through, rather than the signal reaching it — use `crt-screen` or `camera-lens`."
- "You want intermittent digital faults rather than continuous analog wear — use `sustained-glitch`."
---
diff --git a/registry-artifacts/camera-lens.json b/registry-artifacts/camera-lens.json
new file mode 100644
index 00000000..346a5a18
--- /dev/null
+++ b/registry-artifacts/camera-lens.json
@@ -0,0 +1,17 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "camera-lens",
+ "title": "Camera Lens",
+ "description": "Put a scene behind real glass: resolution falls off toward the corners, highlights bloom through the optics, colour fringes at the edges — a screencast that reads as filmed rather than rendered.",
+ "dependencies": ["remotion"],
+ "registryDependencies": ["@remocn/canvas-presentation"],
+ "files": [
+ {
+ "path": "registry/remocn/camera-lens/index.tsx",
+ "content": "\"use client\";\n\nimport type React from \"react\";\nimport { AbsoluteFill } from \"remotion\";\nimport {\n type CanvasFilterProps,\n makeCanvasFilter,\n makeFilterShader,\n} from \"@/lib/remocn/canvas-presentation\";\n\nexport type CameraLensProps = {\n softness?: number;\n bloom?: number;\n aberration?: number;\n vignette?: number;\n distortion?: number;\n};\n\nconst DEFAULTS = {\n softness: 0.5,\n bloom: 0.5,\n aberration: 0.5,\n vignette: 0.5,\n distortion: 0.05,\n};\n\nconst FRAGMENT_SHADER = `#version 300 es\nprecision highp float;\n\nuniform sampler2D u_scene;\nuniform float u_aspect;\nuniform float u_softness;\nuniform float u_bloom;\nuniform float u_aberration;\nuniform float u_vignette;\nuniform float u_distortion;\n\nin vec2 v_uv;\nout vec4 outColor;\n\nconst int SOFT_TAPS = 6;\nconst int GLARE_TAPS = 8;\nconst float GOLDEN = 2.39996323;\n\nvec2 lensUv(vec2 direction, float distance) {\n vec2 q = direction * distance;\n q.x /= u_aspect;\n return q * 0.5 + 0.5;\n}\n\nvec2 spiral(int index, int count, float radius, float turn) {\n float angle = float(index) * GOLDEN + turn;\n float step = sqrt((float(index) + 0.5) / float(count)) * radius;\n return vec2(cos(angle) * step / u_aspect, sin(angle) * step);\n}\n\nvec4 softSample(vec2 uv, float radius) {\n vec4 sum = texture(u_scene, uv);\n if (radius <= 0.00002) {\n return sum;\n }\n for (int i = 0; i < SOFT_TAPS; i++) {\n sum += texture(u_scene, uv + spiral(i, SOFT_TAPS, radius, 0.0));\n }\n return sum / float(SOFT_TAPS + 1);\n}\n\nvoid main() {\n vec2 p = (v_uv - 0.5) * 2.0;\n p.x *= u_aspect;\n\n float span = sqrt(u_aspect * u_aspect + 1.0);\n float reach = length(p);\n float radius = reach / span;\n vec2 direction = reach > 0.0001 ? p / reach : vec2(0.0);\n\n float bend = 1.0 / (1.0 + clamp(u_distortion, 0.0, 1.0) * radius * radius);\n float focused = reach * bend;\n vec2 base = lensUv(direction, focused);\n\n float soft = u_softness * 0.011 * smoothstep(0.22, 1.0, radius);\n float split = u_aberration * 0.0035 * radius;\n\n vec4 mid = softSample(base, soft);\n float red = softSample(lensUv(direction, focused * (1.0 + split)), soft).r;\n float blue = softSample(lensUv(direction, focused * (1.0 - split)), soft).b;\n vec3 color = vec3(red, mid.g, blue);\n\n vec3 glare = vec3(0.0);\n for (int i = 0; i < GLARE_TAPS; i++) {\n vec3 tap =\n texture(u_scene, base + spiral(i, GLARE_TAPS, u_bloom * 0.026, 0.7)).rgb;\n glare += max(tap - 0.62, vec3(0.0));\n }\n color += (glare / float(GLARE_TAPS)) * u_bloom * 1.4;\n\n float falloff = pow(cos(min(radius, 1.0) * 0.55), 4.0);\n color *= mix(1.0, falloff, clamp(u_vignette, 0.0, 1.5));\n\n outColor = vec4(clamp(color, 0.0, 1.0), mid.a);\n}`;\n\nconst shader = makeFilterShader<CameraLensProps>(\n FRAGMENT_SHADER,\n ({ gl, uniform, passedProps }) => {\n const {\n softness = DEFAULTS.softness,\n bloom = DEFAULTS.bloom,\n aberration = DEFAULTS.aberration,\n vignette = DEFAULTS.vignette,\n distortion = DEFAULTS.distortion,\n } = passedProps;\n gl.uniform1f(uniform(\"u_softness\"), softness);\n gl.uniform1f(uniform(\"u_bloom\"), bloom);\n gl.uniform1f(uniform(\"u_aberration\"), aberration);\n gl.uniform1f(uniform(\"u_vignette\"), vignette);\n gl.uniform1f(uniform(\"u_distortion\"), distortion);\n },\n);\n\nconst CameraLensFallback: React.FC<CameraLensProps & CanvasFilterProps> = ({\n children,\n bloom = DEFAULTS.bloom,\n vignette = DEFAULTS.vignette,\n}) => (\n <AbsoluteFill>\n <AbsoluteFill>{children}</AbsoluteFill>\n <AbsoluteFill\n style={{\n filter: `blur(${6 * bloom}px) brightness(1.5) contrast(1.3)`,\n mixBlendMode: \"screen\",\n opacity: 0.3 * bloom,\n }}\n >\n {children}\n </AbsoluteFill>\n <AbsoluteFill\n style={{\n background:\n \"radial-gradient(ellipse 78% 76% at 50% 50%, transparent 52%, rgba(0, 0, 0, 0.5) 100%)\",\n opacity: Math.min(vignette, 1),\n }}\n />\n </AbsoluteFill>\n);\n\nexport const CameraLens = makeCanvasFilter<CameraLensProps>({\n shader,\n fallback: CameraLensFallback,\n});\n",
+ "type": "registry:component",
+ "target": "components/remocn/camera-lens.tsx"
+ }
+ ],
+ "type": "registry:component"
+}
diff --git a/registry-artifacts/registry.json b/registry-artifacts/registry.json
index f633c57d..700351f4 100644
--- a/registry-artifacts/registry.json
+++ b/registry-artifacts/registry.json
@@ -1674,6 +1674,21 @@
],
"type": "registry:component"
},
+ {
+ "name": "camera-lens",
+ "title": "Camera Lens",
+ "description": "Put a scene behind real glass: resolution falls off toward the corners, highlights bloom through the optics, colour fringes at the edges — a screencast that reads as filmed rather than rendered.",
+ "dependencies": ["remotion"],
+ "registryDependencies": ["@remocn/canvas-presentation"],
+ "files": [
+ {
+ "path": "registry/remocn/camera-lens/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/camera-lens.tsx"
+ }
+ ],
+ "type": "registry:component"
+ },
{
"name": "underwater-ripple",
"title": "Underwater Ripple",
diff --git a/registry/__index__.tsx b/registry/__index__.tsx
index ae296fc3..7c35b59f 100644
--- a/registry/__index__.tsx
+++ b/registry/__index__.tsx
@@ -8,6 +8,7 @@ import { asciiRenderConfig } from "@/registry/remocn/ascii-render/config";
import { backdropConfig } from "@/registry/remocn/backdrop/config";
import { blurOutUpConfig } from "@/registry/remocn/blur-out-up/config";
import { bottomUpLettersConfig } from "@/registry/remocn/bottom-up-letters/config";
+import { cameraLensConfig } from "@/registry/remocn/camera-lens/config";
import { caretWipeConfig } from "@/registry/remocn/caret-wipe/config";
import { chatGptConfig } from "@/registry/remocn/chat-gpt/config";
import { chatToPreviewLayoutConfig } from "@/registry/remocn/chat-to-preview-layout/config";
@@ -1513,6 +1514,13 @@ const registry: Record<string, RegistryEntry> = {
),
config: underwaterRippleConfig,
},
+ "camera-lens": {
+ load: () =>
+ import("@/components/docs/examples/camera-lens-example").then((m) => ({
+ default: m.CameraLensExampleScene,
+ })),
+ config: cameraLensConfig,
+ },
"slide-swap": {
load: () =>
import("@/components/docs/examples/slide-swap-example").then((m) => ({
diff --git a/registry/remocn/camera-lens/config.ts b/registry/remocn/camera-lens/config.ts
new file mode 100644
index 00000000..16c1ae45
--- /dev/null
+++ b/registry/remocn/camera-lens/config.ts
@@ -0,0 +1,55 @@
+import { cameraLensExampleCode } from "@/components/docs/examples/camera-lens-example";
+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";
+
+export const cameraLensConfig: ComponentConfig = {
+ componentName: "CameraLens",
+ importPath: "@/components/remocn/camera-lens",
+ controls: {
+ softness: {
+ type: "number",
+ default: 0.5,
+ min: 0,
+ max: 2,
+ step: 0.05,
+ label: "Corner softness",
+ },
+ bloom: {
+ type: "number",
+ default: 0.5,
+ min: 0,
+ max: 2,
+ step: 0.05,
+ label: "Bloom",
+ },
+ aberration: {
+ type: "number",
+ default: 0.5,
+ min: 0,
+ max: 3,
+ step: 0.1,
+ label: "Aberration",
+ },
+ vignette: {
+ type: "number",
+ default: 0.5,
+ min: 0,
+ max: 1.5,
+ step: 0.05,
+ label: "Vignette",
+ },
+ distortion: {
+ type: "number",
+ default: 0.05,
+ min: 0,
+ max: 0.6,
+ step: 0.01,
+ label: "Distortion",
+ },
+ },
+ durationInFrames: 90,
+ fps: FPS,
+ compositionWidth: W,
+ compositionHeight: H,
+ previewBackdrop: { type: "color", value: "#0a0a0a" },
+ snippet: cameraLensExampleCode,
+};
diff --git a/registry/remocn/camera-lens/index.tsx b/registry/remocn/camera-lens/index.tsx
new file mode 100644
index 00000000..3803afec
--- /dev/null
+++ b/registry/remocn/camera-lens/index.tsx
@@ -0,0 +1,150 @@
+"use client";
+
+import type React from "react";
+import { AbsoluteFill } from "remotion";
+import {
+ type CanvasFilterProps,
+ makeCanvasFilter,
+ makeFilterShader,
+} from "@/lib/remocn/canvas-presentation";
+
+export type CameraLensProps = {
+ softness?: number;
+ bloom?: number;
+ aberration?: number;
+ vignette?: number;
+ distortion?: number;
+};
+
+const DEFAULTS = {
+ softness: 0.5,
+ bloom: 0.5,
+ aberration: 0.5,
+ vignette: 0.5,
+ distortion: 0.05,
+};
+
+const FRAGMENT_SHADER = `#version 300 es
+precision highp float;
+
+uniform sampler2D u_scene;
+uniform float u_aspect;
+uniform float u_softness;
+uniform float u_bloom;
+uniform float u_aberration;
+uniform float u_vignette;
+uniform float u_distortion;
+
+in vec2 v_uv;
+out vec4 outColor;
+
+const int SOFT_TAPS = 6;
+const int GLARE_TAPS = 8;
+const float GOLDEN = 2.39996323;
+
+vec2 lensUv(vec2 direction, float distance) {
+ vec2 q = direction * distance;
+ q.x /= u_aspect;
+ return q * 0.5 + 0.5;
+}
+
+vec2 spiral(int index, int count, float radius, float turn) {
+ float angle = float(index) * GOLDEN + turn;
+ float step = sqrt((float(index) + 0.5) / float(count)) * radius;
+ return vec2(cos(angle) * step / u_aspect, sin(angle) * step);
+}
+
+vec4 softSample(vec2 uv, float radius) {
+ vec4 sum = texture(u_scene, uv);
+ if (radius <= 0.00002) {
+ return sum;
+ }
+ for (int i = 0; i < SOFT_TAPS; i++) {
+ sum += texture(u_scene, uv + spiral(i, SOFT_TAPS, radius, 0.0));
+ }
+ return sum / float(SOFT_TAPS + 1);
+}
+
+void main() {
+ vec2 p = (v_uv - 0.5) * 2.0;
+ p.x *= u_aspect;
+
+ float span = sqrt(u_aspect * u_aspect + 1.0);
+ float reach = length(p);
+ float radius = reach / span;
+ vec2 direction = reach > 0.0001 ? p / reach : vec2(0.0);
+
+ float bend = 1.0 / (1.0 + clamp(u_distortion, 0.0, 1.0) * radius * radius);
+ float focused = reach * bend;
+ vec2 base = lensUv(direction, focused);
+
+ float soft = u_softness * 0.011 * smoothstep(0.22, 1.0, radius);
+ float split = u_aberration * 0.0035 * radius;
+
+ vec4 mid = softSample(base, soft);
+ float red = softSample(lensUv(direction, focused * (1.0 + split)), soft).r;
+ float blue = softSample(lensUv(direction, focused * (1.0 - split)), soft).b;
+ vec3 color = vec3(red, mid.g, blue);
+
+ vec3 glare = vec3(0.0);
+ for (int i = 0; i < GLARE_TAPS; i++) {
+ vec3 tap =
+ texture(u_scene, base + spiral(i, GLARE_TAPS, u_bloom * 0.026, 0.7)).rgb;
+ glare += max(tap - 0.62, vec3(0.0));
+ }
+ color += (glare / float(GLARE_TAPS)) * u_bloom * 1.4;
+
+ float falloff = pow(cos(min(radius, 1.0) * 0.55), 4.0);
+ color *= mix(1.0, falloff, clamp(u_vignette, 0.0, 1.5));
+
+ outColor = vec4(clamp(color, 0.0, 1.0), mid.a);
+}`;
+
+const shader = makeFilterShader<CameraLensProps>(
+ FRAGMENT_SHADER,
+ ({ gl, uniform, passedProps }) => {
+ const {
+ softness = DEFAULTS.softness,
+ bloom = DEFAULTS.bloom,
+ aberration = DEFAULTS.aberration,
+ vignette = DEFAULTS.vignette,
+ distortion = DEFAULTS.distortion,
+ } = passedProps;
+ gl.uniform1f(uniform("u_softness"), softness);
+ gl.uniform1f(uniform("u_bloom"), bloom);
+ gl.uniform1f(uniform("u_aberration"), aberration);
+ gl.uniform1f(uniform("u_vignette"), vignette);
+ gl.uniform1f(uniform("u_distortion"), distortion);
+ },
+);
+
+const CameraLensFallback: React.FC<CameraLensProps & CanvasFilterProps> = ({
+ children,
+ bloom = DEFAULTS.bloom,
+ vignette = DEFAULTS.vignette,
+}) => (
+ <AbsoluteFill>
+ <AbsoluteFill>{children}</AbsoluteFill>
+ <AbsoluteFill
+ style={{
+ filter: `blur(${6 * bloom}px) brightness(1.5) contrast(1.3)`,
+ mixBlendMode: "screen",
+ opacity: 0.3 * bloom,
+ }}
+ >
+ {children}
+ </AbsoluteFill>
+ <AbsoluteFill
+ style={{
+ background:
+ "radial-gradient(ellipse 78% 76% at 50% 50%, transparent 52%, rgba(0, 0, 0, 0.5) 100%)",
+ opacity: Math.min(vignette, 1),
+ }}
+ />
+ </AbsoluteFill>
+);
+
+export const CameraLens = makeCanvasFilter<CameraLensProps>({
+ shader,
+ fallback: CameraLensFallback,
+});
diff --git a/registry/remocn/registry.json b/registry/remocn/registry.json
index e7a543cb..569d698c 100644
--- a/registry/remocn/registry.json
+++ b/registry/remocn/registry.json
@@ -1674,6 +1674,21 @@
}
]
},
+ {
+ "name": "camera-lens",
+ "type": "registry:component",
+ "title": "Camera Lens",
+ "description": "Put a scene behind real glass: resolution falls off toward the corners, highlights bloom through the optics, colour fringes at the edges — a screencast that reads as filmed rather than rendered.",
+ "dependencies": ["remotion"],
+ "registryDependencies": ["@remocn/canvas-presentation"],
+ "files": [
+ {
+ "path": "camera-lens/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/camera-lens.tsx"
+ }
+ ]
+ },
{
"name": "underwater-ripple",
"type": "registry:component",
diff --git a/src/remotion/canvas-spike-root.tsx b/src/remotion/canvas-spike-root.tsx
index 987aa478..75834de7 100644
--- a/src/remotion/canvas-spike-root.tsx
+++ b/src/remotion/canvas-spike-root.tsx
@@ -7,6 +7,7 @@ import {
registerRoot,
} from "remotion";
import { AsciiRenderExampleScene } from "@/components/docs/examples/ascii-render-example";
+import { CameraLensExampleScene } from "@/components/docs/examples/camera-lens-example";
import { CrtScreenExampleScene } from "@/components/docs/examples/crt-screen-example";
import { DisplacementExampleScene } from "@/components/docs/examples/displacement-example";
import { EmberBurnExampleScene } from "@/components/docs/examples/ember-burn-example";
@@ -20,6 +21,7 @@ import { UnderwaterRippleExampleScene } from "@/components/docs/examples/underwa
import { VhsFilterExampleScene } from "@/components/docs/examples/vhs-filter-example";
import type { ComponentConfig } from "@/lib/customizer-config";
import { asciiRenderConfig } from "@/registry/remocn/ascii-render/config";
+import { cameraLensConfig } from "@/registry/remocn/camera-lens/config";
import { crtScreenConfig } from "@/registry/remocn/crt-screen/config";
import { displacementConfig } from "@/registry/remocn/displacement/config";
import { emberBurnConfig } from "@/registry/remocn/ember-burn/config";
@@ -75,6 +77,7 @@ const SCENES: Record<
Scene: UnderwaterRippleExampleScene,
config: underwaterRippleConfig,
},
+ "camera-lens": { Scene: CameraLensExampleScene, config: cameraLensConfig },
};
function makeStage(Scene: ComponentType) {