geometricNormal

The surface normal of the shape, whichever kind of shape is active.

geometricNormal(
  frame: SurfaceFrame,
  field: SurfaceField,
  opts: {bevelWidth: Expr; bevelShape: Expr; sharpness?: number; eps?: number; hint?: string},
): Expr

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

A 3D shape takes its normal from the marched depth. A flat shape takes a normal that tilts away from the face near the edge, over bevelWidth (in the units of field.sdf) with the profile bevelShape (0 round, 1 machined). sharpness clamps the 3D slope (default 5, lower is calmer). eps must match the stencil step (default 0.01). Needs a stencil with neighbour taps.

Parameters

NameTypeNotes
frameSurfaceFrame
fieldSurfaceField
opts{bevelWidth: Expr; bevelShape: Expr; sharpness?: number; eps?: number; hint?: string}

Example

const n = geometricNormal(frame, field, {bevelWidth: u.bevelWidth, bevelShape: u.bevelShape})

Tip. Add relief with nudgeNormal or tiltNormal after this, never before.

See also

  • marchedNormal — The surface normal of a 3D shape, from the marched depth.
  • nudgeNormal — Tilts a normal by a slope in x and y, turning a height field into relief.
  • tiltNormal — Tilts a normal along and across a direction, for brushed or woven relief.
  • fieldSlope — The direction the shape's distance grows in: a 2D vector pointing outward at this pixel.

Used by

BrushedMetal, CarbonFiber, Irradiance, LiquidMetal, Nebula, Obsidian