grid
A grid of vec4f cells advanced once per frame by step, with named outputs in derive.
grid(config: GridSimInit): GridSim & InputNode
Import simulate from shaders/std and use simulate.grid.
Read the grid in WGSL as name(uv) (bilinear between cell centres) and an output as name.output(uv).
resolution: cells per side of a square grid, or[width, height](it does not follow the frame's shape: give[w, h]in the frame's proportions). Its cost is fixed, whatever the canvas size. -history: 2lets steps read last frame's state withreadPrev(a wave, or Verlet motion). -precision: 'full'stores 32-bit cells, for positions and anything that moves by tiny amounts. -initseeds every cell once: a WGSL body returningvec4fthat seescell,cellUV(the cell's centre, 0–1),gridSize, props, helpers and library functions. -stepruns in order every frame:op.*steps and your ownop.kernelbodies. A kernel reads the grid (read,readPrev,readLinear), the built-ins (dtfollows the layer's Speed), props, helpers and other inputs by name (clicks(i), another grid'sfield(uv)). - Revising the component restarts the grid frominit; a capture continues it.
Parameters
| Name | Type | Notes |
|---|---|---|
config | GridSimInit |
Example
inputs: {
field: simulate.grid({
resolution: 256, history: 2,
step: [op.wave({damping: p('decay')}), op.splat({at: pointer(), amount: pointerSpeed({max: 2}), radius: p('radius')})],
derive: {slope: op.gradient()},
}),
},
effect: wgsl`return textureSample(childTexture, childSampler, uv + field.slope(uv).xy * intensity);`,
See also
opdisplaceBy— Push the child's pixels around by a vector field from one of your simulations.