From 9dcbefe5a55d6033da1e2f0bebeb9b96c1f6d495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?arvid=20schr=C3=B6der?= Date: Mon, 28 Nov 2022 19:15:34 +0100 Subject: [PATCH] Added simplistic lambert implementation --- shader/lambertshader.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/shader/lambertshader.cpp b/shader/lambertshader.cpp index 3aebacd..5e94254 100644 --- a/shader/lambertshader.cpp +++ b/shader/lambertshader.cpp @@ -8,6 +8,10 @@ Color LambertShader::shade(Scene const &scene, Ray const &ray) const { Color fragmentColor; // IMPLEMENT ME - - return fragmentColor; + 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; }