CS4451: Assignment 6

Ray Tracing

Due: 10am, Wednesday December 8th


Purpose

To generate realistic-looking images using ray tracing.

Task

Write a program to read a given input file (whose name is passed as a command line parameter). The data in the file will describe a scene to be rendered. After reading the file, your program should then ray trace the image specified by the data. All programs should be able to generate images with shadows and diffuse reflection. Your program should be able to handle spheres and (planar) polygons, and point light sources as well as ambient lighting. Optional additions for extra credit (and nicer images) are described below.

Sample data will be provided. Your program should work on the sample data, as well on other similar data. You should ray trace at least one image of moderate complexity at a resolution of 300 by 300 and save the image to a publicly accessible web page (use snapshot to capture it, and then xv to convert it to GIF so that it doesn't use up so much disk space). Include a URL for the web page in the header comments of the file you turn in. The web page should contain the image and any other comments you feel are necessary. (We'll try to get some of the best looking images on the class web site for your peers to enjoy!) The data file to create this image should be included in your submission.

In order to generate more complex and interesting data files, please use the SPD program. You can use it to write out NFF files, and can also use it to show you roughly what those files should look like. It can be found at http://www.acm.org/tog/resources/SPD/overview.html. The page contains pointers to Windows and Mac binaries, and the windows zip file has the source in it that should compile on any Unix machine. We will put Sun and SGI versions in the class account.

We will be using the NFF file format for this program. It provides some interesting models to raytrace, but also provides a lot of information you won't need for the most basic version of this program. You may ignore those parts of the input that aren't part of the core functionality.

Your program should, at a minimum, handle spheres, polygons, and point light sources. For the most basic version of this program you may assume that your eyepoint is on the positive z-axis, looking back toward the origin along the negative z-axis. You may assume the window is a square centered at the origin, extending from (-1,-1) to (1,1). In this simplified viewing system, just use the z value of the "from" coordinates in the NFF file to set the eye position.

Note: for this program you are being provided with a shell that reads the scene data and builds linked lists of objects and light sources. You will be given the files ray.c, ray.h and trace.c. Ray.c reads the input file and builds the data structures, while trace.c contains the display callback with the raytracing stub (as usual, ray.h contains some common structures, etc, used by both files). You should use the ray.c and ray.h files in an unmodified form, and implement your raytracing code in trace.c. In the simplest form, you just change shoot_ray to trace a single ray through the scene and return the resulting color.

All of the files for the assignment are in ~cs4451/a6-files


Turn in

Your submission should consist of
  • a single file "trace.c" which implements the ray tracing component. The TAs will evaluate it using some simple test files, and by looking at your sample image on the web page pointed to in the comments. Your source file should be commented with the usual comments. If you do the optional parts of the assignment, you should include them in the same file.
  • a data file "testfile.nff" which generated the image on the web page.
  • a "README" text file describing which options you included in your submission.

Your submission MUST be mailed to the class account as a single, uuencoded tar file (using the process described in the course newsgroup). Using MIME attachments to turn in files is NOT acceptable; the TAs may deduct up to 25% off your grade for incorrectly submitted assignments, so if you are unsure of how to submit, talk to the TAs BEFORE THE ASSIGNMENT IS DUE.

The time the mail is received will be used to determine whether or not the program is late, so be sure to allow a couple of minutes for the mail system to transmit your file if you are working right up to the deadline.

IMPORTANT: If the TA has to edit your file, you will lose up to another 25%.


Due date

This program is due before class on Monday, November 22th. This means it must be received by 9:59am EDT on Monday to not be considered late. As with previous assignments, you will lose 25% per day the assignment is late, and programs submitted more than 2 days late will not be graded.

GRADUATING SENIORS ARE NOT ALLOWED TO SUBMIT LATE ASSIGNMENTS.


Grading

The grading will be done as in previous assignments. Among other things, your program will be graded on its ray-sphere intersections, ray-polygon intersections, diffuse and ambient lighting calculations, shadows, and the "look" of the image (eg even shading, correct shadow placement, etc).

Extra Credit

The following options can be added for extra credit. You will receive extra credit for each option you implement, which may exceed the 2 possible point total that could be obtained in the previous assignments (each option will be worth 1 or 2 points):
  1. specular highlights
  2. transparency/refraction
  3. reflection
  4. correct viewing transformations based on the input data
  5. ray-object intersection calculations for the other objects supported by the input file format (cylinders and cones, polygonal patches)
  6. speedup options such as bounding volumes, octrees, adaptive raytracing, etc.
  7. other features (should be approved first)

In all cases, be sure that your README file describes the enhancement(s), as well as instructions on how to invoke them or show them off.

Note: you should NOT worry about any of these until you have implemented the basic functionality of the program--the required parts!


Input File Format

The input file format is described in the file NFF.DOC, provided for you in the ~cs4451/a6-files directory. The input data is read into two linked lists, one for objects and one for lights, and one structure containing viewing information. These are straightforward and should be self-explanatory--see the include file for details.

Hints and Tips

Sample data are posted in ~cs4451/a5-files. The shell program (Makefile, ray.c, ray.h and trace.c) will also be in that directory.

The comments at the start of the program should contain details of how to compile and run it. These samples were obtained from previous years, are are provided as a way to make the assignment simpler. If you do not like them, feel free to change them. However, you will not receive extra credit for doing so.

Ray tracing, especially with no optimizations, is a VERY time-consuming process!!! Initially when developing and testing your program, work with small images so that you aren't tracing as many pixels. Only when you are sure your program is working correctly and that your "camera" is pointing where you wish should you attempt a higher resolution scene!

Along the same lines, please do NOT log in remotely and export the display to the machine you are using. Use only the cycles of the machine you are sitting in front of (if you were ever using the SGI lab when the Alias users fired off remote renders on every machine in the lab, then you already KNOW how frustrating it can be when someone else is raytracing on the machine you are trying to work on!).