Builtin Library
- ..
- README.md2.1 KB
- bindings.yaml3.8 KB
- shader.wgsl5.1 KB
README.md
grid
Reads and writes a field of cells in one kernel. The field is a Grid (one tile,
no apron, x fastest, lanes values per cell) or a Raster (tiles with aprons,
one batched dispatch) through the layout in tile_layout.
- sample (
MODE sample): the field at positions, nearest or trilinear, held to the edge cell past the field. Reads each cell from the tile that owns it. - write (
MODE write): a patch of values blended into the field (replace, add, max, min, multiply, optionally weighted per cell). Every tile that holds a cell as core or apron receives it, so apron copies agree. The patch window is stated in field cells and may reach past the field (negative origin, or a size beyond the cell counts): a stored cell a border tile holds past the field takes the patch where the window covers it. - stencil (
MODE stencil): per stored cell, a neighbour at an offset, slope in degrees, curvature (the laplacian over x and z) or the gradient, with neighbour reads held to the tile's own stored edge. Slope and curvature are the terrain mask's. The gradient writes two values a cell, d/dx and d/dz per metre.
MODE, SAMPLING (nearest, trilinear), STENCIL (offset, slope, curvature, gradient) and BLEND (replace, add, max, min, multiply) are specializations.
The bindings: field (the field, read by sample and stencil), aux (the
positions, xyz a position, for sample; the patch values for write), weight (one
weight a patch cell, read by write when the param hasWeight is 1) and out (the
sampled column, the stencil result, or the field being written). Sample runs one
thread per position (count of them) and writes outLanes values each, from lane
lane; write and stencil run one thread per stored cell.
determinism: exact: each output element has one writer. The bindings a mode
does not use take any buffer of at least one element that is not bound elsewhere
in the dispatch.
grid.sample samples with it, core.raster.blend writes a patch into a raster
with it, and core.raster.stencil measures slope and curvature with it.