cloudy-raytracer/shader/noiseshader.cpp

16 lines
430 B
C++
Raw Normal View History

2023-01-24 06:26:24 +01:00
#include "noiseshader.h"
NoiseShader::NoiseShader(std::shared_ptr<Noise> noise, float scale, Vector3d offset)
{
this->noise = noise;
this->scale = scale;
this->offset = offset;
}
Color NoiseShader::shade(const Scene &scene, const Ray &ray) const
{
Vector3d point = ray.origin + ray.direction * ray.length;
float noiseValue = noise->getNoise(point / scale + offset);
return Color(1, 1, 1) * noiseValue;
}