# Heightmap using Simplex noise with octaves: help with parameters and interpretation

I've found a few pieces of code around, where Java code for Simplex noise (based on this widely quoted paper) was coupled with octaves to get a heightmap. However those classes/snippets are NOT in the -1,1 range despite saying so, so I had to add some modifications.

By trial and error and some brain work I got to a version that produces an output within -1 and 1, here (could you sanity check it please? It this correct?):

public static float[][] generateOctavedSimplexNoise(final int width,
final int height,
final int octaves,
final float roughness,
final float scale)
{
final float[][] totalNoise = new float[width][height];
float layerFrequency = scale;
float layerWeight = 1f;
float weightSum = 0f;

for (int octave = 0; octave < octaves; octave++)
{
// Calculate single layer/octave of simplex noise, then add it to total noise
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
totalNoise[x][y] += (float) noise(x * layerFrequency, y * layerFrequency) * layerWeight;
}
}

// Increase variables with each incrementing octave
layerFrequency *= 2f;
weightSum += layerWeight;
layerWeight *= roughness;
}

// scale output between -1 and 1, as we are doing
// a weighted average
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
totalNoise[x][y] /= weightSum;
}
}

}


My understanding is that "roughness" must vary between 0 and 1, and influences the "flatness" of the final image. What "scale" is I cannot fathom yet - any help?. Also, more than 6-7 octaves seems useless in my tests, hopefully this is expected.

But most of all my question is: how do I work in a top-down way? That is, knowing the kind of map I roughly want (a big island in the ocean, with a few lakes and a few mountains, but mostly plain and hills) how do I choose parameters and the thresholds for terrain types?

I've tried a lot, but I can't seem to control the function to produce a nice map..

• As a side note, it occurred to me that some people may intentionally have an output outside the -1,1 range, and then clamp it. This would be a sort of "zoom" within the noise map.. but I'm not sure if it makes sense nor if it's needed (shouldn't that be achievable with "scale"?). Oct 11 '15 at 14:38