CS 5600 - Spring 2013

Homework Assignment 4

OpenGL Lighting (100 points)

Handed out: March 20, 2013
Due: 11:59pm, April 10, 2013

 

 

You will write build on the last assignment. 

You should modify it to do the following (include the trackball, animation, modeling, lighting as in the last assignment).

If you did not get animation working correctly, I won’t take off points for a non-animated dog but I will take off points for not having a trackball since I’ll need that to grade the assignment (see the differences in lighting).

 

  1. Put a texture on the body of the dog such that it is your face on both sides of the dog.  Input your face as an image you generate with whatever means you like.  You can have it repeat so that it appears on both sides.  If you need to rotate it so put the top of your head up, this can be done with the TEXTURE MATRIX.  You can convert your photo that will be texture to a format you can read as we discussed in class.  You can also download code from the web to read a jif/gif/tiff/etc file into an OpenGL texture, just document it.
  2. To generate texture coordinates use gluQuadricTexture so that texture coordinates are generated.  This is similar to the gluQuadricNormals call that is necessary for generate normals.
  3. You should do three kinds of lighting with this: fixed function lighting, vertex shader lighting and fragment shader lighting.  Make sure the dog’s body has a good deal of shininess to it so you can see the difference between Phong and Gourand shading.  As we discussed in class, use the GLSL tracking of OpenGL state for the material properties and the light position in your shader code and you won’t need uniforms for that.  You will need a uniform for the texture object though.
  4. The ‘p’ key should put things in fixed function mode.
  5. The ‘o’ key should put lighting into vertex shader mode.
  6. The ‘i’ key should put lighting into fragment shader mode.
  7. The ‘u’ key should turn texturing off for any of the lighting modes (so you can see the difference in lighting).
  8. For texturing, it should work in all three modes using a modulate texture function (you have to write it for shader code).
  9. You must turn in documentation as in the other assignments where you document any and all design choices made.
  10. It is fine to use the read/compile/link code from the GLSL zip file on the web page.  Do not copy other code.

 

Debugging shader code is hard, the print (cout/printf) command for debugging shader code is to write specific colors and then examine the resulting image with GIMP/Photoshop/etc.  It’s not simple.

 

For shader access, I suggest installing and using GLEW which provides the missing functionality for Windows.

It may or may not be necessary for OS X or Linux.  If this is confusing, let me know but you can download it from source forge.  The issue is that Windows uses old OpenGL API and you’ll get undefined functions for shader code.

 

Output

The program should draw its output to an OpenGL window of size 512x512 as in the example program. You should use a perspective projection in this assignment. hint: use gluPerspective to set the PROJECTION matrix stack

 

Submission

use the handin routine in the CADE Lab. You can with zip or tar your solution. You should comment your code appropriately and hand in a web-page that will serve as complete documentation. Please include a paragraph of difficulties and a paragraph of what you learned in this assignment.

The handin name for this lab is "lab4".

Windows users should use the Zip utility and handin a single zipped file. Unix users should use the tar program to do the same. We will recompile the programs to grade them. Make sure your workspace/program will compile for us. That is, be careful about your user-specific pathname variables! If you do this on a home machine, please allow sufficient time for porting to the CADE machines. We will grade based on compiling and running on the CADE machines.

Due to a bug in the handin program, do not include spaces in the names of the files that you submit, otherwise we will not receive them. For instance, "no spaces.txt" is not a valid filename and would not be received, while "no_spaces.txt" is valid. Please keep this in mind while handing in your assignment.