Program (extra credit): due December 15

Due: during final period December 15. This entire assignment is optional extra credit.

GOAL:

In this assignment you will learn the basics of OpenGL shader coding by implementing phong and toon illumination with GLSL shaders.

BASIC GRADING:

The components of this assignment will be graded as follows:

  • 10% Properly turned in assignment
  • 30% Render input triangles using vertex shaders for the view transform, in white
  • 40% Add Blinn-Phong illumination to the fragment shaders
  • 20% Add interactively activated toon shading to your fragment shaders  
  • Participation credit: You can receive participation credit (outside of this assignment) for posting your result, good or bad, on the class forum!

General notes:

You need only display one image. As you progress through the assignment, you can use any improved image to replace the previous (e.g. don't show parts 1, 2 and 3, just 3).

All vertex locations should be described in world coordinates, meaning they do not require any transformation. Locate the eye at (0 0 -2), with a view up vector of [0 1 0] and a look at vector of [0 0 1]. Locate the front clipping plane a distance of 1 from the eye, and the back clipping plane a distance of 3. You may assume that the viewing window is a 2x2 square centered on the front clipping plane, and aligned with world the coordinate axes. With this scheme, you can ensure that everything in the world is in view if it is located in a 2x2x2 box centered at the origin. Use perspective projection. Put a white (1,1,1) light at location (0,5,0). Use obj files from previous assignments.

Part 0: Properly turned in assignment

Turn in both an executable and source. Your assignment should run without any missing libraries, and compile without any missing references. Submit a readme.txt file if there is any configurable behavior. If you wish to claim any extra credit, list those claims in the readme file, along with any needed details.

Part 1: Render using vertex shaders for the view transform, in white

Transform and project each vertex in a vertex shader. For each fragment, assign it a white color. Don't worry about colors, normals, or depth.

Part 2: Add Blinn-Phong illumination to the fragment shaders

As above, but for each fragment, calculate and output the Blinn-Phong color.

Part 3: Add optional toon shading to your fragment shaders 

As above, but for each fragment, apply simple toon shading when the "t" key is pressed. Toon shading quantizes Blinn-Phong results to create an inked look. Blinn-Phong shading reappears when the key is pressed again. No need for inked contour lines yet.

EXTRA CREDIT GRADING:

Extra credit opportunities include the following, with others possible with instructor approval:

  • 5% support arbitrarily sized images (and interface windows)
  • 5% support multiple obj files and arbitrary modeling coordinates
  • 5% support arbitrary viewing setups
  • 5% support off-axis and rectangular projections
  • 5% support multiple lights at arbitrary locations
  • 15% add texture mapping
  • 15% add inked contouring
  • 25% add a mode that uses BSP trees for occlusion rather than z-buffering.

Arbitrarily sized images and interface windows

Read in an additional window.txt file that one line, lists the width and height of the interface window. Size your interface window to match, and change the aspect ratio of the viewing window to match.


Multiple obj files and arbitrary modeling coordinates

Read in an additional world.txt file that on each line, references an obj file and its associated modeling transform (a 4x4 matrix). Read in, transform and display all the named obj files before rendering them.


Support arbitrary viewing setups

Read in an additional view.txt file that lists the eye's location, the view up, and the look at vectors, each on a different line. Render the scene with these viewing parameters. Note that with bad viewing parameters, you will not see the model.


Support off-axis and rectangular projections

Read in an additional project.txt file that lists the viewing window's top, right, bottom and left Y, X, Y, and X coordinates (four numbers) on one line. Render the scene with these new projection parameters. Note that if you also perform the arbitrary viewing extra credit, these coordinates may not be in world space! Also with bad projection parameters, you will not see the model. Finally, note that your viewing window's and interface window's aspect ratios may not match, if you implement both extra credits.


Multiple and arbitrarily located lights

Read in an additional lights.txt file that on each line, describes the location and color of a light (use one triple for a light's color, with its ambient, diffuse and specular colors the same). Render the scene with these lights.


Add texture mapping 

Using materials and texture coordinates, map textures onto some of your models, and display them. Make sure to blend lighting and texture colors so that you can see the effects of both.


Add inked contouring

Add the inked contouring often used with toon shading  as described here, so that model silhouettes have dark outlines.


Use BSP trees for hidden surface removal

Turn off z-buffering, build a BSP tree, then in each frame, traverse it to produce a depth sort. Render the triangles in that order.