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 needUse
ripples from the cursorwave with splat, derive gradient
something spreads and fadesdiffuse, decay
organic spots, stripes, mazesreactDiffuse
a growing frost or crackle edge that can retreatgrowthFront, with occupancy so fronts stop on contact
a cellular automaton (Life)automaton
a temperature that spreads and coolsheat
your own rulekernel

Types

TypeWhat it is
AutomatonOpA cellular automaton on .x (0 or 1): born with birth live neighbours, survives with survive.
CellKernelOpYour own step: a WGSL body run per cell, returning the cell's new vec4f.
DecayOpFade every channel toward 0, halving every halfLife seconds.
DiffuseOpSpread every channel into the neighbours at rate per second (a blur, as a step).
GradientOpThe slope of .x at every cell, as .xy.
GridDeriveOpAny output a grid can derive.
GridStepOpAny step a grid can run.
GrowthFrontOpA spreading boundary in .x (0 → 1) that creeps into neighbours at rate cells per second, ragged by roughness; reverse makes it retreat.
HeatOpA temperature in .x that spreads (spread) and cools (cool per second).
OccupancyOpFirst-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.
OpArgA number, or a prop read live each frame.
ReactDiffuseOpGray-Scott reaction-diffusion on .x (A) and .y (B).
SplatOpPress a soft round brush into .x wherever the pointer moves (radius 0.1–1, a fraction of the grid).
WaveOpRipple like a water surface, fading by damping (0 rings forever, 20 dies in a few frames).

Words

Keep reading