#ifndef CG1_TRACER_PERLINNOISE_H #define CG1_TRACER_PERLINNOISE_H #include "noise.h" // Stolen from https://en.wikipedia.org/wiki/Perlin_noise class PerlinNoise : public Noise { public: /** * * @param size * @param gridSize * @param seed 0 for random seed */ PerlinNoise(int size, int gridSize, unsigned int seed = 0); void renderNoiseThread(int xOffset, int xSize); private: void generateNoise(); std::normal_distribution distribution; std::mt19937 generator; int gridSize; std::vector gradients; Vector3d randomGradient(); float getGradientValue(int x, int y, int z); float getCornerValue(Vector3d position, Vector3d corner); static void runPerlinNoiseInThread(int xOffset, int xSize, PerlinNoise *noise); }; #endif //CG1_TRACER_PERLINNOISE_H