Devlog

Rivers drawn from flow data, sized by how much water they carry

Published

In short: rivers are now drawn from river data, each as wide as its flow, running on to the sea. Nothing lands, grows or is built on them.

The ground’s colour comes from a satellite map with 500 m pixels. On it only the biggest rivers show, about a pixel wide, so the Chao Phraya through Bangkok, about 400 m across, was missing. Now rivers are drawn on their own, from river data. The test area is again the plain around Bangkok.

A blue-green river winding through a grey city of blocks and on across yellow-green farmland, seen from about 4 km.
The Chao Phraya through Bangkok, from about 4 km.

Where the rivers come from

The rivers come from HydroRIVERS, a line map of the world’s rivers[1] made by the HydroSHEDS project. For each stretch of river it also gives an estimate of the long-term average flow. Through central Bangkok, that is 828 m³ a second. HydroRIVERS is free to use, commercial use included, with credit; see credits.

How wide

A river’s width grows with its flow as a power law[2]. The game uses the common square-root form: width = A × √flow. A is set so the Chao Phraya through Bangkok comes out at about 400 m, which gives A ≈ 13.9. Every other river follows the same rule.

Rivers under 60 m wide are left out. At that size they would break up into dots, and most would hide under the forest anyway.

A winding river crossing a wide brown-green plain under scattered cloud, passing through a grey town, with a large loop of river at lower right.
The Chao Phraya plain from about 20 km, the Bang Krachao loop at lower right.

How it is drawn

Each area gets one baked texture, 200 by 200 km at about 49 m a pixel. It does not store the river’s colour: it stores the distance to the nearest river bank. That keeps banks smooth and sharp far below a pixel, at the cost of about one texture lookup for the ground.

Colour

The real Chao Phraya is muddy brown. In the game the rivers are a clean blue-green: in the developer’s words, “it’s after-earth era so nature is pristine”. The sea’s own blue was tried first, and was “too blue”.

The same view of the river through the city, with the river a strong bright blue.
First try: the sea’s blue. Rejected as “too blue”.

Reaching the sea

The river data’s coastline sits 8 to 20 km inland of the game map’s coast round Bangkok, so at first the rivers stopped short of the sea. Now each river mouth is carried on to the map’s sea, and over its last 2.5 km the river turns to the sea’s blue, so the two meet without a seam.

A river winding down a wide plain to the blue Gulf of Thailand, its last stretch running straight to the shore.
The river reaching the Gulf of Thailand.

Real water

Rivers are water for the game, not just paint. No trees grow on them, nothing lands on them and no buildings stand on them, so a river through town leaves a clear band. Roads cross as bridges, with a light rim along each edge.

A bug along the way

The game decides what is water by colour: clear blue is water. The new blue-green was too green for that test, so for a few minutes Bangkok’s buildings stood in the river. The fix: the water test now reads rivers as sea-blue, whatever colour they are drawn in. A new test checks the buildings the game actually puts up, so this can’t come back unnoticed.

Related

Sources

  1. HydroRIVERS, HydroSHEDS. HydroRIVERS represents a vectorized line network of all global rivers
  2. The hydraulic geometry of stream channels and some physiographic implications (Leopold and Maddock, 1953), U.S. Geological Survey, Professional Paper 252. vary with discharge as simple power functions at a given river cross section