CSE 167 - Introduction
to Computer Graphics - Fall 2003
Instructor: Sam Buss, Univ. of California, San Diego
Project #4 - Add lights and materials to your scene.
Due Date: Friday, November 14, midnight.
Goals: Use illumination and shading to make your scene from project #3 look more three-dimensions. Learn how to shade objects with the Phong lighting model in OpenGL. Create three lights, two or more materials. Add keyboard controls to your program.
What to hand in: (1) Make a directory called
LightedScene in your CSE 167 home directory. (The CSE 167 home directory on
ieng9, under Class Resources, not your "My Documents"
file modification dates will serve as a time stamp so we will know files have
been turned in on time. Place, in that directory, all your source
files and project files (including .dsp and .dsw files).
(2) You must upload also, a thumbnail GIF file, a full size screenshot and a very simple HTML file using a web page described below. This will collect the entire class's projects into a web page that will be made accessible on the web.
As usual, grading will be personalized and one-on-one with a TA or with Sam Buss. Your program must run on the PC lab, you must come into the PC lab and meet one of us. You will have to show your source code, run the program, possibly make changes on the spot to your program and recompile as requested by the grader, and be able to explain how your program works and why it renders what it does. Your files should be complete and project must recompile in the ieng9 directory. You will then come see a TA to get your work graded. This grading MUST be done by Friday, November 21, and we prefer that it be done earlier.
FOR THIS PROJECT #4, DO THE FOLLOWING STEPS #1 - #N.
1. Download PC executable from the web, at http://math.ucsd.edu/~sbuss/CourseWeb/CSE167_2003F/LightedScene.exe . You can also get this file from the ieng9 class public directory. This an executable for PC's only. You will not be able to use it on Macintoshes or under Unix/Linux. Run the executable file on a PC. You will see a scene with a mushroom like shape and a letter "S". Now there are also three lights (shown as three spheres) and the surfaces show Phong lighting effects, including specular highlights. The LightedScene program supports all the old controls from WireFrameScene plus some new ones:
Experiment with these controls. Try increasing and decreasing the mesh fineness while switching back and forth between smooth and flat shading modes. Notice how the specular highlights change size and position when you toggle the "h" command -- understand why this happen. Rotate slowly around the object in smooth and flat shading modes -- note how a little bit of the faceting can be seen even in smooth mode, especially if the mesh size is not very high.
Your job is to re-create this program -- but with your own three-dimensional geometry from Programming assignment #3. If you failed to complete assignment #3, and want to use my geometries instead, please come see me.
2. Form a new project and workspace -- call it LightedScene. Copy YOUR files from Project #3 and include them in the project LightedScene (you will probably wish to rename the source files too). For information on how to build a new project, read this handout on starting a new Visual C++ 6.0 program.
3. Add three lights and ambient lighting.
4. Keyboard controls "1", "2" and "3" toggle these lights off and on. Add these controls to the myKeyboardFunc routine. glEnable(GL_LIGHTi) and glDisable(GL_LIGHTi), for i = 0, 1,2, are the relevant commands to turn lights on and off.
5. Give objects in your scene materials and material properties.
6. Give normal vectors for the vertices in your mushroom cap.
(Normal vectors are automatically given for the built-in glut Solid Objects.
If you built some custom geometries you probably need to add normal vectors for
- You probably will need to use the glEnable(GL_NORMALIZE) command (why???).
7. Add the keyboard command "s" that toggles between flat and smooth shading mode for all materials in the scene.
8. Add the "h" keyboard command to toggle between the two modes:
Mode (a) with positional lights and local viewer, and mode (b) with directional lights and non-local viewer.
9. Make a screen shot and a thumbnail gif, then turn everything in. Here is a page with detailed turn-in instructions.
Grading is on a scale of 1-8 as usual.