Foliage
Overview
Bare ground looks empty. Real land is covered with rocks, bushes, trees and grass, and placing each one by hand would take forever. In Quorum Studio, these are called foliage: models or pictures that the terrain scatters over the ground in many copies. You choose which ones a terrain can use, and then paint them on with a brush, the way you paint ground materials. In this tutorial, you will add rocks to a terrain, paint them, remove them, and change their settings. You will also learn why thousands of copies can slow a game down, and which settings keep it running smoothly.
Goals
By the end of this lesson, you can
- Add a foliage asset to a terrain, and paint and remove its copies with the Foliage tool
- Change an asset's settings, such as its density, size, lean, color, wind, levels of detail and shadows
- Explain what foliage costs the computer each frame, and how density and draw distance change the frame rate
- Compare two versions of a scene and decide which one plays better
Warm up
Imagine drawing a forest by hand, one tree at a time, and then being asked to draw it again 60 times every second. What shortcuts would you take? Would you draw the trees far away as carefully as the ones close to you? Would you draw the ones behind you at all?
Vocabulary
You will be learning about the following vocabulary words:
| Term | Definition |
|---|---|
| Foliage | Plants, rocks and other small things scattered over a terrain in many copies, such as trees, bushes, stones and grass. |
| Foliage asset | One kind of foliage, such as one rock model. A terrain can use up to 16. |
| Copy | One placed rock, tree or tuft of grass. A copy has its own place, size and turn, but shares its asset's model. |
| Card | A flat picture standing up on the ground, used instead of a model for things like grass. Its clear parts are cut away. |
| Coverage | How much an asset grows at each place on the ground, from 0 (none) to 1 (its full density). The Foliage brush paints it. |
| Density | How many copies grow on each square unit of ground where the asset's coverage is full. |
| Draw distance | How far from the camera copies are drawn. Copies farther away are skipped. |
| Level of detail | A simpler version of an asset, such as a plainer model or a flat card, drawn in place of the full one when the camera is far away. |
| Frame rate | How many pictures a game draws each second. A higher frame rate looks smoother. |
| Culling | Skipping things that can't be seen, such as things behind the camera or too far away, so the computer doesn't spend time drawing them. |
| Graphics Processing Unit (GPU) | The graphics processing unit: the part of the computer that draws pictures, many points at the same time. |
| Central Processing Unit (CPU) | The central processing unit: the part of the computer that runs the program, one step after another. |
New Code to Learn
You will be using the following new pieces of code:
| Quorum Code | Code Example | Explanation |
|---|---|---|
| action Update(number seconds) | action Update(number seconds) | An action a game can have, which Quorum calls once every frame. seconds is how long the last frame took. |
| LoadScene(text path) | LoadScene("Scenes/Scene.qs") | Loads a scene made in Quorum Studio, with its terrain, foliage and water. |
| output | output "Frames this second: " + frames | Writes a line of text to Quorum Studio's output window. |
| SetPath(text path) | file:SetPath("FramesA.csv") | Sets which file a File stands for. A path without folders is in the folder the program runs from. |
| OpenForWrite(File file) | log:OpenForWrite(file) | Opens a file for writing, with a FileWriter. Anything already in the file is replaced. |
| WriteLine(text line) | log:WriteLine("second,frames") | Writes a line of text to the file. |
| PushToDisk() | log:PushToDisk() | Saves what has been written so far, so it is kept even if the program stops suddenly. |
| action OnExit returns boolean | action OnExit returns boolean | An action a game can have, which Quorum calls when the game is about to close. Returning true lets it close. |
CSTA Standards
For teachers · 2026 CSTA K–12 Computer Science Standards
Specialty II · Game Development
Analyze game system architectures that support scalability, maintainability, and performance.
Also in 1 other lesson
Specialty II · Game Development
Evaluate two versions of a game using defined metrics to determine which performs better.
Only this lesson so far
Specialty I · Data Science
Apply exploratory data analysis techniques to non-hierarchical quantitative data.
Also in 1 other lesson
High School · Systems & Security
Demonstrate the capabilities and limitations of a physical or simulated computing device to address a task or problem.
Also in 1 other lesson
Explore
This tutorial uses a terrain from the earlier tutorials, with some hills and flat places. Select it before you start, from the scene tree or by clicking the ground. Like the terrain itself, foliage is drawn with Vulkan.
Getting a model
Foliage starts with a model file. Quorum Studio can use models in the
.glb, .gltf, .fbx and .obj formats, or a .png picture for a card.
Small, simple models work best, because there will be many copies of them.
The examples in this tutorial use three rock models, RockA.glb,
RockB.glb and RockC.glb, from the demo of Terrain3D, a free terrain tool
for the Godot game engine. They are shared under the MIT license, which
lets anyone use them as long as the license notice goes with them. Put the
models in a folder in your project, such as Models/Foliage, with the
license file beside them. As with any art you didn't make, add a line to
your game's credits saying where the rocks came from.
Adding an asset
- Select the terrain, and go to the Foliage section of the Properties panel. With the keyboard, press Ctrl+P (Cmd+P on Mac) and Tab until you reach it.
- Press Add asset..., and choose a model or a picture.
- Quorum Studio reports the change to accessibility tools, which may give a phrase such as "Added RockA as foliage asset 1, a model. Paint it with the Foliage tool."
The first time you add an asset, Quorum Studio makes a foliage list for
the terrain: a file in the project's Scenes/Foliage folder, named after
the terrain's folder, such as Scenes/Foliage/Terrain1.json. The list
holds the assets and their settings. The copies themselves are saved beside
the terrain's own files, one file for each region that has foliage.
The section's first line says how many copies the terrain has in all, such as "20719 copies in all." Under it, the assets are listed in alphabetical order. Each asset is a heading that opens and closes, like the other parts of the Properties panel, with a line under it that says whether it is a model or a card and how many copies it has, such as "Card, 20529 copies". Click an asset's name or its arrow to open it, or move to it with Tab and press Enter; the same opens and closes each group of settings. Only one asset is open at a time.
An open asset shows:
- Name: what the asset is called in the section and in Quorum Studio's reports.
- Its settings, in five groups that open and close: Placement, Lean and turn, Color and wind, Levels of detail, and Shadows. They are described below.
- Remove (for example,
Remove Grass
), which takes the asset away with every copy of it. This can't be undone, so take care with it.
Adding and removing assets can't be undone yet.
Painting foliage
The Foliage tool paints where one asset grows: its coverage, from none to full. Quorum Studio then works out the copies from the coverage and the asset's settings.
- Choose the Foliage tool: press Shift+Alt+4 (Shift+Option+4 on Mac), or choose Foliage in the Brush section's Tool group. You can also find it in the Scenes menu (Alt+C, or Option+C on Mac), under Terrain and then Tools.
- Choose the asset to paint in the Brush section's Foliage Asset card. It lists the terrain's assets in the same alphabetical order as the Foliage section.
- Set the brush. Size is the brush's radius. Strength sets how thick the asset grows where you paint: the usual strength or more is the asset's full density, and less is sparser. Painting a weaker brush over thick growth thins it. Press Alt+= and Alt+- for a larger or smaller brush, and Alt+] and Alt+[ for a stronger or weaker one (on Mac, Option).
- Paint:
- With the keyboard: move the brush with the arrow keys and hold Space. Keep holding it and move the brush to paint a trail.
- With the mouse: a gray ring follows the pointer, showing where the brush would go. Click outside the brush's ring to move the brush there, and click inside it to paint once. Hold the button down for a moment, anywhere, to start painting there, and drag to keep painting.
Under the brush, the coverage moves toward the brush's strength: fully near the middle, fading toward the edge. Copies grow at random spots within the coverage, with random sizes and turns, but only where the ground's slope suits the asset. The same coverage always grows the same copies, so the foliage is the same every time the scene opens, and in the running game. When you let go, Quorum Studio reports what changed and what is now under the brush, as a phrase such as "Added 14 RockA. Under the brush: 14 RockA, coverage 1.0." Painting a weaker brush over thick growth reports, for example, "Thinned RockA, 40 fewer." The whole stroke is one step for Undo.
If the terrain has no assets yet, the report is "The Foliage tool needs a foliage asset. Add one in the Foliage section."
Removing foliage
The same tool removes foliage, by lowering its coverage. In the Brush section's Foliage Asset card, the Foliage brush choice sets what the brush does:
- Paint: paint where the chosen asset grows.
- Remove this asset: remove the chosen asset under the brush.
- Remove every asset: remove all foliage under the brush.
With the keyboard, Alt+L (Option+L on Mac) switches between the three, and Quorum Studio reports the new choice, such as "Foliage brush: remove RockA." Then use the brush as usual: hold Space, or the mouse button, and move it.
| Action | Windows | Mac |
|---|---|---|
| Choose the Foliage tool | Shift+Alt+4 | Shift+Option+4 |
| Switch the brush between Paint, Remove this asset and Remove every asset | Alt+L | Option+L |
| Use the brush (hold) | Space | Space |
| Remove the chosen asset, whatever the choice (hold) | Ctrl+Space | Not on Mac |
| Remove every asset, whatever the choice (hold) | Ctrl+Shift+Space | Not on Mac |
| Larger or smaller brush | Alt+= or Alt+- | Option+= or Option+- |
| Stronger or weaker brush | Alt+] or Alt+[ | Option+] or Option+[ |
| Leave the tool | Escape | Escape |
On Windows, holding Ctrl as a stroke starts also removes the chosen asset, and holding Ctrl and Shift removes every asset, whatever the choice is. On a Mac, the system uses Control and Space for itself, so use the choice or Option+L instead.
Quorum Studio reports how many copies went, such as "Removed 5 RockA." When
every asset is removed, the report names foliage
instead of an asset's
name. Remember to switch back to Paint before painting again.
Foliage follows the ground
You can keep shaping the ground after painting foliage. When you raise or lower the ground, stamp a hill, erode it, or undo a change, the copies move up or down with the ground, so rocks never float in the air or sink out of sight. When a stroke ends, the copies are worked out again, so an asset still grows only on the slopes it suits. Nothing needs to be turned on for this; it always happens.
An asset's settings
Open an asset in the Foliage section to change how its copies are placed and drawn. A field takes its new value when you leave it, with Tab or a click elsewhere. A value that isn't a number, or is out of range, is ignored.
Every setting applies to all of the asset's copies, everywhere you painted it, as soon as you change it. You never need to paint again to change how foliage looks. Raising Density keeps every copy that is there and adds more between them; lowering it takes some away, and the rest stay where they are.
Placement
| Setting | What it does |
|---|---|
| Density | How many copies grow per square unit where the coverage is full. Trees might use 0.02, and grass 2. |
| Scale | The copies' size. 1 is the model's own size. |
| Size varies | How much the copies' sizes vary, as a share. 0.2 means up to 20 percent larger or smaller. |
| Lowest slope | The gentlest slope the asset grows on, in degrees. 0 is flat ground. |
| Steepest slope | The steepest slope the asset grows on, in degrees. Trees might stop at 35, while rocks can sit on steeper ground. |
| Height offset | How far above the ground each copy stands. A negative number sinks it into the ground, which helps rocks look settled. |
| Grows on layer | 0 to grow where the Foliage brush paints the asset. 1 to 4 to grow wherever that material layer is painted on the ground, as much as it is painted, so painting the ground Grass grows grass. With a layer chosen, the painted coverage is ignored. |
Lean and turn
| Setting | What it does |
|---|---|
| Lean with slope | A checkbox. When it's on, copies stand at right angles to the ground, leaning with a hillside, as grass and rocks often do. Trees usually look better upright, with it off. |
| Lean | How far every copy leans, in degrees from upright. Each copy leans in its own direction. |
| Lean varies | How much more each copy may lean, at random, in degrees. 10 to 15 keeps grass from standing too straight. |
| Random turn | A checkbox. When it's on, each copy is turned a random amount around the up direction, so they don't all face the same way. |
| Turn | A turn, in degrees, that every copy gets around the up direction, added to its random turn. With random turn off, it turns every copy to face the same way, such as a row of fences. |
| Card planes | For a card: how many pictures stand at each copy, from 1 to 3, each turned its own way. 1 suits grass painted densely; 2 or 3 make loose bunches. |
Color and wind
| Setting | What it does |
|---|---|
| Shade varies | How much darker some copies are than others, from 0 (all the same) to 1. 0.1 darkens each copy by up to 10 percent. |
| Tint | A color the copies are tinted, as three small fields: red, green and blue, each from 0 to 1. 1, 1, 1 is white, which means no tint. 0.8, 1, 0.6 makes grass a fresher green, and 1, 0.9, 0.6 makes it dry and yellow. |
| Hue varies | How far each copy's color may turn around the color wheel, in degrees either way, chosen at random for each copy. At 20, some tufts are greener and some yellower. It turns the tint, so it shows only when the tint isn't white. |
| Wind | How much copies sway: how far a point moves sideways for each unit of height above the copy's base. The base stays still and the tip moves most, and copies near each other don't sway together. Try 0.05 to 0.1 for grass and 0.02 to 0.05 for trees. 0 keeps them still. |
| Wind direction | Which way the wind blows, in degrees around the up direction: 0 along the x axis, 90 along the z axis. |
Levels of detail
Far from the camera, a detailed model is only a few pixels tall, so drawing all its triangles is wasted work. Levels of detail let a copy switch to something simpler when it's far away. The asset's own model or picture is used up close. Each level after it is used from a distance you choose, and the farthest level that has been reached is the one drawn. Levels are chosen for a whole cell of foliage at a time, measured from the camera to the cell's nearest side.
| Setting | What it does |
|---|---|
| Draw distance | How far from the camera copies are drawn, in units. Over the last fifth of that distance, copies thin out a few at a time, so far foliage fades instead of ending in a line. |
| Level 1 to 3 file | A simpler version of the asset: a model (.glb or .gltf) or a picture (.png or .jpg), which is drawn as a flat card. Press Choose... under the field to pick the file, or type its path, which is relative to the foliage list's file. Empty the field to stop using the level. If the file can't be found, the asset's own model is used. |
| Level 1 to 3 from | The distance from the camera from which the level is used. Give later levels larger distances, such as 40 for level 1 and 100 for level 2. A new level starts at half the draw distance. |
| Fade margin | How far before a level's distance the change begins, in units. At 0, a cell switches all at once. At 10, a growing share of the copies switch over those 10 units, so the change is hard to notice. |
For example, a tree might use its full model up close, a simpler model from 40 units, a flat card from 100 units, and nothing past 250.
Shadows
| Setting | What it does |
|---|---|
| Casts shadows | A checkbox. Whether copies cast shadows. Grass usually doesn't, and turning shadows off for grass saves a lot of work. |
| Last shadow level | The farthest level of detail that casts shadows, from 0 to 3. Levels past it cast none, since shadows of far trees are hardly noticed. 3 lets every level cast them. |
| Shadow from level | A simpler level of detail whose shadow is used for the nearer, detailed levels, from 0 to 3. A detailed tree near the camera is then drawn without its own shadow, and its simpler level is drawn only into the shadow in its place. The shadow looks almost the same and costs much less. 0 lets each level cast its own. |
What foliage costs
Every copy of a rock is drawn from the same model, but each copy is still real work for the computer, and the work is split between two of its parts, which work in very different ways. The Central Processing Unit (CPU) runs your program. It follows the program's steps one after another, very quickly, and makes the decisions, such as what the player pressed and what should happen next. Even a fast CPU has only a handful of cores, each doing one thing at a time. The Graphics Processing Unit (GPU) is a separate processor built for one job: working out pictures. It has thousands of small cores that all do the same simple calculation at the same time, each on a different triangle or point of the screen. A CPU is like a few expert chefs who can cook anything, one dish at a time. A GPU is like a thousand kitchen helpers who can each only chop, but all chop at once. So the CPU decides what to draw, and the GPU draws it.
- The GPU draws the triangles. A model is made of small flat triangles. A rock might have a few hundred. A thousand copies of that rock means a few hundred thousand triangles, and the GPU has to draw them all again on every frame. A detailed tree can have many thousands of triangles, so a forest adds up very fast. Shadows cost more: the GPU draws every copy that casts a shadow a second time, from the light's point of view.
- The CPU prepares and culls. Before the GPU can draw, the program has to decide what to draw. Each frame, it checks which copies are close enough and in front of the camera, and skips the rest. That skipping is called culling. The more copies there are, the more there is to check.
A game has very little time for all of this. At 60 frames a second, each frame has about 16 thousandths of a second for everything: the player's input, the physics, the terrain, the water and the foliage. If drawing takes longer than that, the game draws fewer frames each second, and movement starts to look jerky.
Quorum's terrain uses a few tricks to keep foliage fast:
- Cells. The ground is split into squares about 32 units wide, and each square holds one asset's copies. The program culls a whole cell at once, instead of checking every copy one at a time. Cells of foliage that casts no shadows, such as grass, are skipped when they're outside the camera's view, so grass behind the player costs nothing. Cells that cast shadows are kept, since a tree just out of view can still throw its shadow into it.
- Drawing copies together. All the copies in a cell are sent to the GPU in one go, which the GPU can draw much faster than the same copies sent one by one. The copies are worked out once and kept ready, so on each frame the CPU only copies them over, instead of working out every copy again.
- Draw distance. Cells farther away than the asset's draw distance aren't drawn at all, and copies thin out near that distance, so they fade out gradually instead of all vanishing at once.
- Levels of detail. Far away, an asset can switch to a simpler model or a flat card, with far fewer triangles. Up close, it looks the same.
- Cheaper shadows. Far levels can skip shadows, and a simple level can cast the shadow for a detailed one.
So two settings matter most for speed. Density, with the coverage you painted, decides how many copies there are in all. Draw distance decides how many of them are drawn on each frame. Halving the draw distance leaves only about a quarter of the area around the camera to draw, because the area of a circle grows with the square of its radius.
Measuring the frame rate
A game can count its own frames. Quorum calls a game's Update action once
every frame, and its seconds value says how long the last frame took.
This program loads your scene and counts the frames. Once a second, it
writes the count to Quorum Studio's output window, and also adds it as a
line to a log file, so you can study the whole run afterward as data.
Put it in your project's Main.quorum, and change the scene's path if yours
is different.
use Libraries.Game.Game
use Libraries.System.File
use Libraries.System.FileWriter
class Main is Game
integer frames = 0
number elapsed = 0
integer secondCount = 0
FileWriter log
action Main
UseVulkan(true)
StartGame()
end
action CreateGame
LoadScene("Scenes/Scene.qs")
// Each run starts a new log. Use a different name for each version,
// such as FramesA.csv and FramesB.csv.
File file
file:SetPath("FramesA.csv")
log:OpenForWrite(file)
log:WriteLine("second,frames")
end
action Update(number seconds)
frames = frames + 1
elapsed = elapsed + seconds
if elapsed >= 1
secondCount = secondCount + 1
output "Frames this second: " + frames
log:WriteLine("" + secondCount + "," + frames)
log:PushToDisk()
frames = 0
elapsed = elapsed - 1
end
end
action OnExit returns boolean
log:Close()
return true
end
end
The log is a small table in a format called CSV, for comma-separated
values. Its first line names the columns, second,frames, and each line
after it is one second of the run, such as 12,58: in the twelfth second,
the game drew 58 frames. You can open it in a spreadsheet, or read it in
any text editor or with a screen reader, one line at a time. PushToDisk
saves each line as soon as it's written, so nothing is lost if the game
stops suddenly. OnExit is called when the game's window closes, and it
closes the file. Taking away 1 from elapsed, instead of setting it to 0,
keeps the bit of time left over, so every line covers a full second.
Games usually limit how many frames they draw a second, often to about 60 or 70, so a fast computer may show the same number with or without foliage. The number matters when it drops below that limit.
Engage
The goal of this activity is to find out, with real numbers, how much
foliage a scene can hold before the game slows down, and to decide which
of two versions plays better. Work in pairs, with one computer. First,
agree on a test: the same scene, the same camera, and the frame-logging
program above. For each run, let the game run for 30 seconds without
touching anything, then close its window. Give each run its own log name:
FramesNone.csv, FramesA.csv and FramesB.csv.
Run it with no foliage. Then make Version A: paint rocks over a large area at full strength, set a high density and a long draw distance, such as 400, and run it. Then make Version B from the same painting: lower the density, shorten the draw distance, such as 100, and remove the rocks far from where the player starts, so they stay only where a player would notice them. Run it once more. If your computer is fast enough that nothing changes, keep making Version A denser until the frame rate drops. If you can, also run Version A on a second, different computer, and keep that log too.
Compare the versions using your logs. Write a short report that answers these questions:
- How many copies did each version have? The Foliage section's first line gives the total.
- From each log, what were the average, lowest and highest frames per second? How many seconds were below 60?
- Did the frame rate stay steady, or were there sudden drops? Which rows of the log show it?
- Move the brush to where the player starts, choose the Foliage tool, and read what's under the brush in each version ("Under the brush: 14 RockA"). Did Version B remove copies near the player, or far away? Why is far away the cheaper place to cut?
- If you ran Version A on a second computer, how did its log differ? What about that computer might explain it?
- Which version would you ship, and why? What would you change for a player with an older or slower computer?
Wrap up
Foliage turns bare ground into a place, but every copy is work for the CPU
and the GPU on every frame. Density, draw distance, shadows and simpler far
models are the levers that trade looks for speed. Professional games make
the same trade, and many let players choose between high
and low
settings. In the next tutorial, Lakes,
you will fill the hollows in your terrain with water.