CS318 - Fall 1999
Machine Problem 6


Assigned:
November 19, 1999
Due Date:
December 10, 1999, 10:00am


Description

For this MP, you will be implementing a basic Ray Tracer. You will be given a scene description consisting of basic objects such as spheres and planes, and you will render this scene using ray tracing. Your final picture will be complete with effects such as shadows, reflections, and specular highlights.


Goals

Upon completion of this MP, you should be able to do the following things:

  1. Understand the the various illumination models presented in the book;
  2. Derive the equations for ambient, diffuse, and specular shading; and
  3. Implement a basic ray tracing algorithm.


Preparation

Read the Textbook

Read Chapter 14, sections 1 through 6, in the required text for this class - ``Computer Graphics, C Version, 2nd Edition'' by Hearn & Baker. It discusses the basic illumination models, shading, and ray tracing.

Write Your Basic Ray Tracing Algorithm

Before you begin coding, figure out the different parts that make up your ray tracing algorithm. For example, you will have to figure out how to determine intersection with a sphere and a plane, how to calculate a reflection vector, etc.

START NOW!!!

This is your last MP, and it will take you longer than any of the other MPs in this class. You have about 2-1/2 weeks to do it, and you will probably need all of that time to complete it. If you wait until the last minute to start programming, you will not finish. You have been warned.


Your Assignment

You are to write a program that ray traces a scene. Since ray tracing is a slow process, you are required to implement only one input to the program - type ``Q'' to quit. The rest of this section describes the scene, and implementation specifics.

Type the Letter ``Q'' - Quit the Program

When the user types the letter ``q'' or ``Q'', the program should exit.

Scene Description

The description of the scene you are to render is as follows.

Below is an example of this scene rendered with a basic ray tracing algorithm. Notice the shadows cast by the two spheres, the specular highlights of the light on the spheres, and the reflection of each sphere in the other sphere.

{mp6-2.jpg}

Implementation Details

You may use any ray tracing method you wish, as long as you implement ambient, diffuse, and specular lighting, shadows, and reflections. Since the scene described above is very specific, you can make your ray tracer specific to this scene only. It does not need to be general to handle other scenes.

One thing you should realize, however, is that there are many ray tracing programs out there on the internet, and we are aware of most of them. If you get caught copying code directly from these programs into your MP, you will receive a zero for the MP.


Hints / Sample Code


One Unit Grad / Honors Students

Those graduate students enrolled for 1 unit of credit, and undergrad students registered for honors credit, must also implement the following additional functionality.

You must add a third sphere of radius 1.0 to your scene, with its center located at (-2.0,-2.0,1.0). However, this sphere must be made of glass (transparent), with a index of refraction of 1.5. You can make this sphere any color you want, but it must allow light to pass through so you can see objects on the other side.

Below is an example of this scene rendered with a ray tracer. Notice how the image in the glass sphere is upside-down due to refraction.

{mp6-3.jpg}

You may treat this sphere as the other spheres when dealing with shadows. In other words, you do not need to worry about the special shadow generated by this third sphere, or how the light penetrates the glass sphere to generate highlights on the square grid. (In the image above, the shadow generated by the glass sphere has been made slightly lighter by handling it as a special case.)


Hand-In Procedures

For this final MPs, we will be using the electronic handin program. Once you have completed your program, logon or telnet to one of the Sun Sparc machines (``handin'' does not work on the WindowsNT machines) and hand in your source code by typing ``handin cs318 mp6 mp6.c''. (For more information on handing in your code, consult the class web page at http://www-courses.cs.uiuc.edu/~cs318/handin.html.) This will send your program to the class directory for grading.

Do not submit your executable program. Also, put all your source code in one file. You must hand in your source code file before 10:00am of the due date, as handin will not accept late assignments. Make sure your name, login, MP#, and date appear at the top of your code listing. See the class web page for a sample file header.

If your program does not run as required, you will be given at most 50% of the total points for the MP. You are responsible for making sure your program compiles on the WindowsNT machines using the makewin batch file.

Late assignments will not be accepted. If you are having problems beyond your control, you must let a TA know at least 24 hours before the due date to arrange for a possible extension. There will be no exceptions!