# perlin noise tutorial *bug? or intention?*

This topic is 4914 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi I just read through this perlin noise tutorial to create realistic clouds http://www.gamedev.net/reference/articles/article2085.asp in the overlapoctaves function towards the end of the article the author uses this line
map256[(y*256) + x] += noise / pow(2, octave);


for octave=0 to <4 it would add noise1*1+noise2*0.5+noise3*0.25+noise4*0.128 the sum of the factors is 1.875 if you have a pretty bright noise function you would have locations with clusters of pixels that are outside ]-1.0f,1.0f[ so when you convert it to a 8bit grayscale heightmap you would have clusters of pixels with 0s or 255s and i don t think you would like to get such values when using perlin noise i think the weightfactors of the layers should be 1/2 1/4 . . . 1/pow(2,n) for n to unlimited the sum of these factors moves towards 1.0f but never reaches it what do you think?

##### Share on other sites
As far as I noticed, the author in fact should have been clamping the final noise values before using them as texture color values.

It is highly uncommon to reach any value even near the border 1.875f. And taking defensive position (read: scaling by 1/2) would likely not give us such good results, it would rather make the function very rarely return any value above 0.8f, or below 0.2f (well, just a shot here).

##### Share on other sites
the noise function returns values between -1 and 1 so shouldn t we check for the largest and smallest number the function returns

and use this to clamp the entire noise map to the ]-1,1[ range and in the overlapoctraves use

1/pow(2,n) with n>= 1?
this would indeed create a perlin noise that is within ]-1,1[ range with enough sharpness to create proper clouds or whatever you want to use it for

##### Share on other sites
so I just ran a test with my implementation

if you use 1/pow(2,octaves) you get a pretty streched noisemap as result

i implemented it with 1/pow(2,octaves+1) which gives proper results but the sharpness is a little bit too less so i suggest you clamp the values of the 32*32 map to te -1 +1 range

##### Share on other sites
The weightfactors of the layers should be:
1
1/2
1/4
...

take a look here:
http://freespace.virgin.net/hugo.elias/models/m_clouds.htm
and here (especially part about persistance):
http://freespace.virgin.net/hugo.elias/models/m_perlin.htm

Quote:
 Original post by Basiror... so when you convert it to a 8bit grayscale heightmap you would have clusters of pixels with 0s or 255s ...

exponential function will take care of it :)

Chris

##### Share on other sites
yes if you want to remove those clusters, but you probably might want to create a a landscape where those clusters would look pretty ugly

i have implemented the noise generator exactly as he descrips on his paper, but it delivers messy results i will implement it now the way it is descriped in the link your posted it

##### Share on other sites
On secound thought those weightfactors are just amplitudes of noise functions so it doesn't matter if it starts with 1 or 0.5. You should just tweak starting value based on what is your exponential function implementation and target texture format. Kim Pallister in his article is using 0.5 factor for lowest frequency: Kim Pallister article
There is also DX demo there.
Also take a look here:
Sky-rendering techniques

Chris

[Edited by - kzyczynski on August 6, 2005 4:15:06 AM]

##### Share on other sites
thx for the lnks but on the 5th page of kim pallisters page he uses the same blendweigth as i suggested

Color = 1/2 Octave0 + 1/4 Octave1 + 1/8 Octave2 + 1/16 Octave3

going on the octave n the sum of the blendweights will always be < 1.0f

##### Share on other sites
If you apply exponentiation like in the almighty cloud thread, you won't have to worry about getting values < 1.0 (your octave-setup will give ~.94 anyway). If you truly, deeply want to get up to 1.0, you could divide each octave-coefficient by the maximum value = 1/2 + 1/4 + ... + 1/n but that seems rather pointless. Note that 2^-n is not a strict rule either, 1/[2,4,7,14,28] for instance will add up to 1.

##### Share on other sites
for 1/pow(2,n) ^^ it will always be < 1.0f and no i don t always use the exponential filter only for realistic looking clouds

i have implemented a little function that will clamp the noise map to the -1.0f +1.0f boundary

the library is just a collection of noise routines
i just write some libraries to produce a good foundation for my engine project, i hate to interupt my work to write a semi complete library and the next time i want to enhance one part of the engine i need to spend time to enhance the old libraries that breaks my workflow

but i think you know these situation

its part of a big library which am going to release somewhen later this year

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 13
• 9
• 9
• 15
• ### Forum Statistics

• Total Topics
634075
• Total Posts
3015349
×