28 April 2021

World Map Generation 1


It’s fairly commonly knowledge that generating a map can be done in a lot of different ways. This post is the first on a set that will speak of the ideas and algorithms we used to create the map for our toy program to display.

The main  goal was to be able to quickly test new idea for map generation, and be able to create new generators for different kind of terrain, such as town (mainly flat, with buildings and road), or hills, or canyons... This part will concentrate on the terrain itself and not the content (building, trees...). 

The Map

We're working on a small map (32x32 to 128x128 hex). The map will be used in a game similar to BattleTech or Full Metal Planet, meaning only a few level high (5 level for FMP for example). I may eventually change this ( a settler game ? or a Capitalism look-alike ?), but this is my current goal.

The generation process I'll present in this set of blogs are working either on a standard heightmap, or on an hexagonal space (mainly in case we need the neighbours of a cell : we can take the 6 neighbours in hex space and map it to square space).

The general method

We first create a heightmap using a combination of methods and operators.Then we create an HexMap based on this heightmap, using it to get the height of each cell. Last, we use several filters to generate / calculate some others data, such as the discrete elevation.

We will present each time the general process and then an hexmap based on it. 

So, on to the first method...

Landslide generation

This generation process is based on the idea of having a landslide, pushing one part of the map up and the rest being lowered.

 Linear Landslide

 Here the map is separated in two along a line going from one border to the other. One side of the line is lowered, while the other one is heightened. Performing this several time should lead to an interesting map.

The idea comes from this site

The first version perform for each pass a landslide along either an horizontal line or a vertical one (one then the others). This give terrain that are good, but there are artefacts : the fault lines are visible. Having a great number of passes tend to limit the artefacts, but the last lines are still visible. Discretizing to a low range of values reduce the artefacts, and performing a smoothing operation also help.

The following pictures show the result for several passes, from 1 pass to 4 passes. Maps are 64*64 cells. In all cases the seed for the random generator is the same.

The following pictures show the result for 64, 640, 1024 and 4096 passes for the same seed:
If we discretize the last map to a scale of 0-4 to get a terrain that is more usable in a Full Metal Planet setting for example, we got the following result : 

 

Circular Landslide

The same thing can be done with a circle instead of a line : inside a random circle (random in position and radius), add or remove a small amount. 

Results from execution with the same number of pass as the previous one (1,2, 3 and 4 for the first line and 64, 640, 1024 and 4096 for the second one)  are below : while 64 circles still shows some artefacts, this is less vsible at 640, and nearly invisible at 1024 and higher...


The discretization to a 5 level map gives the following :


 

No comments:

Post a Comment