sensorGrain

Adds a fine per-pixel brightness jitter, so rendered light reads as photographed.

sensorGrain(
  rgb: Expr,
  opts: {amount: Expr | number; pixel: Expr; clock: Expr | number},
): Expr

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

Each pixel is scaled by up to half of amount either way. pixel is the pixel coordinate (uv times the viewport size); clock re-rolls the grain each frame.

Parameters

NameTypeNotes
rgbExpr
opts{amount: Expr | number; pixel: Expr; clock: Expr | number}

Example

const rgb = sensorGrain(glow, {amount: 0.08, pixel: mul(uv, viewport), clock: t})

See also

  • hashNoise — Random 0–1 per point, with no smoothness between neighbours.
  • interleavedNoise — A 0–1 dither pattern over device pixels where neighbours differ as much as possible.
  • exposureTone — Turns light that piles past 1 into a soft burn toward white, like film.