/mapgen

Heightmap-Generator written in C++

Primary LanguageC++GNU General Public License v3.0GPL-3.0

Heightmap-Generator

Generates random-heightmaps for dynammo (https://github.com/domso/dynammo). Its a reimplementation of an old FreeBASIC-program I wrote years ago.

The fundamental idea behind this generator is to place multiple hills/valleys randomly on the map. A hill is a cone with random diameter and height, while a valley is just an inverted hill.

Heightmap with 1 hill:

Heightmap after 1000 iterations applied on a random initialized map:

This is the raw-heightmap.

The next step is to use gaussian-blur to reduce the overall noise and smooth the map.

Heightmap after applying gaussian-blur:

To make the map more realistic, the generator simulates erosion. This is done by finding the smallest neighbor of every point and reduce the height of both points. Combined with a random error the resulting heightmap looks like this:

Heightmap after applying erosion:

The last step is to use gaussian-blur again.

Final heightmap:

Water Simulation

Using the heightmap, a watermap can be created.

Find the primary rivers by using erosion again:

After removing some smaller rivers:

Increase the width of each river:

Set the correct height:

Apply gaussian blur to the surrounding pixels:

Add a baselevel of water:

And the final result:

Note: The heightmaps were rendered using blender.