paintFrame

The coordinate and frame size a hand-written paint: builder should draw in.

paintFrame(params: GpuFragmentParams): {uv: Expr; viewport: Expr}

Import paintFrame from shaders/std.

Returns uv and viewport as GPU values. Inside a distortion the uv is the distorted one, and inside a sized box the viewport is the box, so a generator built on these behaves like the library's own.

Parameters

NameTypeNotes
paramsGpuFragmentParams

Example

paint: (params) => {
  const {uv} = paintFrame(params)
  const center = uniformOf(p('center'), params)
  const d = length(sub(uv, vec2(center.member('x'), sub(1, center.member('y')))))
  return vec4(splat3(smoothstep(0, 0.5, d)), 1)
}

See also

  • ctx — The context values as tokens: ctx.uv, ctx.time, ctx.aspect, ctx.pointer, ctx.viewportSize, ctx.logicalViewportSize.
  • uniformOf — The live GPU value of a prop, for a hand-written builder: uniformOf(p('radius'), params).