CS 248: Introduction to Computer Graphics

Pat Hanrahan


Assignment 2

Handed out: Tuesday, January 28. 1997
Due: 5pm, Tuesday, February 11, 1997

One of the cleverest new techniques in computer graphics is the ability to simulate looking around a 3d scene in real time by reprojecting panoramic views of the environment. The best example of this technique is the system from Apple called QuickTimeVR. The system allows the user to look freely in any direction from a fixed viewpoint. The input to the viewer is a full surround panoramic photographic that captures the entire environment. The environment may be either created by a computer, or captured from a set of photographs.

Your assignment is to build such a viewer. As you will see this involves writing a simple texture mapped polygon scan converter. To help concentrate your efforts on the most important and interesting aspects of this assignment, we will provide you with an example viewer, and a set of interesting environments. Your job will be to write the critical inner-most loop of this program---the polygon scan converter with texture mapping.

The key design decision in this system is the representation of the environment surrounding the vantage point. In this assignment we will use a cubical environment map. In this representation, a cube is centered at the vantage point and images of the surrounding environment as seen from the vantage point are stored on each of the 6 faces of the cube. From this information any possible view of the environment from that vantage point may be synthesized. The viewer program takes as input the 6 images, one for each face, and then allows the user to pan and tilt their head to look in any direction. Each face of the cubical environment map is then projected onto the display surface given the current orientation, and is drawn into the framebuffer as a texture mapped polygon.

Since we have not covered the mathematics of many of the 3D geometric operations yet (although we will soon), we will provide a outer shell program that handles the user interface, the orientation of the user's head, the projection of the cube faces onto an image plane, and the clipping of the cube faces to the near Z plane. Your job will be to write a single procedure that takes as input the 2D projection of the three vertices of a triangle, and draws that triangle into the image buffer using a texture map.


As with the first assignment, the class web pages contain detailed instructions on how to submit your assignment. Unlike the first assignment, you will be submitting only one source file. If you are writing your code in C, you should submit rasterize.c; if you are writing your code in C++, you should submit rasterize.cc or rasterize.C. The rest of the files you use should be identical to the ones from the example program, and thus need no submitting. Submission should take place using submit, the assignment 2 CS248 submission script.

Your grade will be based on the following criteria: 90% for implementing the functionality that we request, and 10% for tuning the code. The criteria for tuning the code will be based on your code's speed divided by our code's speed. If your code runs at half our code's speed, you get 5%. Thus, you can get extra credit if your code runs faster than ours (good luck though). We will dock up to 10% if your submission cannot be recompiled and executed. We suggest you attack the assignment as follows:

Step 1.

Step 2.

Step 3.

Step 4.

Step 5.

[email protected]

Copyright © 1997 Pat Hanrahan