Shader stage

A WGSL fragment shader drawn through WebGPU on the frame clock.

0:00 / 0:01

Installation

pnpm odori add component shader-stage

Edit the source in videos/components/shader-stage/. Use odori diff to compare upstream changes and odori update to apply updates. Requires vgpu, so add it to the project: npm install vgpu

Timing contract

Use these durations and content limits when composing a scene. Run odori test to check your video.

Family
Shaders
Recommended duration
150 frames · 5s
Minimum duration
24 frames · 0.8s
Entrance
0 frames
Exit
0 frames
Reduced motion
motion is the shader's own; pass calmer uniforms
Requires
vgpu (npm)
Content limits
none

Props

PropTypeDefaultRequired
wgslA WGSL fragment shader as a plain string. The fullscreen vertex stage is provided, so the fragment entry receives `@location(0) uv: vec2f` and nothing else is required. Uniforms are ordinary `var<uniform>` declarations, addressed by name from `uniforms`.string—Yes
uniformsThe uniform values for a frame. Called with the frame clock, so a shader animates on `time` the way a component animates on `useFrame`: the value is a pure function of the frame, which is what keeps the export deterministic. Return only names the shader declares.(state: ShaderUniformState) => Record<string, unknown>——
fallbackDrawn when the browser has no WebGPU. Studio in an older browser shows this instead of a blank; the render pipeline always has WebGPU when the video declares `webgpu: true`.ReactNode——
alphaDraw on a transparent surface, compositing over whatever is underneath. The shader then returns premultiplied alpha: `vec4f(rgb * a, a)`. This is what makes a fullscreen pass a filter rather than a background.booleanfalse—
styleCSSProperties——

Related components

All components