share

Evaluates a field once and lets several words read the same result.

share(field: Field): Field

Import paint from shaders/std and use paint.share.

Wrap a field in share when it feeds two places, such as a threshold and a pulse.

Parameters

NameTypeNotes
fieldField

Example

const pattern = share(flowField({detail: p('detail')}))
// then: threshold(pattern, ...) and pulse(pattern, ...)

Tip. One result per layer, whatever coordinate it is asked for. Do not use it to sample the same field at two offsets.

See also

  • flowField — A swirling, animated wave pattern from −1 to 1.
  • pulse — A gentle brightness pulse that follows a pattern field, hovering around 1.

Used by

Swirl, Voronoi