op.iterate
Run a step count times this frame.
op.iterate(opts: {count: (f: GridFrame) => number; step: (i: number, nodes: ComputeStep[], f: GridFrame) => void}): GridStage
Import sim from shaders/std and use sim.grids.op.iterate.
Your step adds the pass for iteration i and picks which buffer it reads and writes.
Parameters
| Name | Type | Notes |
|---|---|---|
opts | {count: (f: GridFrame) => number; step: (i: number, nodes: ComputeStep[], f: GridFrame) => void} |
Example
op.iterate({count: (f) => Math.round(f.num('speed', 8)), step: (i, nodes) => nodes.push(react.with(i % 2 ? groupBA : groupAB))})
Tip. A reaction-diffusion field reads smoother when you raise the iteration count than when you raise the step size.
See also
op.pass— One GPU pass, the same every frame.op.sortPass— A compare-and-swap sort that converges a little more every frame:passesswaps per frame, alternating odd and even pairs and the two buffers.