Ray Tracer by Daniel White Download executable: Here Download models: Tetrahedon Checkerboard and Tetrahedon Download source: Here Introduction: I set out to write a ray tracer that sent out 1 ray per pixel of output. It would have the ability to calculate distance attenuation, reflections, refractions, and shadows. I set a limit on the depth of recursion for refractions and reflections to 3. Although I believe it is capable of more, the program is already slow enough. Instructions: From a command line, call: finalp [model name such as t.m] [reflections or refractions 0 for off, 1 for on] [distance attenuation 0 or 1] [shadows 0 or 1] Then simply wait as the raytracer produces the results in a file of the format: "rays_sra.tga" The program will periodically output percent of the rays completed. The program will also output upon success of input read, rays cast, and output file written. Experiments: In the following pictures I set up two models. One contains just a tetrahedron, and the other contains the tetrahedron and a checkerboard of 9 squares alternating black and white. Each square in the checkerboard is actually made of 2 triangles. I then test various combinations of distance attenuation, reflections and refractions, and shadows. In the first two pictures there is one light source, but in the rest there are two light sources. Results: Tetrahedron - Distance attenuation off, reflections and refractions off, shadows off Tetrahedron - Distance attenuation on, reflections and refractions off, shadows off Tetrahedron - Distance attenuation on, reflections and refractions on, shadows off Tetrahedron - Distance attenuation on, reflections and refractions on, shadows off Checker board and Tetrahedron - Distance attenuation on, reflections and refractions off, shadows off Checker board and Tetrahedron - Distance attenuation on, reflections and refractions off, shadows off Checker board and Tetrahedron - Distance attenuation on, reflections and refractions on, shadows off Checker board and Tetrahedron - Distance attenuation on, reflections and refractions on, shadows on Analysis: The most notable result of all the pictures is when shadows are turned on. Yes they don't work at all. I was so perplexed by the result that I chose not to focus my time on fixing it. However we can see how the light is brightest closest to one of the light sources which is close to the bottom left of the screen. There is also another light above the tetrahedron casting that brighter circle down. Whats interesting is how the distance attenuation caused some of the black and white squares to approximately the same color. The very first picture shown is almost solid color; the change in color is due to the change in the lighting vector that connects each point of the tetrahedron to the light source.