Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit61a33237e0

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:

moderegionwhat fills
0disca round body about a point — a lake
1squarethe same, measured in the Chebyshev metric
2patha body swept along a segment, its surface running from one end's level to the other's — a river
3everywherethe 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

layerwhat it holds
waterthe world-space Y of the surface covering that cell
waterMask1 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.