aboutsummaryrefslogtreecommitdiff
path: root/src/raytracer/raytracer.cpp
diff options
context:
space:
mode:
authorFate Bussey <lafayette_bussey@brown.edu>2023-12-12 14:00:56 -0500
committerFate Bussey <lafayette_bussey@brown.edu>2023-12-12 14:00:56 -0500
commit2117034251eaa124ec9c6bec4524e490a0ee9ec0 (patch)
tree2b6ef68677e779ff118a6f5b342a5f57464b8593 /src/raytracer/raytracer.cpp
parent58c896801817ac67913644ccd9373cd18774232a (diff)
potentially buggy normals and first update to phong
Diffstat (limited to 'src/raytracer/raytracer.cpp')
-rw-r--r--src/raytracer/raytracer.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/raytracer/raytracer.cpp b/src/raytracer/raytracer.cpp
index acb229a..b393d40 100644
--- a/src/raytracer/raytracer.cpp
+++ b/src/raytracer/raytracer.cpp
@@ -127,12 +127,9 @@ glm::vec4 RayTracer::getPixelFromRay(
}
}
- glm::vec3 normalObject = getNormal(closestIntersectionObj, intersectedShape, scene);
- glm::vec3 normalWorld =
- (
- glm::inverse(glm::transpose(intersectedShape.ctm))
- * glm::vec4(normalObject, 0.f)
- ).xyz();
+ glm::vec4 normalObject = glm::normalize(getNormal(closestIntersectionObj, intersectedShape, scene));
+ // update
+ glm::vec4 normalWorld = glm::inverse(glm::transpose(intersectedShape.ctm)) * glm::vec4(normalObject);
return illuminatePixel(closestIntersectionWorld, normalWorld, -dWorld, intersectedShape, scene, depth);
}