Assignment #2 -- Basic Shading
Due Date
This assignment is due at 11:59pm on Monday, September 25th. Projects
turned in late will lose points as described in the policies
handout. This assignment should be done alone or in pairs. You may
share ideas with other groups, but you may not share code.
This assignment is worth 53 points.
SUBMISSION DETAILS
You may develop on Unix, OS X, or Windows. The platform you
use will be the one used to grade assignments. Keep in mind that
there are slight variations due to OS versions, different libraries,
and other factors, so you should verify that your code runs on the
instructional machines appropriate for you plat form choice.
We will be using the submit software for submission of this
assignment. Refer to Assignment #0 for instructions on how to use this
software.
You should include a README file that at the
minimum contains the following data:
-
Your (and your partner's) name,
-
The platform your code runs on,
-
The location of your source code (i.e. indicate who in your group has
done the submission, and on what platform). Only one of the people in
your group should submit the actual code. The other people should
only submit the README file.
All files needed to compile your code should appear in the submitted
directory. It is your responsibility to make sure that they will
compile and run properly.
Windows: The grader should be able to recompile your program by
simply opening the project and rebuilding it from scratch.
Unix and OS X: The grader should be able to recompile
your program simply by typing "make".
Do not wait until the last minute to start this assignment. This
assignment should be easy, but it may also be your first experience
coding for graphical output. Assume the unexpected and give yourself
time to deal with it.
Check the news group regularly for updates on the assignment or
other clarification. We will assume that anything posted there is
henceforth known to all.
You should also update your class web page to include images
generated by this code. If you like, you may write code to output
image directly from your software, or you can use screen shots. This
class has graders so the Professor generally does not see assignments
unless there was some issue in grading them that required his
attention. He does, however look at the web pages. If you don't post
anything there then he can only conclude that you did not do the
assignment or that your results were too poor to post. It is also a
nice place to show off your work to others in the class.
Overview
For this assignment, you will write a program that:
- Opens a window that contains an OpenGL rendering area.
- Displays a circular shape that will be shaded using the Phong
Illumination Model for point and directional lights.
- The circular shape should occupy most of the window. If the
window is resized it should update the display so that the shape
still occupies most of the window and is still round.
- When space bar is pressed the program should exit.
You program will take a series of command line options:
- -ka r g b
This is the ambient color coefficients of the
sphere material. The parameters r g b are numbers between 0 and 1
inclusive.
- -kd r g b
This is the diffuse color coefficients of the
sphere material. The parameters r g b are numbers between 0 and 1
inclusive.
- -ks r g b
This is the specular color coefficients of the
sphere material. The parameters r g b are numbers between 0 and 1
inclusive.
- -sp v
This is the power coefficient on the specular term.
It is a number between 0 and max_float.
- -pl x y z r g b
This adds a point light to the scene. The
x y z values are the location of the light. The r g b values are
it's color. Note that the x y z values are relative tot he sphere.
That is, the center of the sphere is at the origin and the radius of
the sphere defines radius one. The Y direction is UP, the X
direction is to the right of the screen, and the Z direction is "in
your face." The r g b value are between 0 and max_float, NOT
between 0 and 1.
- -dl x y z r g b
This adds a directional light to the scene.
The x y z values are the direction that the light point in. The r g
b values are it's color. See -pl for coordinate system notes.
There may be up to 5 point lights and 5 directional lights in a
scene. The r g b values of 1.0 should be mapped to a display values
of 255.
All command line arguments are optional. The default values
should be a black sphere with no lights.
Optional features that you can implement for extra credit are:
- Anisotropic diffuse or specular shading
- Writing image a JPG file instead of to the screen. (Default
would still be to the screen, but an optional command line argument
would cause no OpenGL window to be open and file output instead.)
- Some sort of "toon" shading.
- Other shapes besides spheres.
- Multiple spheres that can shadow each other.
Other features should be clearly documented in your README file.
They should be implemented through additional command line options.
The behavior of the arguments specified in as required for the
assignment should not be changed. Your README file should explain
what your optional features are and provide example command
invocations that produce nice results.
The TAs have provided some example code to start with. You may
use this code if you like or you can start from scratch. If you chose
to use the TAs' code then you are responsible for figuring out how to
use it. If there is a bug in that code, please bring it to the
attention of the TAs immediately. Please be advised that even if
there is a bug in their code do not assume that you will be allowed to
turn in the assignment late.
Questions should be posted to the news group