diff --git a/shader/mirrorshader.cpp b/shader/mirrorshader.cpp index 201a532..b68db45 100644 --- a/shader/mirrorshader.cpp +++ b/shader/mirrorshader.cpp @@ -4,9 +4,9 @@ MirrorShader::MirrorShader() {} Color MirrorShader::shade(Scene const &scene, Ray const &ray) const { - // IMPLEMENT ME - // Calculate the reflection vector - // Create a new reflection ray - // Send the new ray out into the scene and return the result - return Color(0, 0, 1); + Vector3d newDirection = ray.direction - 2 * dotProduct(ray.normal, ray.direction) * ray.normal; + + //TODO: should we reset the ray or use a new ray? Regarding the count of bounces + Ray mirroredRay = Ray(ray.origin + ray.length * ray.direction, newDirection); + return scene.traceRay(mirroredRay); }