Overview
For this assignment, you must write a C++ program that will render spheres and triangles using ray tracing. The input is in a subset of the Polyray (.pi) text file format, containing information about the view and objects in the scene. You will read a .pi scene from a file, and ray trace the single image described there. Rays that hit an object should be rendered in the object's "diffuse" color, while rays that do not hit any object should use the background color of the scene. Do not try to include any of the more advanced ray tracing features you may read about (shadows, reflection, refraction, lights, etc.), we will get to those later. Your output should be an image file in PPM format.
Assignment Goals
The primary goals of this assignment are:
- Get experience converting vector equations into code
- Parse input file into appropriate data structures
- Compute ray directions over an image
- Compute ray-sphere and ray-triangle intersections
Output
Your output should be a file named "trace.ppm" in the PROJECT_BUILD_DIR directory. Once you are happy with this file, copy it into the trace directory and commit it.
We are using the PPM image file format because it is exceedingly simple to write. See the specification for details. You are free to use the trace assn0 code as a basis. PPM colors use unsigned bytes, but colors in the .pi files are floating point numbers between 0 and 1. I recommend using floating point colors until it is time to assign the color into an image pixel. At that point, you should clamp the color to the 0-1 range (to avoid overflow), multiply by 255, and cast to unsigned char.
Other people's code
Ray tracing is a popular rendering technique, and the internet contains lots of resources for ray tracers in general and things like ray-object intersection in particular. Other than the assn0 sample code, YOU MAY NOT USE ANY OUTSIDE CODE. All code that you use must be strictly your own.
Strategy
This is a big assignment. Start NOW, or you will probably not finish. No, really, I promise you will not be able to do it in the last two days. Even before we get to all of the details of the ray tracing itself, you can still start working on your file parsing.
I have created a separate page with some additional development suggestions.
What to turn in
Turn in this assignment electronically by pushing your source code to your class git repository by 11:59 PM on the day of the deadline and tagging the commit assn1. Do your development in the trace directory so we can find it.
Submit an image of your output for balls3-color.pi, replacing the trace/trace.ppm file. If you are a graduate student, also include a second ppm file in your trace directory with your output for gears2.pi.
Include a gfx26/assn1.txt file at the top level of your repository telling us about your assignment. Tell us what works, and what does not. Also tell us what (if any) help you received from books, web sites, or people other than the instructor and TA.
You must make multiple commits along the way with useful checkin messages. We will be looking at your development process, so a complete and perfectly working ray tracer submitted in a single checkin one minute before the deadline will NOT get full credit. Individual checkins of complete files one at a time will not count as incremental commits. Do be sure to check in all of your source code, but no build files, log files, generated images, zip files, libraries, or other non-code content.

