Local lighting, depth buffering and basic shader coding.
Due: by class time Nov. 19.
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
- 30% Render the triangles (in obj file) using shaders, in white
- 40% Render the triangles (in obj file) using shaders, with Blinn-Phong illumination and Phong shading
- 20% Render the triangles (in obj file) 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!
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: 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 2: 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 3: 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.