Simplex Noise – Generating Random Terrain.

Simplex noise - example terrain output - colourized

Sharing is caring!

I had an idea for a game and wanted to see if I was able to make some random terrain for it. So I decided to look into making some random terrain using the Perlin noise as I knew minecraft uses this in it’s terrain generation. while looking into the Perlin noise I discovered a ready made Java class that uses the simplex noise and decide it would less time consuming to use a ready made class then create my own Perlin noise. This was even more beneficial than I had planned as the simplex noise take less computational power than the Perlin noise and can be scaled better.

 

Here is the code for the simplex noise:

My plan was to make a 200 by 200 tiled map which contained water, hills, mountains, trees and rivers. The first thing I wanted to work on was the height map. This is used to create the mountains and lakes be using the simple noise to create a value for each tile.

 

Using a single layer of simplex noise would result in a very rough map like Television static. To overcome this issue a single layer of noise is replaced with multiple layers of noise with different weights to create a fractal noise, each layer is called an octave. The code below shows how the weights for each octave of noise is combined to make a fractal noise.

 

Using the combined octaves for the height map. I wanted to add in trees to generate random forests so I changed from using 2d noise to 3d and used layer 0 for the height map and layer 50 for the tree generation. I tried using different values to decide which are was forest or not and eventually ended up using values < 0.15 would equal forest.

 

An example of what was created with this method.

Simplex Noise - Random Terrain
Simplex Noise – Random Terrain

 

This could be used to generate biomes by using a different layer from the 3d noise and setting values for each type of biome.

 

There are more noise generating algorithms to check out like Diamond Square and Perlin.

 

A good resource for terrain gen and noise is redblobgames.com

Sharing is caring!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.