grainNoise

One octave of smooth signed noise along and across a direction, for grain.

grainNoise(
  coords: {along: Expr; across: Expr},
  opts: {freq: [Expr | number, Expr | number]; offset?: [number, number]; drift?: Expr},
): Expr

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

coords come from directionFrame(...).coordsOf(p). freq sets the feature density per axis (a high across value gives fine streaks). Returns roughly −1 to 1. Sum octaves and apply gains at the call site.

Parameters

NameTypeNotes
coords{along: Expr; across: Expr}
opts{freq: [Expr | number, Expr | number]; offset?: [number, number]; drift?: Expr}

Example

const sheen = grainNoise(brush.coordsOf(pat), {freq: [1.3, 6.5], drift: driftA})

See also

  • surfaceNoise — Smooth signed noise at a 2D point, roughly −1 to 1, with features about one unit wide.
  • tiltNormal — Tilts a normal along and across a direction, for brushed or woven relief.
  • smearAlong — Blurs any 2D lookup along a direction, for streaked reflections and motion smear.

Used by

BrushedMetal