A way to get realistic terrain types on a generated map is to use the Whittaker diagram. This diagram defines the terrain type from two parameters : temperature and precipitation. You can easily compute temperature from the latitude, distance from sea and altitude, but the precipitation is not as intuitive.

One way to get it is to simulate winds. Imagine a point on the map following the wind. When it is over the sea, it accumulates water in a waterCount variable. When it travels above land, it drops a part of its accumulated water at each step. To simulate orographic rains, the percentage of waterCount that is dropped on ground is proportional to the land slope in the wind direction.

This method has two benefits over the previous one :

  • precipitations are nicely spread from sea to land and don’t stop a few kilometers after the coast
  • mountains acts as barrier for precipitations

Here is a precipitation map obtained with this method :

Now I didn’t try to do some realistic wind simulation. I simply apply 4 steps, one for each cardinal direction. This is the altitude map used for this test :

On first step, for each map x coordinate, I simulate a wind that goes from north to south. I get this precipitation map :

North winds only

See how the precipitations are increased on the north flank of the mountain on the east continent ?

Now I can do the same thing with south->north winds and cumulate both precipitation maps, and again with east->west and west->east winds :

North + south winds
All winds

Note that lands near the map border are dry because no water can be accumulated before reaching them. You could fix this by initializing the waterCount with some random value.

The next step consists in adding the effect of latitude on precipitations. I want a desert area and a tropical area. I’m using a sinus function to alter the precipitation map near the equator. To keep it from creating geometric artifacts, I add a 2D noise to it.

Latitude impact
latitude impact

The precipitation map is used for biome generation, and we want the noise to be removed from the different biomes (the player doesn’t want to swap from savanna to desert every kilometer, but rather have a big desert followed by a big savanna. This is why I blur the precipitation map as a final step, using a 5×5 kernel with all weights == 1 (you can do this easily with libtcod’s heightmap toolkit). The final precipitation map and associated biome map :

after blur
biome map


Switch to our mobile site