Builtin Library
- ..
- README.md1.8 KB
- bindings.yaml1.3 KB
- shader.wgsl6.0 KB
README.md
terrain_shape
Blends an analytic shape into one scalar channel of one tile.
One shader covers every placed primitive, selected by a mode lane:
| mode | shape | what it draws |
|---|---|---|
| 0 | disc | a circular pad held at one altitude |
| 1 | square | the same, measured in the Chebyshev metric |
| 2 | cone | a rounded hill, cosine profile, tangent to flat at the rim |
| 3 | ridge | that profile swept along a segment |
| 4 | ramp | an altitude interpolated along a segment |
| 5 | terrace | the existing height quantized into steps |
A negative height on a ridge cuts the same profile downward, which is how a
valley or a sunken road corridor is drawn.
The shape's coverage at a cell is a weight in 0..1 — full inside radius,
falling to zero across falloff metres beyond it — and that weight is what the
blend is applied through. A flatten therefore settles into the terrain rather
than stamping a cliff-edged plateau into it.
Every coordinate is world metres. A shape about a point puts that point in both
segment endpoints; a shape along a line puts the two ends in them. radius is
the half-width for the segment shapes. Because nothing here is in cells, the
same op covers the same ground at any resolution.
blend decides how the shape's value meets what the channel already holds:
replace, add, max, or min. The rounded shapes read best with add,
which lays a hill on top of the terrain instead of replacing it; the level
shapes read best with replace.
Every op carries a mask. The op's weight at a cell is scaled by what the mask reads there — multiplied in, or subtracted out — so the op applies only where the mask lets it and a cell the mask holds out keeps exactly what it already held, at every blend mode. An op that names no mask writes at full strength everywhere.