Hush Trail

· 4 min read

Building the world: terrain, grass and trees

Generated valleys, a grass carpet instead of blades, and the rules that keep it smooth.

Golden Valley at sunset: a log cabin on the lake shore, a truck parked in front, trees and hills behind.
Golden Valley. The lake, the cabin and the trails are placed by the generator.

A driving game with nothing to do lives or dies by its ground. If the hills are dull, there is no reason to drive up them. So the second day, 29 October, went almost entirely into the world.

A valley made from numbers

Every map in Hush Trail is generated: a height field, plus masks that say where forest, meadow, golden grass and wet ground go, then a lake, a stream, trails and the places to find. The first version that day had plains, hills and a ring of mountains around the edge, four trails and a lake. Mud kept tyre tracks by actually pushing the ground down. Generating the world took about 0.9 seconds on my Mac, and the scene was ready in about 1.8.

The terrain is cut into 128 m chunks with levels of detail, and only the chunks near the truck get collision. Later that day each map grew to 2.56 km across, with two ponds, seven trails and twelve or thirteen places to find. In version 1.2 Golden Valley grew again, to 3.84 km, with four ponds, ten trails and 23 places.

Golden hour at the lake pier with long tree shadows across the grass.
Golden hour at the lake pier. The lake, the pier and the long shadows all come out of the generator.

Grass is a carpet

The look I wanted was soft pastel ground, foliage made of textured cards, and thick clumps of grass. Never solid ball-shaped trees, and never single blades standing alone. The first grass did not get there. My note was short: the grass is still wrong. So the grass field was rebuilt from scratch as one continuous, combed carpet of blades whose colour at the root matches the ground under it. Meadow and earth now read as one surface.

The trees went the same way. The early procedural blob trees were replaced by foliage made of cards with soft alpha edges: grass clumps, shrubs, leafy trees and pines. The nature models come from Quaternius’s Stylized Nature MegaKit, which is free to use (CC0), and every one is re-shaded by our own shaders so it sits in the same light as the ground.

Tall golden grass and leafy trees made of soft cards, a truck parked in the shade.
Card foliage and the grass carpet. Each crown shades as one soft shape; the grass takes its colour from the ground.

Why the colours looked washed out

For a while every map looked pale, and nudging the colours did not help. The cause was one wrong assumption: the vertex colours on the ground were treated as linear values, so every ground colour came out lighter than designed. A per-map blend towards true sRGB fixed it, and Golden Valley got its gold.

Keeping it smooth

After the first drive on a real device the verdict was clear: it stuttered at speed. A few rules came out of that, and they still hold:

  • Work per frame is time-boxed. A terrain chunk gets about 4 ms; grass tiles are built one row at a time in about 2.5 ms.
  • Ground colour is baked ahead of time, for each map.
  • The camera follows the physics-interpolated position of the truck, not the raw one.
  • Small plants stream in around the truck instead of existing for the whole map.
  • Mud and snow ruts move vertices in place instead of rebuilding a 128 m chunk.

On the Mac that took the worst frames from 37 to 70 ms down to none above 18 ms. Baking where every plant and rock goes, once per map, took the world’s start-up on the Mac from 3.9 to 2.3 seconds, and on an Android emulator from 14.4 to 5.3.

The grass field around a truck seen from high above, coloured by a debug view: it covers only the area near the truck and thins out at its edge.
A debug view from above: the grass exists only around the truck and is streamed in tiles as it drives. Past the edge, the ground colour carries the look.

Weather and the hours

The world has a full day and six kinds of weather: clear, cloudy, overcast, rain, fog and snow. Rain darkens the dirt and fills the ruts. Snow settles, counts as its own surface for grip, spray and tracks, and the truck slides a little. You choose how long a day lasts, from twelve minutes to real time.

Rain on the valley: wet dark ground, a grey sky and a truck with its lights on.Snowy hills and frosted forest stretching across Frost Pass.
Rain on the valley, and snow across Frost Pass.

Two lessons that cost a night each

Godot treats a face as the front when its corners run clockwise seen from above. Wind the terrain the other way and it gets no shadows and the light looks wrong.

The second came later. When the generator changes, the baked world files have to change with it. On 13 November an old Cappadocia file from the previous day’s generator met freshly baked plant data, and half of the objects floated or sank by up to ten metres. Since then the bake tool compares every saved world with a fresh generation and rebuilds it when the heights differ by more than a quarter of a metre.