2022-11-25 14:58:29 +01:00
|
|
|
#include "light/light.h"
|
|
|
|
#include "scene/scene.h"
|
|
|
|
#include "shader/lambertshader.h"
|
|
|
|
|
|
|
|
LambertShader::LambertShader(Color const &diffuseColor) : diffuseColor(diffuseColor) {}
|
|
|
|
|
|
|
|
Color LambertShader::shade(Scene const &scene, Ray const &ray) const {
|
|
|
|
Color fragmentColor;
|
|
|
|
|
|
|
|
// IMPLEMENT ME
|
2022-11-28 19:15:34 +01:00
|
|
|
for (auto& light : scene.lights()) {
|
|
|
|
auto illum = light->illuminate(scene, ray);
|
|
|
|
auto lightAngle = dotProduct(ray.normal, normalized(illum.direction));
|
|
|
|
fragmentColor += illum.color * std::abs(lightAngle);
|
|
|
|
}
|
|
|
|
return fragmentColor * diffuseColor;
|
2022-11-25 14:58:29 +01:00
|
|
|
}
|