I have a problem about raytracing. I can create sphere but ı cannot give a shadow. You have to compile this code in command line(cmd). How can we put shadow on this three sphere.When you compile this code you can see 3 sphere and light also shine. but there is no shadow pls help me. thank you
You need to generalize the scene/ray intersection logic into a function. That function can then be used to follow rays from the camera as well as from points of intersection on other objects.
The idea is that when a camera ray hits an object, you create a new ray from that intersection point to each light source, and run the ray/scene intersection again. If one of these rays intersects an object that is closer than the light source, then it does not contribute any energy to that point.
You can also compute the ray of reflection and recursively determine its color, modulating it with the surface properties of the object. You will want to limit the depth of recursion so you don't get stuck in an infinite hall of mirrors.