Skip to main content

Module terrain

Module terrain 

Source
Expand description

Unity terrains as stored: TerrainData (the heightmap, holes, splat layers and their alphamaps, tree prototypes and instances) and TerrainLayer.

The heightmap is resolution x resolution samples, row z then column x, each 0..=32766 for 0..1 of the terrain’s height (scale.y metres; TerrainData.GetHeight is h / 32766 * size.y); samples are scale.x and scale.z metres apart from the terrain’s position, so the terrain is (resolution - 1) * scale wide. Holes are one byte per cell, 0 a hole (none stored: no holes). Alphamaps hold four layer weights per texel (RGBA), texel row 0 at z = 0 as Unity stores rows.

Structs§

TerrainData
A TerrainData as stored.
TerrainLayerData
A TerrainLayer as stored.
TreeInstance
A tree placed on a terrain: position as 0..1 of the terrain’s size, scales, rotation about y (radians), colour, and its prototype’s index.

Enums§

HeightmapError
Why check_heightmap refuses a heightmap.

Constants§

MAX_HEIGHT
The highest stored height sample: 0..=32766 is 0..1 of the terrain’s height (TerrainData.GetHeight).

Functions§

check_heightmap
What a heightmap must be to be read: resolution x resolution samples (at least 2 x 2: one cell), each 0..=MAX_HEIGHT, and, where it has holes, one per cell ((resolution - 1)^2).