X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fnoise.hpp;h=26e37668b00f609fdfd2747a2ed6a3e044031729;hb=4485397da18a25dfd1a51e864814887b66ba0f2e;hp=166a60a71058b998d60df732f752259b993beea4;hpb=c877ddd21f402381d88a6bebdd5c7c0b4ac28ba9;p=blank.git diff --git a/src/noise.hpp b/src/noise.hpp index 166a60a..26e3766 100644 --- a/src/noise.hpp +++ b/src/noise.hpp @@ -35,6 +35,7 @@ private: }; + /// (3D only) adaptation of Stefan Gustavson's SimplexNoise java class class SimplexNoise { @@ -68,6 +69,29 @@ private: }; + +template +float OctaveNoise( + const Noise &noise, + const glm::vec3 &in, + int num, + float persistence, + float frequency = 1.0f, + float amplitude = 1.0f, + float growth = 2.0f +) { + float total = 0.0f; + float max = 0.0f; + for (int i = 0; i < num; ++i) { + total += noise(in * frequency) * amplitude; + max += amplitude; + amplitude *= persistence; + frequency *= growth; + } + + return total / max; +} + } #endif