Build a scene of several objects of your choice. Each object needs to be assigned a diffuse & specular reflectivity and a transparency value. Set up some colored light sources which may be directional or positional.
Generate the scene using ray tracing. Incorporate reflection, transparency & shadows in your ray tracer. Your ray tracer should take the depth (or recursion level) of ray tracing as input (depth up to 5 or 6 is sufficient, as beyond this it generally takes a long time). With increasing depth you will get multiple reflections (i.e. reflection of one object getting reflected from another and so on)
The number of objects should be sufficient enough to demonstrate all the above features (for e.g. shadow of one object should fall on another object, similarly, the required interactions should happen between objects for reflection and transparency).
Hence the required features are:
- multiple light sources, each light source can be assigned a color
- diffuse and specular reflectivity of objects
- multiple reflections
- shadows of objects
Note: In this project you will use OpenGL only for displaying the pixels. All of the remaining steps in rendering will be done by your ray tracer.
Getting Started and Suggested Approach
Starter code for a primitive ray tracer is here. When you compile it, you should get an executable that draws a picture of a dark red circle on a black background: a ray traced picture of a red sphere in dim ambient light.
The simple ray tracer casts a ray through every pixel in the image plane. The image plane lies in the plane z = -1, and the viewpoint is at the origin. The sphere you see is centered at (0,0,-2) and has radius 1.
The ray tracer uses OpenGL only to put up a window; it draws an array of pixels into the window, and you are responsible for coloring the pixels one by one to make the image. The function drawPixel() writes a single pixel to the array.
In this project it is recommended that you increase the complexity of the scene step-by-step. Here is a suggested approach that you may follow.
Look at some of the inspiring images from the previous semester!
For Extra Credit
- up to 6 points: Add texture mapping on objects, this makes for cool pictures
(it's simple to do on planes and cylinders, you may use the readppm function to read a ppm texture image)
- up to 6 points: Incorporate refractions by bending the rays according to physics laws
- up to 6 points: Perform antialiasing. Fire multiple rays (say four) through each pixel and average these rays to get a much more accurate image.
- up to 6 points: Make some interesting objects by combining convex objects.
- up to ??? points: Any additional features you can think of. Be sure to document these in your README..
Written Questions for Each Team Member (20% of the project grade)
1. How will the running time of your ray tracer change for each of the following changes (will it increase or decrease or remain the same)?
(a) the window size is increased
(b) all the objects are increased in size
(c) more objects are added
Give a short explanation for each.
2. In this project, you implemented reflection, transparency, and shadows using ray tracing. Out of these effects, which ones are better suited for a ray tracer and which ones are better suited for OpenGL? Be sure to consider ease of implementation and running time for each effect.
3. Let a regular lattice for 3-D be defined as a set of identically-sized 3-D cubes that divide up a finite amount of 3-D space. The cubes in the lattice are nonoverlapping and the union of all cubes is the original space. If the entire scene is divided into a regular lattice and if every object is placed in the cube or cubes that it occupies, then how can you use the lattice to speed up your ray tracer?
What and How to Submit
Your program should compile and run on the Taylor basement machines. Then submit the following files:
The project4.txt file should also be a plain text file which contains
the answers to the above "Written Questions for Each Team Member".
Each team member needs to create their own version of this file themselves
and then submit their own version
electronically (see the turnin directions below).
You can grab the picture of a scene by using xv on Taylor/Painter basement machines. Save it as .gif or .jpg file. Here is a note on how to grab a window using xv.
Each group should submit their code using:
turnin --submit djeu cs354_project4_code [source code, Makefile, README, project4.jpg, any additional files]
And each person in the group should submit their written answers using:
turnin --submit djeu cs354_project4_written project4.txt
Here is a note on how to use the turnin program.
Ray tracing pseudo-code (PDF)