add ambient intensity

This commit is contained in:
Shuo Feng 2024-03-14 19:15:16 -04:00
parent ef5df2fa64
commit 641b62ca01
Signed by: sfeng
GPG key ID: 1E83AE6CD1C037B1
4 changed files with 13 additions and 2 deletions

View file

@ -1,4 +1,6 @@
#include "Light.h"
#include "Scene.h"
#include <algorithm>
#include <cmath>
@ -30,7 +32,8 @@ Vector3f PointLight::illumination(const HitRecord &hit,
g->type() == Geometry::Type::SPHERE)
return Vector3f::Zero();
Vector3f ambient_ = geometry->ka() * geometry->ca();
Vector3f ambient_ =
geometry->ka() * geometry->ca().array() * Scene::current->ai().array();
Vector3f diffuse_ = geometry->kd() * geometry->cd().array() * id_.array() *
std::max(0.0f, hit.normal().dot(rayDirection));