Math 155A - Introduction to Computer Graphics - Spring 2005
Instructor: Sam Buss,  Univ. of California, San Diego

Project #4 - Add lights and materials to your scene. 

Due Date: Wednesday, May 11, midnight.

Goals: Use illumination and shading to make your scene from project #3 look more three-dimensional.  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 Math 155A home directory.  (As usual, not your "My Documents" folder).   Place, in that directory, all your source files and project files (including .sln and .vcproj files).
    (2)
You must upload also, a thumbnail GIF file, a full size screenshot and a very simple HTML file.  Instructions for this are in UploadHowto.html.  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.   Grading must be done within two weeks of the due date, preferably earlier.

FOR THIS PROJECT #4, DO THE FOLLOWING STEPS #1 - #9.

1. Download PC executable from the web, at http://www.math.ucsd.edu/~sbuss/CourseWeb/Math155A_2005Spring/LightedScene.exe.   Run the executable file on a PC.  You will see a scene with a surface of rotation 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 all of 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. 

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 .NET 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 surface of rotation.  (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 them too.)
        - 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 screenshot and a thumbnail gif, then turn everything in.    Reminder: you must turn in both (1) files to the CSE167 storage directory, including source files and project files and (2) files that uploaded to the common class web page using the Project Four upload page.    This must include a thumb.gif file and a JPEG screenshot image as in Project #3.  For your index.html file, modify the one used for handing in Project #3.

10. Extra credit items (up to a total of 1/2 point extra credit only):  
        (a) Learn how to apply textures on your own (we will discuss in it class later) and give the base plane an attractive texture. 
        Or, (b) Add a spotlight to the demo and show it off effectively.  For instance, shining onto the ground plane.

Grading is on a scale of 1-10.