From 6d81bd45303db17496ab48be9de305724f474933 Mon Sep 17 00:00:00 2001 From: vonhyou Date: Mon, 4 Mar 2024 02:43:10 -0500 Subject: [PATCH] calc correct light --- src/Light.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Light.cc b/src/Light.cc index e9f1075..4298adf 100644 --- a/src/Light.cc +++ b/src/Light.cc @@ -1,6 +1,7 @@ #include "Light.h" #include #include +#include void Light::setTransform(const Matrix4f &transform) { this->transform = transform; @@ -52,11 +53,11 @@ Vector3f AreaLight::illumination(const HitRecord &hit, Vector3f color = Vector3f::Zero(); if (useCenter) { - color += PointLight(*this, (u + v) / 2).illumination(hit, geometries); + color += PointLight(*this, p1 + (u + v) / 2).illumination(hit, geometries); } else { for (int y = 0; y < gridSize; ++y) for (int x = 0; x < gridSize; ++x) - color += PointLight(*this, (u * x + v * y) / gridSize) + color += PointLight(*this, p1 + (u * x + v * y) / gridSize) .illumination(hit, geometries); }