nearestEdge

The closest point on the shape's edge to this pixel, and the outward normal there.

nearestEdge(
  sdfUV: Expr,
  sdf: Expr,
  slope: Expr,
  hint: string = 'edge',
): {point: Expr; normal: Expr}

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

Where a rim glow or contact shadow comes from for pixels outside the shape. slope is fieldSlope; its length is guarded.

Parameters

NameTypeNotes
sdfUVExpr
sdfExpr
slopeExpr
hintstringOptional. Default 'edge'.

Example

const edge = nearestEdge(frame.sdfUV!, field.sdf, fieldSlope(field))

See also

  • fieldSlope — The direction the shape's distance grows in: a 2D vector pointing outward at this pixel.
  • pointLightFrom — A point light as seen from a point on the shape: the 3D light vector L, the 2D direction toLight and the distance.
  • continuedField — The distance field extended past the edge of an SVG shape's texture.

Used by

Irradiance