Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit8d45df8664

README.md

terrainOps

The terrain.* procgen op family: a whole landscape (a valley, a mountain range, an island ending in a coastline, a plateau cut into terraces) built as a procgen graph.

M.ops is the family, keyed by registry id. procPacks/terrain.procPack returns it, and that asset's registration is what puts every op in the proc registry, the same .procPack path any author outside this package uses to contribute a family. The procgen toolbox's searchNodes lists them and describeNode gives one's inputs, params and outputs. The nodes a graph calls as g.terrain.<name> are this package's terrain.nodebox.

MovementOps
sourceterrain.source: the rect of ground, in metres, at a resolution
shapeterrain.fbm · terrain.cone · terrain.ridge · terrain.ramp · terrain.flatten · terrain.terrace · terrain.stamp · terrain.layer · terrain.project · terrain.erode · terrain.coast · terrain.sea · terrain.lake · terrain.river
maskterrain.mask writes a named layer; every raster kernel op reads one through mask / maskMode / maskGain
baketerrain.write: the whole landscape as a .terrainData: heightfield, control textures, holes mask, layer table
carryterrain.to_texture · terrain.from_texture: one layer in and out of a .texture
standterrain.scatter · terrain.drape: points onto the surface, and anyone else's points back down onto it

The value every op takes and returns is a proc.raster Raster: a tiled GPU grid carrying named scalar layers (height, water, waterMask, and whatever terrain.mask names).

What is in here

FileRole
init.luauAssembles the family into M.ops. Owns terrain.source.
shape.luauThe placed shapes: flatten, cone, ridge, ramp, terrace.
noise.luauterrain.fbm: multi-octave, optionally domain-warped fractal relief.
mask.luauterrain.mask: a soft band over one feature, written to a named layer.
project.luauterrain.project: a curve driving the ground by distance to its polyline.
surface.luaulayer, stamp, coast: an external source blended into height.
water.luaulake, sea, river: one water body over three regions.
erosion.luauterrain.erode: droplet and thermal erosion batched over the tiles.
convert.luauto_texture, from_texture: a raster layer and a texture are the same field in two carriers.
write.luauterrain.write: the whole landscape as one .terrainData container.
scatter.luauterrain.scatter, terrain.drape: a point cloud off the ground, and points put back on it.
scene.luauterrain.ground: the ground the scene's Terrain entities stand on, which drape sets points on.
curve.luauA Curve's control points flattened for the payload binding, shared by project and mask.
lanes.luauThe eight vec4 dispatch lanes a placed-shape kernel's numbers are packed into.
modes.luauThe shader numberings the ops declare.

M.packers and M.payloads expose each kind's dispatch numbers with no GPU dispatch and no readback, which is what a test verifies the maths through.

Out of the graph

A landscape leaves as a .terrainData: the heightfield, the control textures saying which surface covers where, the holes mask, the water surface and the table of what those surfaces are, held together as one asset. terrain.write takes the raster, a name, and the layers (the mask layer names holding each surface's coverage, in channel order), and answers the reference to the container.

Its children are ordinary .texture assets written inside the container, so nothing here is a private format and a material samples a control texture the way it samples any texture. A Terrain component standing an entity on that container is what puts the ground in a scene.

terrain.to_texture carries ONE layer out on its own, for a raster that is feeding something other than a landscape; terrain.from_texture is the way back in, and it is how a heightmap made anywhere else becomes ground these ops can carve.