Terrain
What is terrain?
Most of the world in Terra Diem is represented by terrain. In the game, terrain is a fairly general concept covering everything from rock, water, trees, vegetation, and even buildings. There are three fundamental properties of terrain:
- Terrain has a fixed 3D location in the world (in meters). It does not move (although it can change)
- All terrain can be subdivided into individual cubic meter pieces. For instance, a tree is made out of individual pieces of trunk, branch, and leaves within each cubic meter of space in the world.
- Terrain is made out of materials. Materials have various properties that define how the terrain looks and behaves in the world. For instance, a material may be liquid, loose, or solid. It also may be transparent, translucent, or opaque.
Terrain representation
Terrain is organized hierarchically:
- Column: The top level division of terrain is the column. Columns cover a 16x16 meter area and the entire vertical span of the world (which in turn is set via generation parameters). Columns are largely an optimization to aid culling and light propagation.
- Chunk: A chunk is a 16x16x16 meter cube of space in the world. This is the smallest unit of generation, serialization, and simulation for the world. A chunk stores all the terrain and local simulation state for the chunk. At a minimum each chunk consumes a little over 8K of memory when loaded (8K for block storage and some miscellaneous book keeping).
- Block: A block represents a single cubic meter of space in the world. It may be as small as 2 bytes (and usually is) or very large depending on what types of terrain exist in the block.
- Block Instance: Each block contains a list of instances which define what is in the block. A block with no instances is pure air. Each instance has a type, material, and other parameters which together defines what terrain is in the block. A chunk may contain up to 16,384 block instances.
Block volume
Each block represents a finite amount of space, and thus material. The smallest unit of volume in Terra Diem is a “bit”, and each block may contain up to 64 bits of material. Each block instance represents a certain volume in bits, but the total volume of all block instances will never exceed 64. Any unused space in a block is implicitly filled with air.
Block instance types
There are currently five types of block instances:
- Single material: This is the simplest form of instance. It specifies a material that completely fills the remaining space in the block.
- Partial block: This subdivides a block into 8 smaller cubes (2x2x2) which may or may not contain material. Partial blocks are made of a solid material, and may also define a secondary solid material which consumes the rest of the space.
- Partial slope: This subdivides a block by chopping off one or more corners of the block. The remaining corners are wrapped giving a convex solid which defiines the space consumed by the instance material. Like partial blocks, partial slopes are made of solid material and may also define a secondary solid material which consumes the rest of the space.
- Partial amount: This instance type defines only how much of a material is in the block (in bits). Partial amount materials pile up in the block in the space not consumed by other instances.
- Tree: This represents a trunk or branch, with zero or more child branches leading to neighboring blocks (directly adjacent or diagonal). Each branch is an octagonal prism. Tree instances are made of a solid material (usually wood), and consume space based on the diameter of the branches.