stage.iterate
Run a step count times this frame.
stage.iterate(opts: {count: (f: GridFrame) => number; step: (i: number, nodes: ComputeStep[], f: GridFrame) => void}): GridStage
Import sim from shaders/std and use sim.grids.stage.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
stage.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
stage.pass— One GPU pass, the same every frame.stage.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.