Implement perlin frequency
This commit is contained in:
Binary file not shown.
BIN
build/Raytracer
BIN
build/Raytracer
Binary file not shown.
2
main.cpp
2
main.cpp
@@ -146,7 +146,7 @@ void funny() {
|
|||||||
void perlinSpheres() {
|
void perlinSpheres() {
|
||||||
hittableList world;
|
hittableList world;
|
||||||
|
|
||||||
auto perlinTexture = make_shared<noiseTexture>();
|
auto perlinTexture = make_shared<noiseTexture>(4);
|
||||||
world.add(make_shared<sphere>(point3(0,-1000,0), 1000, make_shared<lambertian>(perlinTexture)));
|
world.add(make_shared<sphere>(point3(0,-1000,0), 1000, make_shared<lambertian>(perlinTexture)));
|
||||||
world.add(make_shared<sphere>(point3(0,2,0), 2, make_shared<lambertian>(perlinTexture)));
|
world.add(make_shared<sphere>(point3(0,2,0), 2, make_shared<lambertian>(perlinTexture)));
|
||||||
|
|
||||||
|
@@ -77,12 +77,15 @@ class noiseTexture : public texture {
|
|||||||
public:
|
public:
|
||||||
noiseTexture() {}
|
noiseTexture() {}
|
||||||
|
|
||||||
|
noiseTexture(double scale) : scale(scale) {}
|
||||||
|
|
||||||
colour value(double u, double v, const point3& p) const override {
|
colour value(double u, double v, const point3& p) const override {
|
||||||
return colour(1,1,1) * noise.noise(p);
|
return colour(1,1,1) * noise.noise(scale * p);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
perlin noise;
|
perlin noise;
|
||||||
|
double scale;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Reference in New Issue
Block a user