Country Terrains - Greece

This post looks over some details about generating terrain, with specific focus on how to make distinguished biomes of plains and mountains respectively. With it comes this Openprocessing script, which shows off the results and the code:


If you want it in fullscreen follow this link: http://openprocessing.org/sketch/582909

An oft-used method for generating terrain is to use Perlin noise to decide the altitude. Using just one Perlin map leads to a couple of issues regarding mountains.

  • When looking at an island, altitude is zero around the coast and more or less increases as you go towards its centre. Of course, terrain is not uniform, but landmasses are in general conical.
  • Mountains, paradoxically, tend not to be conical, but rather quite flat and often elongated. This reflects the "growth zones" of mountains in real life, but not the characteristic hill-and-valley result of wind and water deterioration.
  • Almost all terrain has a similar "frequency", with few areas that are particularly flat or particularly hilly.

If we look at the landmass in the bottom, it is generally quite gentle and flat - parts of it, especially those far from the coast have a high altitude, so it mostly shows off the naïve usage of Perlin, as described. But that is only the landmass at the bottom. At the top, rather, we see something quite unconventional: tall mountains surfacing directly out of the water, channels, rivers, and in the very corner, as far from the sea as can be - a flat, gentle valley.

The method portrayed here operates with four Perlin maps, that I will show off one by one on the same map. This map can be accessed with noiseSeed(9) in the above.

First, the naïve, simple Perlin map seperating sea from land, with conical islands and flat mountains. We will use a large-scale noise with low frequency.


We see tall areas sure, but they are far from the coast and are generally quite flat. This noise is quite low frequency, so of course, what we need to do is add some much higher frequency noise on top, a sort of hill-and-valley noise.


This is not just regular high-frequency noise. The noise has been "folded" or "mirrored" by taking the absolute value of noise in a -1 to +1 realm. This gives the characteristic hill/valley /\/\/\ mountainous feeling. 

But there is one problem - all parts of the map are equally hilly. This is where a third noise layer will be added - no, not added. It will be multiplied with the above map, to control which parts of the world will be in a "mountain biome"

Here, we can finally see the full effect - some parts are mountainous, independent of distance to the sea, and others remain nice and flat like in the first picture. This means that the final function for getting the height-map is:

height = largescale_noise+mountainbiome_noise*abs(hillvalley_noise*2-1)

in glorious pseudocode.

There is one last layer of noise, though it is a bit more subtle. This one, however, can and should be used with all types of terrain generation if you have the spare processing power: Offsetting the x and y coordinates via Perlin noise. Now, look closely at the differences between these two pictures:


Perhaps the effect is a bit exaggerated here, but basically, it takes Perlin noise that, no matter the amount of detail, is mostly uniform, and distorts it into something a bit more realistic. It gives the noise a much more fluid-like feeling, and, as illustrated, can be added to all the other layers of the function without much worry. It works equally well with the flat plains and the mountains, that now seem more rugged and less round.

Comments