Assignment 3

Local lighting, depth buffering and basic shader coding
Due: by class time November 8 at this link.

Goal:

In this assignment you will learn the basics of OpenGL shader coding by implementing phong shaders with z-buffering in shader code.

Basic grading:

The components of this assignment will be graded as follows:
  • 10% Properly turned in assignment
  • 15% Render the triangles described in an obj file without shaders, in white
  • 15% Render the triangles without shaders, with z-buffering, Blinn-Phong illumination and Gouraud shading
  • 20% Render the triangles using shaders, in white
  • 30% Render the triangles using shaders, with Blinn-Phong illumination and Phong shading
  • 10% Render the triangles using shaders, with Blinn-Phong illumination, Phong shading and z-buffering 
  • 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). Yes, you can earn 40% without ever programming shaders.

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).

You may make your interface window only 256x256 in size. This will speed testing of your ray casting. We will test your program with the test cube, as well as several other obj files, some of which you can find here, others which you cannot.

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: Using OpenGL, render the triangles in white

Your program should read in the file input.obj. Your parser should not halt if it doesn't recognize a line, instead it should ignore it. You can ignore colors and normals for this part of the assignment. Render the triangles contained in the obj file in white.

Part 2: Using OpenGL, render lit triangles

You can now no longer ignore colors and normals, and need to worry about depth. Turn on depth buffering, local Blinn-Phong lighting, Gouraud shading. You should see the same triangles you rendered before, but with the same sort of lighting and shading you saw on the first assignment's triangle, with every triangle fragment having a slightly different color. You should also see occlusion.

Part 3: With shaders, render white triangles

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 4: With shaders, render lit triangles

As above, but for each fragment, calculate and output the Blinn-Phong color. No need to worry about depth.

Part 5: With shaders, render lit, occluded triangles 

As above, but for each fragment, calculate its depth and apply z-buffering.

Participation credit:

Please remember that you can get participation credit outside this assignment for posting your imagery, good or bad, on the course forum or Voicethread.

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
  • 25% add a mode that uses BSP trees for occlusion rather than z-buffering.

Extra credit: 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.

Extra credit: 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.

Extra credit: 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.

Extra credit: 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. 

Extra credit: 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. 

Extra credit: 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.

Extra credit: 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.