I want to create a terrain-like 3D noise generator and after doing some research I came to the conclusion that Simplex Noise is by far the best type of noise to do this.
I find the name quite misleading though as I have a lot of trouble finding resources on the subject and the resources I find are often not well written.
What I am basically looking for is a good resource/tutorial explaining step by step how simplex noise works, and explains how to implement that into a program.
I am not looking for resources explaining how to use a library or something.
In lue of a tutorial recommendation I will attempt to explain how to use an existing java source that creates a single octave of simplex noise.
Simplex noise code
This part of the code was created by Stefan Gustavson and was placed in the public domain. It can be found here. It is quoted here for convinience
Frankly I consider this whole class to be a black box with a public constructor
public SimplexNoise_octave(int seed)
, and 3 public methodspublic double noise(double xin, double yin)
,public double noise(double xin, double yin, double zin)
andpublic double noise(double x, double y, double z, double w)
.You can use these methods exactly as you would the perlin noise equivalents.
Create 1 SimplexNoise_octave for each octave you want, each should have its own seed
Call to get the particular noise value for that octave at those co-ordinates. Note; the co-ordinates should be pre-scaled (more later). The other
noise
functions are the same but for higher dimentions.Creating Octaves
Just like in perlin noise you will in general combine several octaves of noise to create fractal noise (which gives you terrain like features). Note that 3D terrain heights are created by 2D noise.
Several octaves are combined using the following ratios
For each octave (i) you divide the input co-ordinates by frequency and multiply the result by amplitude; this gives a terrain like appearance. Persistence is used to affect the appearance of the terrain, high persistance (towards 1) gives rocky mountainous terrain. low persistance (towards 0) gives slowly varying flat terrain. See the tag page for more details.
An example of how this could be used is shown below:
This creates octaves that give features of size between 1 and
largestFeature
, I found this to be useful but theres nothing special about 1 being the smallest size and you could modify this. It outputs between -1 and 1, scale as needed.Usage
An example main method that would use this class is as follows
This method makes use of my own ImageWriter class just to render the output to a file
http://webstaff.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf this is a pretty good explanation