Write a program that uses ray-casting to render a simple lighted scene containing spheres. Your program should take five command line arguments:
For each pixel on the viewport, you need to cast a ray from the viewpoint through the pixel and determine the point of intersection between the ray and the closest object in the scene. Then, at the intersection point, you should perform the appropriate lighting calculations to compute the intensity for the pixel. Basic shadow handling must be included as well: if any objects fall between the intersection point and a particular light, then that light should not contribute to the intensity computation for that point.
Lighting calculations must account for global ambient light and and for diffuse, and specular components of multiple individual lights. The lighting computation should also include a distance-based attenuation factor. The file format allows specification of attenuation coefficients corresponding to those in OpenGL lighting (p. 197-198 OGL book) to be specified for the scene (this one set of coefficients, GLOBAL_ATTENTUATION, will be used for all lights rather than having separate coefficients for each light).
In Homework 6, you will extend your HW5 program to do recursive ray tracing. Objects will include both spheres and boxes. You should think carefully about the organization of the functions in your HW5 program; if organized properly it will be much easier to add recursive ray tracing calls to your HW6 program.
Ambitious students should consider integrating/combining the ray casting/tracing functionality directly into HW4. The idea is simple: after setting up a scene in HW4, have your program open an new window and render the ray cast/traced scene in that window (without closing the original HW4 window). This isn't very hard. If you get your ray caster/tracer working, I'd be happy to talk with you about how to do it if you have trouble.