threshold

Turns a signed field (−1 to 1) into a soft 0–1 mask.

threshold(field: Field, opts: {low: number; high: number; bias?: FieldScalar}): Field

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

The field is first mapped to 0–1 and shifted by bias, then eased from 0 at low to 1 at high. Bring low and high together for a hard edge.

Parameters

NameTypeNotes
fieldField
opts{low: number; high: number; bias?: FieldScalar}

Example

paint: rampOver(threshold(flowField({detail: p('detail')}), {low: 0.3, high: 0.7, bias: {base: p('blend'), add: -50, mul: 0.006}}), stops(p('colorSpace')))

See also

  • flowField — A swirling, animated wave pattern from −1 to 1.
  • tone — Reshapes a 0–1 field with glow, contrast and balance controls, then flips it.

Used by

Swirl