menu_bookDocumentation
Terrain System
Terrain System
Create expansive outdoor environments with real-time terrain editing, heightmap import, and multi-layer materials.
Features
| Feature | Status | Notes |
|---|---|---|
| Real-time editing | ✅ | Sculpting tools, 2-layer texture painting |
| Heightmap import | ✅ | World Machine, GeoGen, Gaia (16-bit) |
| Level of Detail | ✅ | Very large landscapes possible |
| Multi-layer materials | ✅ | Up to 32 PBR materials, splatmap import |
| Material height blending | ✅ | Smooth material transitions |
| Anti-tiling | ✅ | Automatic texture variation |
| Physics materials | ✅ | Per-material footstep sounds, bounciness |
| Foliage | ✅ | Grass and scatter meshes |
| Trees | ✅ | Tree placement and rendering |
| Holes | ✅ | Cut holes for caves/buildings |
| NavMesh | ✅ | Automatic navigation mesh generation |
| Vertex displacement | ✅ | Runtime mesh deformation |
Creating Terrain
- Add Terrain Component — Add to a GameObject in your scene
- Set Size — Define terrain dimensions in the inspector
- Edit — Use sculpting tools to shape the terrain
- Paint — Apply multiple materials using splatmaps or brush tools
Heightmap Import
Import from external tools:
- Export 16-bit heightmap from World Machine, GeoGen, or Gaia
- Drag into terrain import dialog
- Adjust scale and offset
Terrain Materials
Multi-layer PBR material system:
- Up to 32 unique materials per terrain
- Height-based blending between materials
- Splatmap import for precise material placement
- Anti-tiling for natural texture variation
Material Setup
CSHARP
// Access terrain materials at runtime
var terrain = Components.Get<Terrain>();
// Get/set material at position
var materialIndex = terrain.GetMaterialIndexAt(worldPosition);
terrain.SetMaterialAt(worldPosition, newMaterialIndex);Foliage System
Scatter vegetation across terrain:
- Grass — Billboard or mesh-based grass
- Scatter Meshes — Rocks, debris, small details
- Trees — Impostor and mesh LOD system
- Density based on slope, height, and material rules
Physics Integration
Terrain collides with physics objects automatically:
- Physics material per terrain material
- Footstep sounds via surface properties
- Bounciness, friction from material definitions
NavMesh Generation
Terrain automatically contributes to NavMesh:
- Walkable areas based on slope
- Respects holes and obstacles
- Dynamic updates when terrain changes
Code API
CSHARP
public class TerrainManager : Component
{
[RequireComponent]
public Terrain Terrain { get; set; }
void ModifyTerrain()
{
// Sculpt at position
Terrain.SculptAt(worldPosition, radius, strength, brushShape);
// Paint material
Terrain.PaintAt(worldPosition, radius, materialIndex, opacity);
// Get height at position
float height = Terrain.GetHeightAt(worldPosition);
// Check if position is on terrain
bool onTerrain = Terrain.IsPointOnTerrain(worldPosition);
}
}Performance Considerations
- Terrain uses chunked LOD system
- Distant chunks render at lower resolution
- Foliage uses distance culling
- Physics mesh is simplified for distant areas
Was this helpful?