Camera Lens
remocn/camera-lensFreeComponent
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.
Install it
npx shadcn@latest add https://www.remocn.dev/r/camera-lens.jsonSource
1"use client";23import type React from "react";4import { AbsoluteFill } from "remotion";5import {6 type CanvasFilterProps,7 makeCanvasFilter,8 makeFilterShader,9} from "@/lib/remocn/canvas-presentation";1011export type CameraLensProps = {12 softness?: number;13 bloom?: number;14 aberration?: number;15 vignette?: number;16 distortion?: number;17};1819const DEFAULTS = {20 softness: 0.5,21 bloom: 0.5,22 aberration: 0.5,23 vignette: 0.5,24 distortion: 0.05,25};2627const FRAGMENT_SHADER = `#version 300 es28precision highp float;2930uniform sampler2D u_scene;31uniform float u_aspect;32uniform float u_softness;33uniform float u_bloom;34uniform float u_aberration;35uniform float u_vignette;36uniform float u_distortion;3738in vec2 v_uv;39out vec4 outColor;4041const int SOFT_TAPS = 6;42const int GLARE_TAPS = 8;43const float GOLDEN = 2.39996323;4445vec2 lensUv(vec2 direction, float distance) {46 vec2 q = direction * distance;47 q.x /= u_aspect;48 return q * 0.5 + 0.5;49}5051vec2 spiral(int index, int count, float radius, float turn) {52 float angle = float(index) * GOLDEN + turn;53 float step = sqrt((float(index) + 0.5) / float(count)) * radius;54 return vec2(cos(angle) * step / u_aspect, sin(angle) * step);55}5657vec4 softSample(vec2 uv, float radius) {58 vec4 sum = texture(u_scene, uv);59 if (radius <= 0.00002) {60 return sum;61 }62 for (int i = 0; i < SOFT_TAPS; i++) {63 sum += texture(u_scene, uv + spiral(i, SOFT_TAPS, radius, 0.0));64 }65 return sum / float(SOFT_TAPS + 1);66}6768void main() {69 vec2 p = (v_uv - 0.5) * 2.0;70 p.x *= u_aspect;7172 float span = sqrt(u_aspect * u_aspect + 1.0);73 float reach = length(p);74 float radius = reach / span;75 vec2 direction = reach > 0.0001 ? p / reach : vec2(0.0);7677 float bend = 1.0 / (1.0 + clamp(u_distortion, 0.0, 1.0) * radius * radius);78 float focused = reach * bend;79 vec2 base = lensUv(direction, focused);8081 float soft = u_softness * 0.011 * smoothstep(0.22, 1.0, radius);82 float split = u_aberration * 0.0035 * radius;8384 vec4 mid = softSample(base, soft);85 float red = softSample(lensUv(direction, focused * (1.0 + split)), soft).r;86 float blue = softSample(lensUv(direction, focused * (1.0 - split)), soft).b;87 vec3 color = vec3(red, mid.g, blue);8889 vec3 glare = vec3(0.0);90 for (int i = 0; i < GLARE_TAPS; i++) {91 vec3 tap =92 texture(u_scene, base + spiral(i, GLARE_TAPS, u_bloom * 0.026, 0.7)).rgb;93 glare += max(tap - 0.62, vec3(0.0));94 }95 color += (glare / float(GLARE_TAPS)) * u_bloom * 1.4;9697// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from remocn
All 277 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| UI Accordionaccordion | remocn | Components | Free | 1 dep · 2 files | |
| UI AI Prompt Flowai-prompt-flow | remocn | Components | Free | 1 dep | |
| UI Alert Dialogalert-dialog | remocn | Components | Free | 1 dep · 2 files | |
| Animated Bar Chartanimated-bar-chart | remocn | Components | Free | 1 dep | |
| Animated Line Chartanimated-line-chart | remocn | Components | Free | 1 dep | |
| ASCII Dissolveascii-dissolve | remocn | Components | Free | 2 deps | |
| ASCII Renderascii-render | remocn | Components | Free | 1 dep | |
| Backdropbackdrop | remocn | Components | Free | 1 dep |
