Function tinyraytracer::reflective_ray_cast [−][src]
pub(crate) fn reflective_ray_cast(
ray: Ray,
scene: &[Box<dyn RayCollision>],
lights: &[LightSource],
depth: u32
) -> Material
Our ray of lights don’t stay in the same spot. If the hit some reflective material, they bounce off it like a ball. The is a recursive process. We start with a ray of light and cast it through the scene. Every time a ray hits some object and bounces off, well that’s a new ray. In real life ( I guess ) this process can go on until light losses energy, here we put a hard limit on the number of bounces.