Removed superfluous normalizations

This commit is contained in:
arvid schröder 2022-11-17 22:26:43 +01:00
parent 8e14f3ccae
commit 37753f96af
3 changed files with 6 additions and 6 deletions

View file

@ -27,10 +27,10 @@ bool InfinitePlane::intersect(Ray &ray) const {
return false; return false;
// Set the normal // Set the normal
if (std::acos(dotProduct(ray.direction, this->normal)) > 0) { if (dotProduct(normalized(ray.direction), normalized(this->normal)) > 0) {
ray.normal = normalized(this->normal); ray.normal = this->normal;
} else { } else {
ray.normal = normalized((-1.0f * this->normal)); ray.normal = -1.0f * this->normal;
} }

View file

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

View file

@ -18,7 +18,7 @@ Color RefractionShader::shade(Scene const &scene, Ray const &ray) const {
float eta2 = indexInside; float eta2 = indexInside;
Vector3d v = normalized(ray.direction); Vector3d v = (ray.direction);
Vector3d n = normalized(ray.normal); Vector3d n = normalized(ray.normal);
// Check whether we are entering or leaving the object // Check whether we are entering or leaving the object
@ -43,7 +43,7 @@ Color RefractionShader::shade(Scene const &scene, Ray const &ray) const {
} }
// Calculate refracted ray direction t // Calculate refracted ray direction t
Vector3d t = normalized( Vector3d t = (
eta1 / eta2 * eta1 / eta2 *
(v - dotProduct(v, n) * n) - (v - dotProduct(v, n) * n) -
n * std::sqrt(denominator)); n * std::sqrt(denominator));