Reflections
pixel = pixel + castRay(P, reflectDirection)pixel = pixel + sphere.reflectFactor * castRay(P, reflectDirection)



Last updated
pixel = pixel + castRay(P, reflectDirection)pixel = pixel + sphere.reflectFactor * castRay(P, reflectDirection)



Last updated
let normal = normlize(P - sphere.c);
function reflectRay(ray, normal, P) {
// project the ray direction onto the normal
let proj = dotProduct(ray.d, normal) * normal
// invert the projection and multiply by 2
proj = -2 * proj
let reflectDir = proj + ray.d
// The new ray has P as its starting point, and the reflectDir as its direction
return new Ray(
o = P
d = reflectDir
)
}