You are to implement a program which renders spheres using ray casting. The difference between this and ray tracing is that you only have to cast primary rays and compute their intersections with objects. Once the closest intersection for a ray is known, you can use the Phong local illumination model to compute the color for that point. You may assume that you have only a very few objects in the scene, so you don't need to do clipping or anything fancy to speed up your code. Your objects should be specified by giving the quadric type and parameters, diffuse color, specular color, and material. You should also be able to specify a color for the background of the scene. You should be able to place the viewer anywhere in the scene by specifying an eye, lookat point, and top of head point, and you should be able to specify the width, height, number of pixels wide, and number of pixels high of a window centered a distance d (specified by you) along the viewing vector.
Your goal will be to produce a picture with three spheres. You can assume that all light sources are directional (points at infinity), and that you have no more than 3 light sources. You should also be able to specify the position of these. All specifications of the scene geometry should be in an ascii input file, which your program reads to produce the internal description of the situation. You then run your program to produce an array of pixel colors of the size specified for your window, which your program outputs as a ppm (see below) file. You can display your files using xv, so you need not write any display software.
You will need to write routines for creating a ray from the eye through the center of each pixel in the window, computing the intersection of any ray with a sphere, computing the normal to the sphere at the intersection point, and evaluating the Phong model. There is no user interface requirement for this assignment. You can use a text editor to create the input file, and you will use xv to display your results. Once you have the ray tracer working, you can expect to get some really ugly pictures at first. Plan to spend some time tweaking the parameters of your Phong model to make the images look more realistic.