Log inGet started
Package

terrainSystem.package

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

terrainSplat (material)

The eight-layer terrain surface. Blends three layer atlases — albedo, normal, mask — by the two RGBA weight textures the landscape was baked with.

You normally do not apply this material yourself

terrainSurface.forLandscape(data) instances it per landscape: the .terrainData's control textures bound as the weight maps, its rect as terrain_field_min / terrain_field_size, its layer slices as the three atlases, and its layer table as the per-layer tints and tilings. What you apply is the handle that call returns — and a Terrain component does even that for you.

This asset is the same shader with defaults, so it is inspectable and it is what a hand-authored variant starts from. Applied by hand it has no weight textures and no field rect, so it renders layer 0 everywhere — an unbound stack looks unbound rather than looking broken.

Properties

PropertyUnitWhat it does
terrain_field_min, terrain_field_sizemetresthe rect the weight textures cover; zero size means no weight map
terrain_normal, terrain_normal_strength—the landscape's own normal per pixel, and how far a pixel takes it over the vertex normal (1 takes it, 0 keeps the vertex normal)
terrain_morph_band_start—where a vertex begins sliding onto its parent's position, as a fraction of its distance band
terrain_cut_eyes_a, terrain_cut_eyes_b, terrain_cut_eye_count—the points the ground's LOD cut was taken for, which the geomorph measures each vertex from
terrain_weights_lo, terrain_weights_hi—layers 0-3 and 4-7, normalised to sum to one; read through a cubic B-spline, so an edge between two layers is a smooth curve through the texels
layer_atlas_albedo / _normal / _mask—4x2 atlases, layer N at (N mod 4, N div 4)
atlas_sizetexelsatlas dimensions, for the half-texel inset between cells
layerN_tint—multiplies layer N's albedo sample
layerN_sizemetresworld metres one repeat of layer N's texture covers
weight_sharpen—1 is the stack as evaluated; higher narrows every transition without moving it
height_blend—0 blends by weight alone; higher gives a contested pixel to whichever layer stands highest at its weight plus its relief, sharing it with the layers within 1 / height_blend of that
normal_strength—scales the blended tangent-space XY; 0 is flat
smoothness, metallic—scale the mask atlas's alpha and red

The mask atlas

Each cell is a mask MAP in the usual channel order: R metallic, G ambient occlusion, B height, A smoothness. White is the neutral one — no occlusion, a level height, and metallic and smoothness left to the two scalars.

The height channel is what makes a transition look like two materials meeting rather than a crossfade: where the weights come near a tie, height_blend gives the pixel to the layer standing highest at its weight plus its height there, so sand settles into the gaps between cobbles instead of fading evenly across their faces. A layer standing within 1 / height_blend of the highest shares the pixel by how near it stands, which is what keeps the edge soft.

A layer's height is read as RELIEF: about the slice's own mean (its coarsest mip), so the edge falls where the weights cross and wanders across that crossing along both surfaces' shapes, whatever scale each texture states its height on. A layer with no mask map reads its relief from its albedo's light and shade about the slice's mean luminance — light faces stand proud, dark cracks sink — so a rock without a mask still takes sand into its cracks. Layers standing level meet along the line where their weights cross.

Three atlases, not twenty-four slots

A slot per layer per map would put twenty-four sampled textures in one bind group, which is past what WebGPU guarantees a shader stage. The atlas keeps the cost at three whatever the layer count is. terrain.write packs the sheets when it bakes a landscape — a layer names its own albedo / normal / mask textures and they are resampled into that layer's cell — so the packing is not something an author does by hand.

A stack with no atlas at all renders its eight layerN_tint colours, which is enough to see every rule working.