pass
Your own WGSL, rendered into a texture every frame before the body runs, read by name: clouds(uv).
pass(
body: WgslBody | string,
opts: {scale?: number; format?: PassFormat} = {},
): PassInput
Import pass from shaders/std.
The body is like a paint: body (it gets uv, time, props, other inputs, library functions, and returns a vec4f), but it runs in a compute pass: no dpdx, fwidth or discard, and textureSample becomes textureSampleLevel for you. Reading child gives the layer inside at this uv.
scale renders at a fraction of the canvas (0.5 is a quarter of the pixels). Use it for expensive work that is smooth anyway: volumetric clouds, a soft height field. targetSize (vec2f) is this pass's own size in pixels; use it, not viewport, for anything measured in pixels here (one pixel is 1.0 / targetSize.y in uv).
Parameters
| Name | Type | Notes |
|---|---|---|
body | WgslBody | string | |
opts | {scale?: number; format?: PassFormat} | Optional. Default {}. |
Example
inputs: {clouds: pass(wgsl`return marchClouds(uv, time);`, {scale: 0.5})},
paint: wgsl`return clouds(uv);`,
See also
downsample— A smaller copy of a source, box-filtered so it does not alias.previousFrame— This layer's own output from an earlier frame.