op

The stages a grid frame is built from.

op: { host, values, settle, readyWhen, pass, cache, publish, seedOnce, iterate, sortPass }

Import sim from shaders/std and use sim.grids.op.

List them in stages in the order they should run.

Bookkeeping: host (before any gate), values (write this frame's values), readyWhen (wait for an input), settle (sleep once the field is still). Work: pass (one GPU pass), cache (a pass picked per frame), seedOnce (a one-shot reset), iterate (a pass N times), sortPass (a compare-swap chain), publish (write the result the layer samples).

Example

stages: [op.readyWhen(() => ready), op.values('write', (f) => paramsU.write({dt: f.dt})), op.iterate({count: () => 8, step: (i, nodes) => nodes.push(react.with(i % 2 ? groupBA : groupAB))}), op.publish(() => output)]

Tip. A values stage sits before the passes that read it. Stages run in list order.

Members

  • op.host — A named step that runs before any gate: pointer smoothing, activity flags, anything a later settle needs to know.
  • op.values — A named step that writes this frame's values for the passes after it.
  • op.settle — Sleep the simulation once nothing has driven it for settleMs of simulated time.
  • op.readyWhen — Run nothing until fn returns true, typically once the child's picture has arrived through bindInputs.
  • op.pass — One GPU pass, the same every frame.
  • op.cache — A GPU pass chosen per frame, for a pass whose input is rebound after the frame starts.
  • op.publish — The last stage: write the state into the texture the layer samples.
  • op.seedOnce — A one-shot reset run before the rest of the frame whenever staleWhen says the state is stale: on the first frame, or when a seed prop changes.
  • op.iterate — Run a step count times this frame.
  • op.sortPass — A compare-and-swap sort that converges a little more every frame: passes swaps per frame, alternating odd and even pairs and the two buffers.

See also

  • gridSim — A field of cells advanced every frame by an ordered list of stages.

Used by

PixelSort, ReactionDiffusion