Grid steps
The steps a grid runs every frame, and the outputs it derives. Every cell holds a
vec4f; most steps work on .x and leave the other channels for you. Steps run in the order you
list them. op.kernel is your own step in WGSL, for anything the others do not cover.
import {op} from 'shaders/std'
Reach for it when
| When you need | Use |
|---|---|
| ripples from the cursor | wave with splat, derive gradient |
| something spreads and fades | diffuse, decay |
| organic spots, stripes, mazes | reactDiffuse |
| a growing frost or crackle edge that can retreat | growthFront, with occupancy so fronts stop on contact |
| a cellular automaton (Life) | automaton |
| a temperature that spreads and cools | heat |
| your own rule | kernel |
Types
| Type | What it is |
|---|---|
AutomatonOp | A cellular automaton on .x (0 or 1): born with birth live neighbours, survives with survive. |
CellKernelOp | Your own step: a WGSL body run per cell, returning the cell's new vec4f. |
DecayOp | Fade every channel toward 0, halving every halfLife seconds. |
DiffuseOp | Spread every channel into the neighbours at rate per second (a blur, as a step). |
GradientOp | The slope of .x at every cell, as .xy. |
GridDeriveOp | Any output a grid can derive. |
GridStepOp | Any step a grid can run. |
GrowthFrontOp | A spreading boundary in .x (0 → 1) that creeps into neighbours at rate cells per second, ragged by roughness; reverse makes it retreat. |
HeatOp | A temperature in .x that spreads (spread) and cools (cool per second). |
OccupancyOp | First-come-wins claims in .w: an empty cell next to a claimed one takes its claim, so fronts from different seeds merge and stop instead of overwriting. |
OpArg | A number, or a prop read live each frame. |
ReactDiffuseOp | Gray-Scott reaction-diffusion on .x (A) and .y (B). |
SplatOp | Press a soft round brush into .x wherever the pointer moves (radius 0.1–1, a fraction of the grid). |
WaveOp | Ripple like a water surface, fading by damping (0 rings forever, 20 dies in a few frames). |
Words
- waveA wave step: the grid ripples outward from any disturbance and fades by
damping(a prop or number, 0–20). - splatA brush step: a soft round push into
.xat the pointer, scaled by how fast it moves. - gradientA derived output: the slope of
.xat every cell as.xy, ready for a displacement. - diffuseSpread every channel into its neighbours at
rateper second. - decayFade every channel toward 0, halving every
halfLifeseconds. - reactDiffuseGray-Scott reaction-diffusion on
.xand.y. - growthFrontA spreading boundary in
.xthat creeps outward from seeded cells (.x = 1frominitor a splat) atratecells per second. - occupancyFirst-come-wins claims in
.w. - automatonA cellular automaton on
.x. - heatA temperature in
.xthat spreads and cools. - kernelYour own grid step, run once per cell: return the cell's new
vec4f.