X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Frand%2FSimplexNoise.hpp;fp=src%2Frand%2FSimplexNoise.hpp;h=7a7242b05b59af021fbd741dc9a84202f96feea9;hb=b7d09e1e35ef90282c97509e0020b20db3c7ea9f;hp=0000000000000000000000000000000000000000;hpb=e53a0e2e711a7d8bd9b0ddacd1360aa14370643f;p=blank.git diff --git a/src/rand/SimplexNoise.hpp b/src/rand/SimplexNoise.hpp new file mode 100644 index 0000000..7a7242b --- /dev/null +++ b/src/rand/SimplexNoise.hpp @@ -0,0 +1,31 @@ +#ifndef BLANK_RAND_SIMPLEXNOISE_HPP_ +#define BLANK_RAND_SIMPLEXNOISE_HPP_ + +#include + + +namespace blank { + +/// (3D only) adaptation of Stefan Gustavson's SimplexNoise java class +class SimplexNoise { + +public: + explicit SimplexNoise(unsigned int seed) noexcept; + + float operator ()(const glm::vec3 &) const noexcept; + +private: + int Perm(int idx) const noexcept; + int Perm12(int idx) const noexcept; + const glm::vec3 &Grad(int idx) const noexcept; + +private: + int perm[512]; + int perm12[512]; + glm::vec3 grad[12]; + +}; + +} + +#endif