t1k:unity:rendering:terrain
| Field | Value |
|---|---|
| Module | rendering |
| Version | 5.39.1 |
| Effort | medium |
| Tools | — |
Keywords: environment, landscape, terrain
How to invoke
Section titled “How to invoke”/t1k:unity:rendering:terrainUnity Terrain
Section titled “Unity Terrain”Terminology
Section titled “Terminology”- TerrainData — Asset storing heightmap, splatmaps, trees, details, terrain layers
- Heightmap — 2D float array [0,1] defining terrain vertex heights (indexed as [y,x])
- TerrainLayer — Texture/material definition for terrain painting (replaces old SplatPrototype)
- NavMeshSurface — Component for baking NavMesh on terrain geometry
Skill Purpose
Section titled “Skill Purpose”Reference for Unity Terrain system (Unity 6). Covers programmatic terrain creation, heightmap manipulation, texture painting, tree/detail placement, NavMesh integration, and terrain colliders. Focused on both editor and runtime terrain generation.
Packages: Built-in
UnityEngine.TerrainModule+ optionalcom.unity.terrain-toolsRelated skills:t1k-unity-rendering-probuilder(modular geometry) ·t1k-unity-dots-combat-physics(colliders) ·t1k-unity-dots-nav-agents-navigation(pathfinding)
When This Skill Triggers
Section titled “When This Skill Triggers”- Creating Terrain GameObjects programmatically
- Using
TerrainData.SetHeights(),GetHeights(),SetAlphamaps() - Configuring terrain layers, textures, materials
- Placing trees and detail objects via script
- Generating procedural heightmaps (Perlin noise, diamond-square)
- Baking NavMesh on terrain surfaces
- Terrain collider configuration
Quick Reference
Section titled “Quick Reference”| Task | Reference File |
|---|---|
| TerrainData API, heightmaps, programmatic creation | terrain-api-guide.md (references/terrain-api-guide.md) |
| Terrain layers, textures, painting, splatmaps | terrain-layers-guide.md (references/terrain-layers-guide.md) |
| Trees, details, NavMesh, colliders, performance | terrain-features-guide.md (references/terrain-features-guide.md) |
Key Namespaces
Section titled “Key Namespaces”using UnityEngine; // Terrain, TerrainData, TerrainCollider, TerrainLayerusing UnityEngine.TerrainTools; // Non-experimental terrain tools (Unity 2021+)using UnityEngine.TerrainUtils; // TerrainUtility, TerrainMap, TerrainTileCoordusing Unity.AI.Navigation; // NavMeshSurface for terrain NavMeshKey Conventions
Section titled “Key Conventions”Core workflow — programmatic terrain:
- Create
TerrainDataasset withheightmapResolutionandsize - Generate heightmap float[,] array (Perlin noise, etc.)
- Apply via
terrainData.SetHeights(0, 0, heights)— indexed [y,x], values 0-1 - Set
terrainData.terrainLayersfor textures - Create Terrain + TerrainCollider GameObjects
- Bake NavMesh via
NavMeshSurface.BuildNavMesh()
Critical rules:
- Heights array indexed as
[y,x](NOT [x,y]) — common rotation bug - Height values 0.0-1.0 mapped to 0-
terrainData.size.yworld units - For batch edits: use
SetHeightsDelayLOD()+SyncHeightmap()(faster) heightmapResolutionmust be 2^n + 1 (33, 65, 129, 257, 513, 1025)- TerrainLayer replaces old
SplatPrototype(deprecated since 2018.3) - Terrain collider auto-updates from TerrainData — no manual rebake
- For NavMesh: add
NavMeshSurface, setuseGeometry = PhysicsColliders
Common gotchas:
| Issue | Fix |
|---|---|
| Heightmap rotated 90 degrees | Heights indexed [y,x] not [x,y] |
| SetHeights slow in loop | Use SetHeightsDelayLOD() + SyncHeightmap() at end |
| Terrain layers not painting | Check alphamapResolution matches splatmap size |
| Trees have no colliders | Enable TerrainCollider.enableTreeColliders |
| Details (grass) not rendering | Check detailResolution and detailObjectDensity |
| NavMesh not baking on terrain | Add NavMeshSurface, collectObjects=All, useGeometry=PhysicsColliders |
Documentation
Section titled “Documentation”Hard rules
Section titled “Hard rules”- Terrain heightmap resolution affects collider precision — physics raycast hits can be off by ~1 unit on coarse heightmaps.
- Terrain trees are billboards past distance threshold — performance saver, but shadows disappear which players notice.
- Terrain layers limit at 4 in URP without splatmap addons — going higher requires custom shader or terrain split.
Visual change notice
Section titled “Visual change notice”A visible change made with this skill (UI, sprites, 3D, shaders, VFX, animation, lighting, scene layout; audio excluded) follows core rule visual-change-discord-notice:
- Capture OLD before the first edit and NEW after the last (screen:
ScreenCapturein Play mode pert1k-unity-editor-cli, windowed or Xvfb only because rendering is needed; 3D, shader, VFX: same-scene frame grab; 2D asset: the file). - Return the paths and a draft Discord post to the orchestrator, which posts; the PR links the post or carries
visual-notice-waiver: <reason>. Logic only: “no visible change”. No capture: “screenshots pending:”, never a fake image.