# [JOML] How to get multiple octaves of SimplexNoise?

The JOML SimplexNoise class gives a noise function for generating noise values. How do I compute this value and add multiple octaves of it to generate a variety of terrain?

Exactly how you compute multiple octaves with any other base noise function:
You scale the input coordinates for the noise function and scale the output value, and do this for any number of octaves you want and accumulate the output values over all octaves.

Is there a particular pattern you are going for?

With the more complex patterns, you have to make multiple calls to the simplex function for each pixel and combine them. Usually this is done with addition, where each octave is given its own weight. It is not necessary to do so, but usually folks scale the multiple calls via some sort of fractal relationship. For example, a nice cloud pattern can be had that way.

Pseudo code:

``````
noiseValue = simplex(x, y) / 2;
noiseValue += simplex(x * 2, y * 2) / 4;
noiseValue += simplex(x * 4, y * 4) / 8;
noiseValue += simplex(x * 8, y * 8) / 16;
etc.

``````

The results will range in between -1 and 1. You can then scale that to color values in various ways. Applying an ABS function to the result before scaling is an option that Ken Perlin called “turbulent” as opposed to “smooth”.

Most importantly, for terrain, instead of scaling the noiseValue to a gradient of a color (as in Red in the range 0…255 or 0…1 depending on what command you are using), one uses a color mapping. I first read about this in a blog post by a jgo member @ShannonSmith
http://www.angryoctopus.co.nz/?p=11

We have a pretty good article here: http://www.java-gaming.org/topics/noise-bandpassed-white/27071/view.html

I made a ‘visualizer’ to help with playing around with different ratios and scalings using a GUI. It uses Gustafson’s implementation of 2D simplex, but if you were to swap in another simplex function, the results should be similar. There is a link to a jar and the github site on this thread:

The html implementation link to the visualizer is obsolete.

As part of the visualizer tool, there is a ‘gallery’ of graphics that can be loaded and fiddled with. The input scalings are apparent (each channel column has fields where values are plugged in), but the “mixer” could be clearer in terms of letting you figure out what numbers to use to scale each output to get the visualized effect.

If I remember correctly, what is going on is this: the values shown on each octave slider are numerators and the sum of all the channels is the denominator. So, if one channel reads 24 and another reads 48, the ratio will be 24/72 and 48/72. There is also a total volume slider (bottom most) which scales everything equally. The display uses values that range 0…255, so if the highest value is 72, output to the graphic is on the low side. If the bottom slider is pushed to the right, it scales everything up by the same factor and can overflow beyond 255 (or be clamped at 255).