Perlin Noise and Octaves

Started by
1 comment, last by ApochPiQ 18 years, 10 months ago
The perlin noise function I have returns values between -1.0 and 1.0. Should I convert this to 0.0 to 1.0 ((noise/2.0f)+0.5f?) before adding the octaves together? If so, how do I make sure the final result is not > 1.0f without it becoming too dark? At the moment, my octave function looks like...

//
// return noise with octaves
//
float PerlinNoise::NoiseWithOctaves(int in_x, int in_y, float in_startScale, int in_octaveCount)
{
	float result=0.0f;
	float pers=1.0f;
	float falloff=0.5f;
	float rawNoise;

	// loop through octaves
	for (int i=0; i < in_octaveCount; i++)
	{
		rawNoise=Noise(in_x, in_y, in_startScale)*pers;
		result += rawNoise;
		in_startScale *= 2;
		pers *= falloff;
	}

	return result;
}

Advertisement
It's been a while since I've worked with perlin noise so shoot me if I'm wrong, but... I think you don't have to worry about the functions adding together to be more than 1.0, because you weight each octave by something...

e.g:

.5 * octave1 + .25 * octave2 + .125 * octave3 ... etc.

So, as long as each octave is < 1.0, the sum won't be either.

EDIT: I dug up some of my old code, hope this helps!

// Fractional brownian motion functiondouble FBM(int nOctaves, int roughness, const Vec3 &point){	// Just calculate the summation of the octaves	// (Optimized)	Vec3f floatPoint = point;	double summation = 0.0;	double maxValue = 0.0f;	for(int i = 1; i <= nOctaves; i++)	{		summation += powf(2, (-i * roughness)) * (Noise3(powf(2, i) * floatPoint));		maxValue += powf(2, (-i * roughness));	}	summation /= maxValue;  //normalize to -1...1	return summation;}
It depends on what you're using the noise data for. When generating procedural textures, it usually makes sense to have the noise function return values on the interval [0, 1], and if subtractive combinations are needed, special-case for them in the octave summation code. For bump maps or other height-based data, it can make sense for values to lie on [-1, 1]. Personally I use two "root" Perlin noise functions, one of which returns values on [0, 1] and the other on [-1, 1]. The one which is most meaningful for a specific instance is the one I choose.

This becomes important if your octaves are not based on simple turbulence (scale input point, sample, weight sample, add to octave list). Most applications of Perlin noise will eventually involve such a case, such as exponentiating each octave to produce cloud-like patterns. In such cases, ranging on [-1, 1] is not only counterintuitive, it is sometimes flat out broken.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

This topic is closed to new replies.

Advertisement