Project 4: Ray Tracing
CS354 Computer Graphics
Due: November 28, 11:59 pm


Goal
This project is on writing a simple recursive ray tracer. Using this you will generate scenes with objects having reflections, transparency and shadows.

Project Specifications
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 colored light sources
- diffuse and specular reflectivity of objects
- multiple reflections
- shadows of objects
- transparency

Note: In this project you will use OpenGl only for displaying the pixels, all the rendering task will be done through your own ray tracer.

Getting Started and Suggested Approach
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 single pixels 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 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 4 points: Do antialiasing, fire multiple rays (say four) through each pixel to get a much more accurate image.
- up to 4 points: Make some interesting objects by combining convex objects.

Questions Related to Project (20% of the project score)
1. How the running time taken by your ray tracer will get affected (whether it will increase or decrease or remain the same) by each of the following:
     (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 & shadows using ray tracing. Out of these, which are the ones that can't be implemented directly using OpenGl? For the rest, what will run faster - your ray tracer or an OpenGl implementation?

3. If the entire 3D space is divided into a regular lattice (set of 3D cubes) and for every object it is known that it falls into which cube(s), then how will you speed-up your ray tracer?

What and how to submit
Your program should compile and run on the Taylor or Painter basement machines. Then submit the following files:

The README file should be a plain text file, it should clearly mention: your name, what the submitted files contain (e.g. which is the executable, which contain the source code etc.), how and on which machine(s) your program compiles and runs, and a short description of the user interface.

The report should also be a plain text file which should contain the answer to the above "Questions Related to the Project".  In the report please mention the extra features that you have implemented. In addition, if appropriate, you may also write about what  new ideas you came up with, what design decisions you took, comments about the project etc; please keep such a discussion short and to the point.

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.

Use the turnin program to submit your files. You have to turnin to: rjkate cs354-project4
Here is a short note on how to use turnin program.

Thanks!