surfaceField

The first line of a material: the field taps, the signed distance and the pixel size, bound once.

surfaceField(
  frame: SurfaceFrame,
  params: GpuFragmentParams,
  opts: {scale?: Expr} = {},
): SurfaceField

Import materials from shaders/std and use materials.surfaceField.

Pass scale (the shape's scale prop) to divide the distance by it, as the library's metals and plastics do, so edge softness and pixel tests track the shape's size. Leave it out for continuedField.

Parameters

NameTypeNotes
frameSurfaceFrame
paramsGpuFragmentParams
opts{scale?: Expr}Optional. Default {}.

Example

const field = surfaceField(frame, params, {scale: params.uniforms.scale})

See also

  • shapedSurface — Turns a shape prop into a surface your material shades.
  • geometricNormal — The surface normal of the shape, whichever kind of shape is active.
  • silhouette — The shape's coverage at this pixel: 1 inside, 0 outside, soft across the edge.
  • insideShape — True inside the shape and up to two pixels outside it.

Used by

BrushedMetal, CarbonFiber, Chrome, Crystal, Frost, Holographic, Irradiance, LiquidMetal, Nebula, Obsidian, Plastic, Water