CS 445/645: Introduction to Computer Graphics
Assignment #4, part 2
Goal: Environment Maps
URL: http://www.cs.virginia.edu/~gfx/Courses/2001/Intro.fall01/Exercises/assignment4-2.htm
Assigned: Thursday, November 15, 2001
Due: Wednesday, November 28, 2001 at midnight
Relevant reading/files/software:
UPDATE: Tunnel Cube Face Textures for your cube map.
UPDATE: Adobe Cube Face Textures for your cube map.
UPDATE: Code to solve for alpha and extrapolate an intersection point that will yield correct texture coordinates is now available.
Synopsis: The goal of this two part assignment is to generate three-dimensional models with interesting color and texturing. In the first part, you used a program called Teddy http://www.mtl.t.u-tokyo.ac.jp/~takeo/teddy/teddy.htm to create a three-dimensional model. You used Teddy to save a model in OBJ format. Hopefully, your part one code successfully read this model and allowed you to view it in an OpenGL/Glut window. If not, the quickest way I suggest to get up and running is to use Nate Robins's code http://www.xmission.com/~nate/smooth.html.
In part two of the assignment, we will add environment mapping using multipass textures and alpha blending.
Specifics: As in assignment 4, part 1, your program must accept a filename (ex: foo.obj) as a command line argument. The program must then read the .obj file and create the GL polygons that represent the model. You may use the model you generated with Teddy or you may use another one you find someplace. Nothing too trivial, though.
We want the model to look good, so compute vertex normals. Position at least three lights in the scene to nicely illuminate the model. Include in your README a brief description of the light types you selected and your decisions regarding position/direction.
We will develop a robust way to describe the rotation of the world, quaternions. This topic will be discussed in class, though there are plenty of tutorials on line. Your system must use quaternions to represent the rotation of the world and to support the interaction with the mouse. The entire world, including the cube, lights, and model should move. Conceptually, you are moving the camera. As in assignment 3, the left button of the mouse will be used to control rotations and the right button of the mouse will be used to control zooming. The texture on your model should change to reflect the changing position of the camera.
The OBJ model you load will be enclosed in a six-sided box that you can create using GL_POLYGONs. Pick a size for the box that produces the most dramatic texturing effect. Each of the six sides will have a texture map attached to its inside face. You can hardcode the textures you use and I suggest using a texture loader like you did for assignment 4 part 1.
You can find images to use as textures in many places. Many web sites include sample textures. Images you've already scanned will work too. If you want to capture a particular image, Cliff will have access to a digital camera and he will be able help you grab images during his office hours.
Your model should be texture mapped to look like it is reflecting the textures from the walls of the cube, an environment map. To achieve this effect, you will have to compute texture coordinates for each vertex. You can evaluate the texture coordinates by computing the intersection between a vector cast from each vertex (in the direction of the reflection vector based on the vertex normal and the vector to the camera) and the cube sides. Some of these texture coordinate mappings will be straightforward, whereas others will not. For example, how do you handle a polygon with vertices that project onto two or three different sides of the cube?
In order to work with polygons that reflect onto multiple faces of your bounding cube, you will use multitexturing/multipass rendering and alpha blending. The SGI O2's do not support multitexturing, whereas many of the machines you folks use at home do. To give you all the fullest capability to have fun with this, you can develop at home and skip the SGI compile stage of the turnin. I encourage the use of multitexturing (as a useful real-world skill) but it's not required. Cliff will probably send mail to the class with instructions that will simplify his grading of your assignments.
Page 410 of the Red Book describes a way to clamp a texture and use its border for texture coordinates greater or less than 1.0 and 0.0 respectively. Create a border with an alpha value of 0 for each texture. Make sure you enable blending (Red Book, Chapter 6) with glEnable (GL_BLEND). We'll discuss this in class.
Points:
Turning in the assignment:
Collaboration: You may talk with one another about your projects, but one should not take written records during the collaboration. Your recollection of the concepts should be the product of the collaboration. Similarly, no side-by-side coding. You can look for code on the web to help with this, but reference any code you use or learn from in your README so I know the difference between what you did and what someone else did.
Image editing: The SGI's provide some handy image editing/conversion tools that can be found in ~dcb8j/Gfx/Tools/bin (note that the standard file format for SGI is called .rgb or .sgi):