Overview
In this project you will implement the OpenGL lighting model in 3 ways:
first, by making the necessary calls to OpenGL to use its built-in
lighting computations; second, by computing the OpenGL lighting model
in software and passing the results to OpenGL in the form of
pre-computed vertex colors; and last, by implementing lighting
calculations in OpenGL Shading Language (GLSL), making use of
programmable graphics hardware. You will finish up by writing a
few other shaders in GLSL.
You are given support code for this project and will need to
- link to the jot library
(the same as for project 1),
- copy the project support code and edit the makefile to indicate jot
installation information, and
- implement the missing functionality.
For more information about
jot, see
the instructions given in
project 1.
Support Code
Copy the project support
code to your local machine using one of the following commands:
Remote session for Linux/Unix/SunOS/MacOS users:
% scp -r red.engin.umich.edu:/afs/engin.umich.edu/class/perm/eecs487/proj2 .
OR
% rsync -av -e ssh red.engin.umich.edu:/afs/engin.umich.edu/class/perm/eecs487/proj2 .
Windows users can use set up an sftp session to red.engin.umich.edu and
grab the files from the above path or, on (CAEN) machines with AFS
mount, copy the files from:
K:\perm\eecs487\proj2
The C++ source code files are:
p2.C,
shaders.H and
shaders.C. The GLSL shader
files are:
simple.vp,
simple.fp,
lighting.vp, and
lighting.fp. Read through these
files to get
familiar with them, then implement the following missing functionality:
OpenGL lighting:
- Implement the OGLShader
class that has been partially defined for you. Fill in the parts that
setup OpenGL state for rendering smooth shaded triangles with lighting
enabled. Use the set of lights and their parameters that are stored in
the VIEW class. Set the
material properties in OpenGL according to the values stored in the Patch class (via its APPEAR base class). The
comments in the provided code skeleton provide further information.
[Note:
the provided code does produce a rendered result that seems somewhat
correct. That is because your main tasks (defining the lights and
setting material properties) are already being done elsewhere in jot.
However, they are not being done according to the project 2 spec! So
implement the requested functionality in the OGLShader class, which will
supersede the incorrect jot implementation.] 20 points.
Software lighting:
- Implement the OpenGL lighting model in software by completing the
definition of the SWShader
class. Compute the color of each vertex by taking into account the
material properties of the Patch
containing the vertex, as well as the global ambient light and the
ambient, diffuse, and specular contributions of each of the active
lights. Handle directional lights, point lights and spot lights. Follow
the equations given in the red book (our text: The
OpenGL Programming Guide) except that instead of using the halfway
vector for specular lighting, use the actual reflection vector, as
discussed in class. 20 points.
GLSL: (Note: for this part you need
OpenGL 1.5 or 2.0.)
- Implement the OpenGL lighting calculations in GLSL shading
language. Specifically, fill in the missing functionality in the file lighting.fp (a GLSL fragment
shader). The provided vertex shader lighting.vp should be modified
to compute a varying variable that represents the vertex position in
eye space. The OpenGL code for loading the shader is provided in shader.C. As in the software
case,
use the reflection vector (not halfway vector) when computing the
specular light contribution. The only difference is that this
time you will interpolate normals within triangles, resulting in Phong
shading. 20
points.
- Implement a toon shader via a simple vertex program. [We will
provide more specific instructions on this shortly.] 10 points.
- Implement a shader of your choice. For this, students can take
ideas from books or online resources, and share ideas and code on the
phorum, but what you turn in should have some original content. (Please
make clear in comments which parts came from elsewhere.) [We will
provide more specific instructions on this shortly.] 10 points.
Lighting design:
- Render an interesting picture and show it to the class. Choose a
model (or models), and design a lighting setup (by modifying the
lighting setup currently implemented in p2.C). Render the scene in any
of your shaders, with the goal of making a nice picture. Grab the
image, then post the picture on the phorum as an attachment. Please use
the thread dedicated to project 2 images. You can post multiple images
(as long as they are good :) You are free to find models
elsewhere (or make them). Sharing models with classmates is encouraged.
[Note: lighting design is hard!] 5
points.
Write-up:
- Described below. 5 points.
Code quality:
- Comment your code reasonably, particularly your design decisions
and choice of approach.
- Modularize your code: use a suitable number helper functions with
descriptive names.
- Use descriptive variable and function names: apply a suitable
tradeoff between symbol-length and descriptiveness.
Bottom
line: Make your code readable!
10
points
Building and running the
code:
Edit the provided Makefile to define the path to your jot directory.
[On Windows, you must use a DOS prompt, and you must first run the
setup.bat script in your jot directory.] Then you should be able to
compile the program, as follows:
% cd proj2
% make
This results in an executable named
p2 which takes model files as
command-line arguments.
Models
A CVS repository of models has been set up on CAEN servers. To check
out your own copies of the models, do the following:
% cvs -d
:ext:<your-uniqname>@red.engin.umich.edu:/afs/engin.umich.edu/class/perm/eecs487/cvsroot
checkout -P models
Students are welcome to share models with the class by checking
them into the repository. (Use binary mode in cvs:
cvs add -kb
mesh.obj). Please stick to model files that are in the public
domain
(or that you made yourself). Currently jot can read .obj files as well
as native jot .sm files. Many 3D model formats can be converted to obj.
A copy of the models directory is also available on CAEN for those who
don't want
to check out their own copies. The path is:
/afs/engin.umich.edu/class/perm/eecs487/models/ [Linux etc]
K:\perm\eecs487\models
[Windows]
Handing in
Copy all your project files (no models) to
/afs/engin.umich.edu/class/f05/eecs487/submit/<your-uniqname>/p2/
[Linux users]
K:\f05\eecs487\submit\<your-uniqname>\p2
[Windows users]
For submission from a remote,
non-CAEN machine you can scp or sftp your files to the respective paths
on red.engin.umich.edu
Your files should include your modified
p2.C, shaders.H
and
shaders.C, files
containing your GLSL vertex and
fragment shaders (including your implementation of toon shading, your
own shader, and
lighting.fp
and
lighting.vp), and a
brief write-up in
PDF
format that discusses:
- anything about your
implementation that is noteworthy, and
- feedback on
this assignment, including suggestions for how it should be changed
next time.
Bottom line: typing
make on the command line should
compile without errors and link to the central JOT installation in
/afs/engin.umich.edu/class/f05/eecs487/jot
OR
K:\f05\eecs487\jot
Modify your Makefile accordingly before
submission!
Test the compilation when you
submit!
Multiple
submissions:
- You are allowed to overwrite your files in the above directory as
many times as you want.
- If the timestamp on these files is past the deadline your
submission will be considered late.
- Test this submission procedure and please let the GSI know well
in advance if you encounter and problems.
Due date
The project is due on October 12, 2005, by 11:59pm. Turning it in 48
hours earlier is worth a 4% bonus; turning it in 24 hours early is
worth a 2% bonus.
Last updated: 07 Oct 2005