Builtin Library
README.md
terrain
Ground, as procedural operations. terrain.source opens a rect of ground as a
tiled Raster with a height layer; every other op in the family takes that
Raster, changes it, and hands it on — so a valley, a mountain range, an
island and a coastline are all the same graph with different nodes in it.
terrain.write carries the result back out — into a .terrainData that a
Terrain component stands an entity on.
Every op is an ordinary procgen op, so any graph can reach them and they
compose with the rest of the registry: the shaping ops take a Raster and hand
one on, and the ops that stand things on the ground hand back points.
Ops
The ground
terrain.source— the rect a terrain graph starts from: a tiled raster with a height layer, at a chosen resolution.
Shapes and noise
terrain.fbm— fractal noise over the height layer; ridged or plain.terrain.flatten— level the ground inside a placed shape.terrain.cone— a cone or crater at a placed centre.terrain.ridge— a raised or cut ridge along a placed line.terrain.ramp— a graded slope between two heights.terrain.terrace— quantize height into steps.
Rules and blending
terrain.mask— write a soft band over one feature (height, slope, or distance to a curve) into a named layer.terrain.project— band height by distance to a curve.terrain.layer— blend a painted layer into height.terrain.stamp— blend a texture into height at a placement.terrain.coast— pull the ground outside a landmass down to the shore.
Water
terrain.lake— fill a basin to a water level.terrain.river— carve and fill a channel along a curve.terrain.sea— flood everything below a level.
Erosion
terrain.erode— hydraulic (droplet) or thermal erosion, batched over the raster's tiles.
Standing things on it
terrain.scatter— points across the surface, weighted by a mask layer and banded by slope and height, each carrying the normal and slope under it.terrain.drape— anyone else's points put down onto the ground: a graph's ownraster, or the scene'sground.terrain.ground— the ground the scene's Terrain entities stand on, as a graph value read afresh every frame. Wired intoterrain.drape, points land on it wherever the graph stands, each markedgrounded, and a Generator sets them again when the ground is rebuilt or the Generator moves.
Out of the graph
terrain.write— the whole landscape as a.terrainData: the heightfield (rgba32f, R metres, G/B gradient), the control textures saying which surface covers where (rgba8, four layers a texture, weights normalized to sum to one), the holes mask, and the table of what those surfaces are.terrain.to_texture— ONE layer as a Texture on its own, for a raster feeding something other than a landscape.terrain.from_texture— the way back in, and how ground made anywhere else becomes something these ops can carve.
local ref = g.op.terrain.write({ raster = ground, name = "dunes", layers = { "sand", "rock" } })
Then a Terrain component standing on that landscape is what puts it in a scene.