Sphere normal indentation fixed.

This commit is contained in:
Tobias 2022-11-17 17:34:17 +01:00
parent 6674549b18
commit e168bb7b77

View file

@ -36,9 +36,9 @@ bool Sphere::intersect(Ray &ray) const {
return false;
// Calculate the normal
auto intersectPoint = ray.origin + ray.direction * t;
auto normalDirection = intersectPoint - this->center; // Point of intersect - origin of sphere creates a line along the normal, pointing outwards
ray.normal = normalized(normalDirection);
auto intersectPoint = ray.origin + ray.direction * t;
auto normalDirection = intersectPoint - this->center; // Point of intersect - origin of sphere creates a line along the normal, pointing outwards
ray.normal = normalized(normalDirection);
// Calculate the surface position and tangent vector
float const phi = std::acos(ray.normal.y);