12 lines
472 B
C++
12 lines
472 B
C++
#include "scene/scene.h"
|
|
#include "shader/mirrorshader.h"
|
|
|
|
MirrorShader::MirrorShader() {}
|
|
|
|
Color MirrorShader::shade(Scene const &scene, Ray const &ray) const {
|
|
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);
|
|
}
|