Implement perlin noise with turbulance

This commit is contained in:
CJSatnarine
2024-07-09 21:17:13 -04:00
parent 176c33bcd7
commit 498b86180a
5 changed files with 358547 additions and 358533 deletions

Binary file not shown.

717064
image.ppm

File diff suppressed because it is too large Load Diff

View File

@@ -47,6 +47,20 @@ class perlin {
return perlinInterpolation(c, u, v, w);
}
double turbulance(const point3& p, int depth) const {
auto accum = 0.0;
auto temporaryP = p;
auto weight = 1.0;
for (int i = 0; i < depth; i++) {
accum += weight * noise(temporaryP);
weight *= 0.5;
temporaryP *= 2;
}
return fabs(accum);
}
private:
static const int pointCount = 256;
vec3* randVector;

View File

@@ -80,7 +80,7 @@ class noiseTexture : public texture {
noiseTexture(double scale) : scale(scale) {}
colour value(double u, double v, const point3& p) const override {
return colour(1, 1, 1) * 0.5 * (1.0 + noise.noise(scale * p));
return colour(1, 1, 1) * noise.turbulance(p, 7);
}
private: