]> git.localhorst.tv Git - blank.git/blob - src/rand/OctaveNoise.hpp
try to get every chunk change saved to disk
[blank.git] / src / rand / OctaveNoise.hpp
1 #ifndef BLANK_RAND_OCTAVENOISE_HPP_
2 #define BLANK_RAND_OCTAVENOISE_HPP_
3
4 #include <glm/glm.hpp>
5
6
7 namespace blank {
8
9 template<class Noise>
10 float OctaveNoise(
11         const Noise &noise,
12         const glm::vec3 &in,
13         int num,
14         float persistence,
15         float frequency = 1.0f,
16         float amplitude = 1.0f,
17         float growth = 2.0f
18 ) {
19         float total = 0.0f;
20         float max = 0.0f;
21         for (int i = 0; i < num; ++i) {
22                 total += noise(in * frequency) * amplitude;
23                 max += amplitude;
24                 amplitude *= persistence;
25                 frequency *= growth;
26         }
27
28         return total / max;
29 }
30
31 }
32
33 #endif