Skip to content

Generate procedural terrain

quick start Beginner ⏱ 6 min vgai 0.1.0

Prerequisites: Installed vgai and run the editor

What you'll learn

  • Run a scene that uses a geometry generator
  • See a procedural sum-of-sines heightfield
  • Understand the deterministic terrain parameters

What you'll build: A look at the terrain scene — a procedural heightfield from the Terrain generator.

Walkthrough — Generate procedural terrain · generated by site/media/lessons/scenes-batch.lesson.ts (4 steps)

A mesh with a generator field gets its geometry from a registered geometry generator. The terrain scene uses the built-in Terrain generator — a horizontal heightfield displaced by a deterministic sum of sines.

  1. Open the terrain scene. Load examples/scenes/terrain.vscn.json.

    The terrain scene loaded
    The terrain scene.
  2. Enter play mode — the terrain generator builds a heightfield. The Terrain generator produces an XZ plane displaced in +Y.

    The procedural terrain rendered
    A generated heightfield.
  3. A procedural sum-of-sines heightfield renders. Params width, depth, segments, amplitude, and frequency shape it; it’s deterministic (no Math.random), so it pairs cleanly with a trimesh collider.

    The terrain surface
    Deterministic terrain.
  4. Stop play mode. Press Stop (or Escape).

Recap

New functionality

  • Ran a scene using the Terrain generator
  • Saw a procedural heightfield

New concepts & skills

  • A mesh's generator field -> registered geometry generator
  • Terrain is a deterministic sum-of-sines heightfield
  • Params: width/depth/segments/amplitude/frequency; pairs with a trimesh collider

Next lesson → Manual: Instancing, terrain & splines

On Your Own!

Extend what you built:

  • Raise amplitude in generatorParams for taller hills
  • Increase segments for finer detail
  • Add a trimesh collider so physics matches the surface