Added experimental mirrorshader

This commit is contained in:
arvid schröder 2022-11-17 14:39:11 +01:00
parent 29f4d0fe3c
commit 48e027c45d

View file

@ -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);
}