Getting Started with Unity Terrain: Building Vast Natural Environments Efficiently

Created: 2026-02-05Last updated: 2026-10-10

Learn how to create vast natural environments with Unity's Terrain system. Covers terrain sculpting, texture painting, placing trees and grass, and performance optimization in detail.

You want a game world players can roam freely. But modeling every hill and valley by hand in a 3D tool and stitching them together? Just thinking about it is exhausting — terrain is often the first wall you hit when you dream of building an open-world-style game.

Unity Terrain is Unity's built-in terrain creation system. Raise hills as if painting with a brush, lay down textures, and plant trees and grass — that's all it takes to build vast natural environments efficiently.

Conceptual image of Terrain: a giant brush sculpting a hill on a white miniature landscape diorama with a blue river and trees

What You'll Learn

  • Creating terrain starting from GameObject > 3D Object > Terrain
  • Sculpting (Raise/Set Height/Smooth/Paint Holes) and shortcuts
  • Texture painting with Terrain Layers and placing trees and grass
  • Performance optimization (Pixel Error and the various Distance settings)
  • Splitting huge maps into multiple Terrain tiles
  • Hands-on: building a mountain field with a winding trail from start to finish

Tested with: Unity 6 (6000.x)

Sponsored

Creating a Terrain

Simply choose GameObject > 3D Object > Terrain from the menu, and a flat 1000x1000 terrain is generated (with a maximum Height of 600 and a Heightmap Resolution of 513×513).

The Five Main Tools

ToolDescription
Create Neighbor TerrainsCreate adjacent Terrain tiles
Paint TerrainSculpt the landscape and paint textures
Paint TreesPlace trees
Paint DetailsPlace details such as grass, flowers, and rocks
Terrain SettingsGeneral settings (size, resolution, performance)
Overview of the five main Terrain tools: Create Neighbor Terrains (add tiles), Paint Terrain (edit terrain), Paint Trees (place trees), Paint Details (place grass), and Terrain Settings (general settings), shown as five cards

Paint Terrain: Sculpting and Painting the Landscape

Sculpting Tools

ToolDescription
Raise or Lower TerrainRaise or lower the terrain height (hold Shift to lower)
Set HeightSet a specific height (handy for creating flat plateaus)
Smooth HeightSmooth out the terrain
Stamp TerrainStamp the brush shape onto the terrain
Paint HolesCut holes into the terrain (cave entrances, etc.)
Effects of the three main sculpting tools: Raise or Lower Terrain builds up a hill, Set Height flattens to a plateau of uniform height, and Smooth Height turns jagged terrain into smooth slopes

Steps for creating a cave:

  1. Cut a hole in the terrain with Paint Holes
  2. Place a 3D cave mesh at the hole's position
  3. Seamlessly connect the mesh edges to the Terrain boundary
  4. Add colliders as needed

Shortcuts

KeyFunction
, .Switch brushes
[ ]Change brush size
- =Change opacity
FFocus the camera on the cursor position on the Terrain
Sponsored

Terrain Layers: Painting Textures

Creating a Terrain Layer

  1. Select the Paint Terrain tool
  2. Choose Paint Texture from the dropdown
  3. Click Edit Terrain Layers > Create Layer
  4. Set the textures (Diffuse, Normal Map, Mask Map, etc.)

Painting Textures

  1. Select a Terrain Layer
  2. Set the brush size and opacity
  3. Drag across the terrain to paint

Painting at low opacity blends naturally with the layers underneath.

Conceptual diagram of texture painting with Terrain Layers. A miniature mountain is painted in four bands by elevation — grass, dirt, rock, and snow — with the band borders softly blending into each other while a brush smooths one of the transitions

The classic approach is to paint by elevation: grass at the foot, dirt and rock on the slopes, snow at the summit. Rather than hard borders, layering at low opacity so the bands bleed into each other looks far more natural.

Terrain Layer Limits

Render PipelineLayers per draw passNotes
URP and Built-in4 layersNo fixed cap, but a 5th layer adds another draw pass
Mobile (recommended)4 layersFits in one draw pass to maintain performance
URP Height-based BlendUp to 4 layersBlends borders by height. Unavailable with 5 or more layers

Caution: As the layer count grows, draw passes increase and performance drops sharply. On mobile, keeping it within 4 layers is recommended.

Trees: Placing Trees

Adding Trees

  1. Select the Paint Trees tool
  2. Click Edit Trees > Add Tree
  3. Select a tree Prefab
  4. Drag across the terrain to place trees (hold Shift to remove)

Mass Place Trees

Mass Place Trees randomly places trees across the entire terrain in one go. Run it with Keep Existing Trees off and every tree you've already planted gets replaced.

Tree Settings

SettingDescription
Bend FactorHow strongly trees sway in the wind (Wind Zone). Set per tree in Edit Trees (affects Tree Editor trees)
Billboard StartThe distance at which trees switch to billboard rendering (set in Terrain Settings)

SpeedTree vs regular Mesh: SpeedTree assets come with a built-in LOD Group and transition between LODs automatically. Regular Mesh trees also switch step by step with distance if you add an LOD Group to the Prefab. If you want high-quality trees, SpeedTree-compatible assets are recommended.

Sponsored

Details: Placing Grass and Details

Detail Types

TypeDescription
GrassRendered as billboards (flat quads). Lightweight
Detail MeshRendered as 3D meshes. Fully three-dimensional

Adding Details

  1. Select the Paint Details tool
  2. Click Edit Details > Add Grass Texture or Add Detail Mesh
  3. Drag across the terrain to place them

Terrain Settings: Configuration and Performance Optimization

Basic Settings

SettingDescription
Terrain Width/Length/HeightTerrain size
Heightmap ResolutionHeightmap resolution (2^n + 1)
Detail ResolutionDetail resolution

Heightmap Resolution Guidelines

Project ScaleResolutionNotes
Prototype / small257×257Low memory usage
Typical game513×513Well balanced
Large open world1025×1025High detail but high memory usage
Massive scale2049×2049 or higherSplitting into multiple tiles recommended

Detail Resolution Guidelines

ProjectResolutionDetail Resolution Per Patch
Mobile512–10248
PC / console1024–204816
High quality2048–409632

Performance Settings

SettingDescription
Pixel ErrorLOD accuracy (1–200, default 5. Start from the default and raise it as needed)
Base Map Dist.Distance at which the terrain switches to the base map (simplified rendering)
Detail DistanceDistance up to which details are rendered
Tree DistanceDistance up to which trees are rendered
Draw InstancedSpeeds up rendering with GPU Instancing

Draw Instanced: Enabling this option speeds up Terrain rendering using GPU Instancing. It is especially effective when using multiple Terrain tiles.

Conceptual diagram of the distance-based performance settings: three bars of different lengths extend right from the camera. The shortest, Detail Distance, is grass; the middle one, Base Map Dist., is simplified terrain; the longest, Tree Distance, is how far trees are drawn

The three distances are independent settings. Even their defaults are all over the place (Detail Distance 80, Base Map Dist. 1000, Tree Distance 5000), so things don't disappear in a fixed order. Shortening each Distance makes rendering lighter at the cost of a sparser far view.

Wind Settings

You can configure grass swaying under Terrain Settings > Wind Settings for Grass.

SettingDescription
SpeedWind speed
SizeSize of the wind waves
BendingHow much the grass bends

Grass Tint: The "Grass Tint" option in the same section adjusts the color tint of the grass — it is a visual adjustment separate from the wind effect.

Scope of Wind Settings:

  • Details (Grass Texture, Detail Mesh) → affected
  • Trees (placed with Paint Trees) → not affected (trees are configured individually via Bend Factor; SpeedTree trees use SpeedTree's own wind settings)

Multiple Terrain Tiles

When building a large map, splitting it into multiple Terrain tiles can improve performance.

Creating Tiles

  1. Select a Terrain
  2. Click the Create Neighbor Terrains tool
  3. Choose the direction in which to create the new tile

Neighboring tiles connect automatically so their LOD and normal transitions line up. Edge heights aren't matched, though, so when you create a new tile, make sure Fill Heightmap Using Neighbors is on. With it on, the new tile inherits the heights along its neighbor's edge.

Conceptual diagram of multiple Terrain tiles: a landscape split into a 3x3 grid of tiles sits side by side with no gaps, a new tile is added with Create Neighbor Terrains, and borders connect seamlessly

Managing Tiles with Grouping ID

For large maps, give each Terrain the same Grouping ID in Terrain Settings and turn on Auto Connect, and neighboring tiles connect automatically. To connect them from a script, use Terrain.SetNeighbors().

Terrain Tools: The Terrain Tools package (installation is in a later section) makes batch-editing multiple tiles even more convenient.

Importing and Exporting Heightmaps

Terrain Settings > Import Raw / Export Raw lets you read and write 16-bit RAW files. Use this to integrate with external tools such as World Machine and Gaia, or to generate terrain from grayscale images created in Photoshop.

Manipulating Terrain from Scripts

You can manipulate the terrain from scripts through TerrainData.

using UnityEngine;

public class TerrainModifier : MonoBehaviour
{
    Terrain terrain;
    TerrainData terrainData;

    void Start()
    {
        terrain = GetComponent<Terrain>();
        terrainData = terrain.terrainData;
    }

    // Get and set heights (x, y are pixel coordinates)
    // Important: the heights array is indexed as [y, x] (row, column)
    // terrainData.GetHeights(xBase, yBase, width, height) takes arguments in (x, y) order,
    // but the returned array is accessed as heights[y, x]
    public void ModifyHeight(int x, int y, float height)
    {
        float[,] heights = terrainData.GetHeights(x, y, 1, 1);
        heights[0, 0] = height;  // range 0 to 1
        terrainData.SetHeights(x, y, heights);
    }

    // Convert world coordinates to pixel coordinates (with range clamping)
    // With a heightmapResolution of 513, valid pixel coordinates are 0 to 512
    public Vector2Int WorldToHeightmapCoord(Vector3 worldPos)
    {
        Vector3 terrainPos = worldPos - terrain.transform.position;
        int maxIndex = terrainData.heightmapResolution - 1;
        int x = Mathf.Clamp(
            Mathf.RoundToInt(terrainPos.x / terrainData.size.x * maxIndex),
            0, maxIndex);
        int y = Mathf.Clamp(
            Mathf.RoundToInt(terrainPos.z / terrainData.size.z * maxIndex),
            0, maxIndex);
        return new Vector2Int(x, y);
    }

    // Set the texture (Alphamap)
    public void PaintTexture(int x, int y, int layerIndex)
    {
        float[,,] alphas = terrainData.GetAlphamaps(x, y, 1, 1);
        // Reset all layers
        for (int i = 0; i < alphas.GetLength(2); i++)
            alphas[0, 0, i] = 0;
        alphas[0, 0, layerIndex] = 1;
        terrainData.SetAlphamaps(x, y, alphas);
    }
}

Use cases: Procedural terrain generation and runtime terrain deformation (digging, flattening, etc.).

In the Editor: TerrainData is an asset, so terrain you rewrite during Play stays changed after you stop Play. Duplicate the TerrainData asset as a backup before you experiment.

Coordinate system caveat: heightmapResolution and alphamapResolution may return different values. Be careful not to mix up heightmap coordinates and alphamap coordinates.

Difference between Heightmap and Alphamap resolutions:

PropertyValue PatternExamples
heightmapResolution2^n + 1513, 1025
alphamapResolution2^n512, 1024

Procedural Terrain Generation with Perlin Noise

public void GenerateProceduralTerrain(float scale, float heightMultiplier)
{
    int res = terrainData.heightmapResolution;
    float[,] heights = new float[res, res];

    // Add offsets to generate variation,
    // since Mathf.PerlinNoise always returns the same result for the same input
    float offsetX = Random.Range(0f, 10000f);
    float offsetY = Random.Range(0f, 10000f);

    for (int y = 0; y < res; y++)
    {
        for (int x = 0; x < res; x++)
        {
            heights[y, x] = Mathf.PerlinNoise(
                (x + offsetX) / (float)res * scale,
                (y + offsetY) / (float)res * scale
            ) * heightMultiplier;
        }
    }
    terrainData.SetHeights(0, 0, heights);
}

The Terrain Tools Package

Installing the Terrain Tools package unlocks additional sculpting tools and advanced features such as erosion simulation.

Installation

  1. Open Window > Package Manager
  2. Click the + button and choose Add package by name...
  3. Enter com.unity.terrain-tools and install

Added Tools

ToolDescription
BridgeConnect two points with a bridge
CloneCopy and paste part of the terrain
ErosionErosion simulation (weathering, water flow, etc.)
TerraceCreate stepped, rice-terrace-like landscapes
NoiseNoise-based terrain generation
Sponsored

Hands-On: Building a Mountain Field with a Winding Trail

The grassland and snowy peaks of an open-world RPG, the forest around your base in a survival crafting game, the mountain range rolling past in the background of a racing game — the genres differ, but "a field with a mountain, a trail, trees, and grass" is the classic thing you build with Terrain. Let's use every tool covered so far to finish one explorable mountain field.

The finished result: a clay-style diorama with a snowy mountain in the back, a winding trail running from the foothill plain up the slope, trees on the hillsides, and a lake and dense grass area at the base
  1. Decide the size and resolution: In Terrain Settings, set Width/Length to 500×500 and Heightmap Resolution to 513×513. Finishing a smaller map teaches you far more than abandoning a giant 1000×1000 one
  2. Start with the big shapes: Raise the mountain ridge in the back with a large Raise or Lower Terrain brush, then flatten a plateau at the base with Set Height — that's your future village or base site
  3. Lay the trail: Type a number (in meters) into Set Height's Height field and even out a winding path from the foothills to mid-slope, raising the height section by section (e.g., 5 → 15 → 25 → 40). Painting on at one height gives you a flat trench, not a climbing trail. Finish by running Smooth Height over the steps and the edges until it reads as a walkable slope
  4. Paint the textures: Register four layers (grass, dirt, rock, snow) with Edit Terrain Layers > Create Layer and paint them following the elevation, then overwrite just the trail with the dirt layer (four layers fit in a single draw pass)
  5. Plant trees and grass: Register a tree Prefab with Edit Trees > Add Tree, bulk-place with Mass Place Trees, then Shift-drag to clear the trail and the plateau. Register grass with Edit Details > Add Grass Texture, and keep grass (Details) dense only around the foothills where players actually walk — good looks and good performance at once
  6. Finish with distance tuning: Adjust Pixel Error and Tree/Detail Distance in Terrain Settings, and check the frame rate with Stats in the Game view

Two points matter most.

  • Work from big shapes to details: If you polish trails and small bumps first, re-raising the mountain later destroys them. Mountain → plateau → trail → vegetation means never redoing work
  • Design the gameplay flow first: Decide where the trail, base, and vista points go, then shape the terrain around them. Starting from looks tends to produce maps that are beautiful but unfun to traverse

If all those trees and grass start weighing down the frame rate, the draw call optimization guide and the mobile optimization guide will help.

Bonus: Good Things to Know in Advance

Once your field takes shape, these topics come into view next. Even just knowing the names keeps you from getting lost.

  • Want AI to walk on your terrain? A Terrain can be baked into a NavMesh (in Unity 6, bake it with the AI Navigation package's NavMesh Surface). See the NavMesh guide for making enemies and NPCs patrol your field.
  • Rocks, bridges, and buildings are regular 3D models: Terrain only handles the ground. Props on top of it are imported 3D models — the 3D model import guide covers the details.
  • Rendering constraints depend on your render pipeline: Specs like how many Terrain Layers fit in one draw pass (4 on URP and Built-in) are tied to the pipeline. The render pipeline guide gives you the full picture.

Summary

Unity Terrain is a powerful system for efficiently building large-scale natural environments.

  • Paint Terrain - Sculpt the landscape and paint textures with brushes
  • Paint Trees / Paint Details - Quickly place trees and grass
  • LOD and culling - Rich set of performance optimization features
  • Multiple tiles - Scales up to huge open worlds

Start with a single 500×500 map. What kind of terrain does your game's world stand on?

Read nextOn to AI
AI

Unity AI Navigation: Building Smart Enemy Characters with NavMesh

Read this note
Unity Notes in this section100