fix area light illumination

This commit is contained in:
Shuo Feng 2024-03-20 16:53:55 -04:00
parent ebae7ccfaf
commit 87d3c2788e
Signed by: sfeng
GPG key ID: 1E83AE6CD1C037B1

View file

@ -57,11 +57,10 @@ Vector3f AreaLight::illumination(const HitRecord &hit,
Vector3f u = p4 - p1; Vector3f u = p4 - p1;
Vector3f v = p2 - p1; Vector3f v = p2 - p1;
Vector3f color = Vector3f::Zero();
if (useCenter) { if (useCenter) {
color += PointLight(*this, getCenter()).illumination(hit, geometries); return PointLight(*this, getCenter()).illumination(hit, geometries);
} else { } else {
Vector3f color = Vector3f::Zero();
for (int y = 0; y < gridSize; ++y) for (int y = 0; y < gridSize; ++y)
for (int x = 0; x < gridSize; ++x) { for (int x = 0; x < gridSize; ++x) {
Vector3f contribution = Vector3f contribution =
@ -69,7 +68,6 @@ Vector3f AreaLight::illumination(const HitRecord &hit,
.illumination(hit, geometries); .illumination(hit, geometries);
color += contribution; color += contribution;
} }
return color / gridSize / gridSize;
} }
return color / gridSize / gridSize;
} }