16 lines
430 B
C++
16 lines
430 B
C++
|
#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;
|
||
|
}
|