Skip to content

t1k:unity:rendering:terrain

FieldValue
Modulerendering
Version5.39.1
Effortmedium
Tools—

Keywords: environment, landscape, terrain

/t1k:unity:rendering:terrain

  • 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

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 + optional com.unity.terrain-tools Related skills: t1k-unity-rendering-probuilder (modular geometry) · t1k-unity-dots-combat-physics (colliders) · t1k-unity-dots-nav-agents-navigation (pathfinding)


  • 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

TaskReference File
TerrainData API, heightmaps, programmatic creationterrain-api-guide.md (references/terrain-api-guide.md)
Terrain layers, textures, painting, splatmapsterrain-layers-guide.md (references/terrain-layers-guide.md)
Trees, details, NavMesh, colliders, performanceterrain-features-guide.md (references/terrain-features-guide.md)

using UnityEngine; // Terrain, TerrainData, TerrainCollider, TerrainLayer
using UnityEngine.TerrainTools; // Non-experimental terrain tools (Unity 2021+)
using UnityEngine.TerrainUtils; // TerrainUtility, TerrainMap, TerrainTileCoord
using Unity.AI.Navigation; // NavMeshSurface for terrain NavMesh

Core workflow — programmatic terrain:

  1. Create TerrainData asset with heightmapResolution and size
  2. Generate heightmap float[,] array (Perlin noise, etc.)
  3. Apply via terrainData.SetHeights(0, 0, heights) — indexed [y,x], values 0-1
  4. Set terrainData.terrainLayers for textures
  5. Create Terrain + TerrainCollider GameObjects
  6. 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.y world units
  • For batch edits: use SetHeightsDelayLOD() + SyncHeightmap() (faster)
  • heightmapResolution must 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, set useGeometry = PhysicsColliders

Common gotchas:

IssueFix
Heightmap rotated 90 degreesHeights indexed [y,x] not [x,y]
SetHeights slow in loopUse SetHeightsDelayLOD() + SyncHeightmap() at end
Terrain layers not paintingCheck alphamapResolution matches splatmap size
Trees have no collidersEnable TerrainCollider.enableTreeColliders
Details (grass) not renderingCheck detailResolution and detailObjectDensity
NavMesh not baking on terrainAdd NavMeshSurface, collectObjects=All, useGeometry=PhysicsColliders
  • 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.

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: ScreenCapture in Play mode per t1k-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.