Created
May 21, 2012 09:22
-
-
Save BlockoS/2761454 to your computer and use it in GitHub Desktop.
Fbm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fractional Brownian motion | |
float fBm(const glm::vec3 pos, const int octaveCount, float lacunarity, float gain ) | |
{ | |
float noiseSum = 0.0; | |
float amplitude = 1.0; | |
float amplitudeSum = 0.0; | |
glm::vec3 sample = pos; | |
for( int i = 0; i < octaveCount; ++i ) | |
{ | |
noiseSum += amplitude * glm::simplex( sample ); | |
amplitudeSum += amplitude; | |
amplitude *= gain; | |
sample *= lacunarity; | |
} | |
return (noiseSum / amplitudeSum); | |
} | |
void somewhere() | |
{ | |
float z = 0.4; | |
for(int j=0; j<HEIGHT; ++j) | |
{ | |
for(int i=0; i<WIDTH; ++i) | |
{ | |
glm::vec3 sample(i/float(WIDTH), j/float(HEIGHT), z); | |
float altitude = 0.5 + 0.5*fBm( coord, 8, 2.18387276, 0.521869 ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment