Builtin Library
- ..
- README.md2.2 KB
- bindings.yaml2.3 KB
- shader.wgsl7.0 KB
README.md
terrain_water_kernel
Fills a water surface over a region of one tile, into the water and
waterMask layers of a proc.raster Raster — terrainOps.water's
lake, river and sea share this one dispatch.
One shader covers every water body, selected by a region-mode lane:
| mode | region | what fills |
|---|---|---|
| 0 | disc | a round body about a point — a lake |
| 1 | square | the same, measured in the Chebyshev metric |
| 2 | path | a body swept along a segment, its surface running from one end's level to the other's — a river |
| 3 | everywhere | the whole raster — a sea |
A cell takes the surface only where the ground stands below it, so a body
fills the basins its region reaches and leaves ground that rises out of it dry.
That is the whole difference between a lake and a sea: the region an op is
applied to. The ground it reads is op_source, bound to the raster's
height layer.
The two layers are one thing
| layer | what it holds |
|---|---|
water | the world-space Y of the surface covering that cell |
waterMask | 1 where a surface covers the cell, 0 where none does |
A mask of 0 is what "no water here" IS — there is no height in the water
layer standing in for it, so no authored water level can ever be mistaken for
an absence. Everything that reads water reads the pair.
Bodies meet through blend
Where two bodies reach one cell, the second meets the first through blend —
replace, add, max or min. The default max makes the meeting
independent of authoring order: the higher surface wins whichever op ran
first, so a lake in a coastal basin reads the same whether it was placed
before or after the sea.
Every coordinate and every level is world metres, so a body keeps its size, its place and its altitude when the raster's resolution changes.
Every op carries a mask. The op's weight at a cell is scaled by what the mask reads there, and here the water mask layer is what carries that coverage: a cell the mask holds out keeps both layers as they stand, and a partly covered cell holds part of the surface it already had. An op that names no mask fills at full strength everywhere.