silhouette

The shape's coverage at this pixel: 1 inside, 0 outside, soft across the edge.

silhouette(field: SurfaceField, edgeSoftness: Expr): Expr

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

edgeSoftness is the softness prop; at 0 the edge is still anti-aliased over 1.5 pixels. Use it as the alpha of the color you return.

Parameters

NameTypeNotes
fieldSurfaceField
edgeSoftnessExpr

Example

return guarded(insideShape(field.sdf, field.pxH), vec4(rgb, silhouette(field, u.edgeSoftness)), vec4(0, 0, 0, 0))

See also

  • insideShape — True inside the shape and up to two pixels outside it.
  • guarded — Evaluates an expression only where a condition holds, and a cheap fallback everywhere else.

Used by

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