2023-01-24 05:22:40 +01:00
|
|
|
#ifndef CG1_TRACER_PERLINNOISE_H
|
|
|
|
#define CG1_TRACER_PERLINNOISE_H
|
|
|
|
|
|
|
|
|
|
|
|
#include "noise.h"
|
|
|
|
|
2023-01-24 06:26:24 +01:00
|
|
|
// Stolen from https://en.wikipedia.org/wiki/Perlin_noise
|
2023-01-24 05:22:40 +01:00
|
|
|
class PerlinNoise : public Noise
|
|
|
|
{
|
|
|
|
public:
|
2023-01-24 06:26:24 +01:00
|
|
|
PerlinNoise(int size, int gridSize);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void generateNoise();
|
|
|
|
std::normal_distribution<float> distribution;
|
|
|
|
std::mt19937 generator;
|
|
|
|
|
|
|
|
int gridSize;
|
|
|
|
std::vector<Vector3d> gradients;
|
|
|
|
|
|
|
|
Vector3d randomGradient();
|
|
|
|
|
|
|
|
float getGradientValue(int x, int y, int z);
|
|
|
|
|
|
|
|
float getCornerValue(Vector3d position, Vector3d corner);
|
2023-01-24 05:22:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //CG1_TRACER_PERLINNOISE_H
|