So I'm working on an assignment where we have to design a simple ray tracer. The program has two objects that it can use, sphere and cube. It can render the cube and spheres, it also does shading on the objects and will cast a shadow of light for the spheres; however, the boxes are not casting shadows. Instead I think it is casting it upon the actual cube instead of "the ground". Any ideas on how to fix that?
Copyright © 2024 VQUIX.COM - All rights reserved.
Answers & Comments
When you have calculated the Point of Intersection of your ray, the next step is to look at the ray from PoI to light source. If this ray intersects with any object, the PoI is in the shadow of that object. For a simple raytracer you'd paint a black pixel and move on.
If your spheres are casting shadows but your cubes aren't, it most likely means that you aren't intersecting the ray with all the objects, just the spheres.