Generating Terrain

Overview

Shaping every hill by hand takes a long time, especially in a large world. Many games instead generate their landscapes: a program follows rules to make the ground, then a designer changes the parts that matter. In this tutorial, you will generate whole landscapes in Quorum Studio from a preset and a seed, learn how the computer makes random numbers that can be repeated, wear the land down with erosion, press shapes such as hills and craters into it, and make a terrain bigger by adding regions.

Goals

By the end of this lesson, you can

  • Generate terrain from a preset, a seed and a height
  • Describe how each preset makes its kind of land
  • Explain the difference between random and pseudo-random numbers, and why the same seed always gives the same world
  • Use erosion and stamps to change a terrain, and add and remove regions

Warm up

Suppose you rolled dice to decide the height of every square of a map, one roll per square. Would the result look like real land? What would be wrong with it? What rules could you add so that it looks more like hills, or mountains, or canyons?

Vocabulary

You will be learning about the following vocabulary words:

Vocabulary
TermDefinition
Procedural generationCreating content, like terrain, by following rules instead of making each part by hand.
RandomImpossible to predict. A truly random result, like a fair dice roll, can't be known before it happens.
Pseudo-random numberA number that looks random but is made by a formula. Start the formula the same way and it gives the same numbers again.
SeedA starting number for a pseudo-random formula or a generator. The same seed and settings always give the same result.
DeterministicAlways giving the same output for the same input. A generator with a seed is deterministic, even though its result looks random.
NoiseA formula that turns a position into a value that changes smoothly from place to place, used to make natural-looking shapes.
Perlin noiseA kind of smooth noise invented by Ken Perlin. Quorum Studio builds all of its terrain presets from it.
OctaveOne layer of noise. Each octave is finer and smaller than the one before it, and adding several together makes ground with both big shapes and small detail.
Fractal noiseSeveral octaves of noise added together, which makes rolling, natural-looking ground.
Ridged noiseNoise folded so it makes sharp crests, used for mountain ridges.
Ridged multifractal noiseNoise turned the other way from ridged noise, so it cuts sharp valleys into high ground, used for canyons.
TerracingTurning smooth heights into flat steps with steep sides between them, used for plateaus.
PresetA saved set of generator settings, such as Rolling hills or Mountains.
ErosionA simulation of rain wearing ground down, which makes generated terrain look more natural.
StampA whole shape, such as a hill or a crater, pressed into the terrain at the brush.

New Code to Learn

You will be using the following new pieces of code:

New Code to Learn
Quorum CodeCode ExampleExplanation
RandomRandom diceMakes a pseudo-random number generator. Without a seed, it starts from the computer's clock, so it gives different numbers each time the program runs.
SetSeed(number seed)dice:SetSeed(7)Starts the generator from a seed, so it gives the same numbers every time.
RandomIntegerBetween(integer minimum, integer maximum)dice:RandomIntegerBetween(1, 6)Gives a pseudo-random whole number from the minimum to the maximum, such as a dice roll.
RandomNumber()dice:RandomNumber()Gives a pseudo-random number from 0 up to, but not including, 1.

CSTA Standards

For teachers · 2026 CSTA K–12 Computer Science Standards

HS-ALG-PS-04

High School · Algorithms & Design

Describe the differences between deterministic and probabilistic algorithms.

Only this lesson so far

HS-DAT-DC-21

High School · Data & Analysis

Use a computational tool to generate simulated data that fits certain parameters for use in a simulation.

Only this lesson so far

MS-ALG-PS-04

Middle School · Algorithms & Design

Justify whether a problem is best solved using procedural instructions, rule-based logic, data-driven methods, or a combination of these approaches.

Also in 1 other lesson

S1-XCS-XC-03

Specialty I · X+CS

Analyze a computer science technology or approach used in a non-CS discipline (X).

Only this lesson so far

Every standard, and the lessons that cover it

Explore

The tools on this page are in the Generate section of the Properties panel, after the Brush section. Select the terrain, then press Cmd+P on Mac or Ctrl+P on Windows to move into the panel, and Tab to reach the Generate section, or click in it with the mouse. Press Escape to go back to the scene. The top of the section remakes the whole terrain at once; the At the brush part below it changes only the ground under the brush.

Generating a whole terrain

Generating fills the whole terrain with new land, following one of five recipes called presets. Three settings decide what you get: the preset, the kind of land; the seed, a number that picks which of the many possible lands of that kind you get; and the height, the tallest the ground can be, in world units. Generating replaces every height on the terrain, including anything you shaped by hand.

  1. In the Generate section, choose a Preset: Rolling hills, Mountains, Plateaus, Canyons or Flat. With the keyboard, Tab to the Preset group and use the arrow keys; with the mouse, click one.
  2. Type a Seed, or press New seed to pick one at random, from 1 to 99999. It starts at 7.
  3. Type a Height. It starts at 32.
  4. Press Generate: Tab to it and press Space or Enter, or click it.

A large terrain can take a few seconds, and Quorum Studio may pause while it works. When it is done, screen reader users might hear a phrase such as "Generated rolling hills, seed 7, heights 0.4 to 30.1." The Terrain section's Ground height line changes to match.

The presets

Every preset except Flat starts from Perlin noise, a formula invented by Ken Perlin in the 1983 when working on the movie Tron for making natural-looking textures in films. Perlin noise turns a position on the ground into a value that rises and falls smoothly, like gentle waves, and it uses the seed to decide where the waves go. Each preset then uses that noise in its own way.

Rolling hills

Rolling hills uses fractal noise: five layers, or octaves, of Perlin noise added together. The first octave makes the broad shape of the land, and each one after it is smaller and finer, adding bumps on the bumps. Together they make soft, rounded hills of many sizes, like farmland or a park.

Mountains

Mountains uses ridged noise: the noise is folded at the middle of each wave, so every place it crosses the middle becomes a sharp crest. Six octaves of it make crests on crests, which look like mountain ridges. The heights are then pushed down, so the valleys between the mountains are wide and the peaks stand out above them.

Plateaus

Plateaus starts with the same fractal noise as rolling hills, then applies terracing: the heights are cut into five flat steps, with most of each step level and a steep rise up to the next one. The result is flat-topped land with cliffs between the levels, like a mesa or a stepped hillside.

Canyons

Canyons uses ridged multifractal noise, the opposite of the mountains' ridged noise: instead of raising sharp crests out of low ground, it cuts sharp valleys into high ground, with the land between them left smooth. The result looks like a high plain with canyons carved into it.

Flat

Flat sets every height to 0. It is a quick way to start over with a level terrain.

Random numbers and why the seed matters

A truly random result, like a fair dice roll, can't be predicted. A computer, though, follows instructions exactly, so it can't roll real dice. Instead, it uses a formula that makes a long string of numbers that look random: pseudo-random numbers. The formula has to start somewhere, and that starting point is the seed. Start from the same seed, and the formula makes exactly the same numbers, in the same order, every time.

Quorum's Random class is a pseudo-random number generator. This program rolls a six-sided die five times:

use Libraries.Compute.Random

Random dice
dice:SetSeed(7)
repeat 5 times
    output dice:RandomIntegerBetween(1, 6)
end

Run it twice: the five rolls are the same both times, because the seed is 7 both times. Now delete the SetSeed line and run it twice more. Without a seed, Random starts from the computer's clock, which is different every time, so the rolls change.

Terrain generation works the same way. The noise uses the seed to decide where its waves go, so the result is deterministic: generate with the same preset, seed and height, and you get exactly the same land, every time, on every computer. Change the seed, and you get a different land of the same kind. Games use this: a seed is one small number, but it can stand for a whole world. Players can share a seed to play the same map, and a game can make the same world again instead of storing every height.

Erosion

Generated land can look too smooth or too even. Real ground is shaped by rain: water runs downhill, picks up soil where it speeds up and drops it where it slows, carving channels and filling hollows. Quorum Studio's erosion simulates this, following a method by Hans Theobald Beyer: it drops thousands of imaginary raindrops onto the ground, one at a time, and lets each one run downhill, picking up and dropping soil as it goes. Erosion moves ground around; it doesn't add or remove it. It uses a pseudo-random generator, seeded with the terrain's seed, to decide where each drop lands, so it is repeatable too.

  • To erode the whole terrain, press Erode whole terrain in the Generate section. For a new 128 by 128 terrain, it uses 2048 drops of rain, one for every eight samples.
  • To erode only part of it, choose any terrain tool, such as Raise with Alt+1 (Option+1 on Mac), move the brush over the area with the arrow keys or the mouse, and press Erode here in the At the brush part of the section.

Erode more than once for a more worn look. Erosion is a simulation: a simplified model of something real. Ask yourself what it leaves out. Real erosion takes thousands of years and depends on rock, plants and weather.

Stamps

A stamp presses a whole shape into the ground at once, as big as the brush, instead of building it up stroke by stroke. It is the quickest way to put one particular feature exactly where you want it: a mountain in the middle of a plain, a crater, or a ridge along the edge of a valley. Stamps are in the At the brush part of the Generate section, and they have these settings:

  • Stamp: the shape: Hill, Mountain, Mesa (a flat-topped hill), Crater or Ridge.
  • Stamp mode: how the shape meets the ground already there:
    • Usual for the shape, the default, adds a crater's shape onto the ground and raises the ground up to the other shapes;
    • Add puts the shape on top of the ground;
    • Subtract digs the shape into the ground;
    • Raise to the shape lifts the ground up to the shape, and leaves ground that is already higher alone.
  • Stamp height: how tall the shape is, in world units. It starts at 15.
  • Turn: how far to turn the shape, in degrees. This matters for a ridge.

With the keyboard:

  1. With the terrain selected, choose any terrain tool to place the brush, such as Raise with Alt+1 (Option+1 on Mac).
  2. Move the brush with the arrow keys to where the stamp should go, and size it with Alt+= and Alt+- (Option+= and Option+- on Mac).
  3. Press Ctrl+P (Cmd+P on Mac) to move into the Properties panel, and Tab to the At the brush part of the Generate section.
  4. In the Stamp group, use the arrow keys to choose a shape, then Tab to Stamp mode and choose one the same way.
  5. Tab to Stamp height and Turn, and type values if you want to change them.
  6. Tab to Stamp here and press Space or Enter.
  7. Press Escape to go back to the scene.

With the mouse:

  1. With the terrain selected, choose any terrain tool, such as Raise, in the Brush section's Tool group.
  2. Move the pointer over the ground to where the stamp should go; the brush follows it.
  3. In the Generate section, click a shape in the Stamp group and a mode in Stamp mode, and type a Stamp height and Turn if you want.
  4. Move the brush back over the spot if needed, then click Stamp here.

Regions

A terrain is made of square regions, 64 by 64 units for a new terrain. Adding regions makes the world bigger, and removing them makes it smaller. New regions are flat, at height 0, so generate again to fill them with land. Regions sit on a fixed grid, from -16 to 15 along each side.

Adding a region with the keyboard:

  1. With the terrain selected, press Alt+8 (Option+8 on Mac) to choose Add region.
  2. Move the brush with the arrow keys past the edge of the ground, to where the new region should be.
  3. Press Space.

Adding a region with the mouse:

  1. Choose Add region in the Brush section's Tool group.
  2. Move the pointer past the edge of the ground, to where the new region should be, and click.

Removing a region: choose Remove region with Alt+9 (Option+9 on Mac) or in the Tool group, move the brush over the region, and press Space or click.

Growing on every side: in the Terrain section, press Grow by one region on every side, with Space or Enter or a click, to add a ring of regions all the way around the terrain.

When you save, a removed region is left out of terrain.json, so it won't load again. Its image stays in the terrain's folder, unused: Quorum Studio never deletes files from your project.

Engage

In this activity, you and a partner test whether random worlds really are random, first in code and then with the terrain generator. The goal is to understand what a seed does, and to compare a generated world before and after erosion. Start with the dice program from this page: each of you runs it with SetSeed(7) and writes down the five rolls, then compares lists. Then delete the SetSeed line, run it again, and compare once more.

Next, each of you adds a new terrain to your own scene. In the Generate section, both choose Mountains, set the seed to 7 and the height to 32, and press Generate. Compare your two worlds: put the screens side by side, or choose Raise so the brush appears, move it the same number of arrow-key steps from the middle on both computers, and compare the heights reported. Then each of you presses New seed, generates again, and compares once more. Finally, one partner presses Erode whole terrain three times, and you compare that terrain with the other at the same few points. Write down what you noticed at each stage, then discuss:

  • Is a generated world random? What exactly did the seed make repeatable?
  • Why would a game want the same world from the same seed? When would it want a new one?
  • What does the erosion simulation get right about real land? What does it leave out?

Wrap up

Procedural generation turns a few settings (a preset, a seed and a height) into a whole landscape, and the same settings always give the same land. Stamps and erosion then let you change parts of it, and regions let the world grow. In your own games, which parts of a world would you generate by rules, and which would you still make by hand? Why? In the next tutorial, Terrain in a Game, you will load your terrain in a game and walk or drive on it.