Programming assignment #4 - Phong shader

CS 248 - Introduction to Computer Graphics
Spring Quarter, 1995
Marc Levoy
Handout #14

Demos on Monday, June 12

Writeups due on Tuesday, June 13 by 5:00pm

Your assignment is to extend the Z-buffer renderer you implemented in project #3 to include Phong illumination, Phong interpolated shading on triangle meshes, and texture mapping.

Required functionality

  1. Phong interpolation and illumination. During scan conversion of each triangle, calculate pixel colors using the Phong illumination model (section 16.1 in the textbook) and, for triangle meshes, the Phong normal vector interpolation method (section 16.2.5). Implement an infinite viewer and one infinite (i.e. directional) light by using the same viewing vector V and the same one lighting vector L at all pixels as discussed in class. For a tutorial on these calculations, refer to the set of online notes entitled "Shading computations for project #4".

    Use the lighting information and material properties provided by Composer, which is documented in /usr/class/cs248/support/include/scene.h. Note that this formulation differs slightly from equation 16.20 in the textbook. To facilitate debugging when an SGI workstation is not available, we suggest providing sliders to manipulate some or all of these variables, especially lighting direction (not required and no extra credit given). For properties not provided by Composer (e.g. Fatt), assume something reasonable or provide your own slider(s) to specify them. Properties provided by Composer but not relevant to your renderer (e.g. transparency) may be ignored.

  2. Texture mapping. The shading calculations for at least one triangle must include a texture. Applying a texture to a triangle consists of four steps:

Submission requirements

We will follow the usual demo and submission procedure. No late demos this time! Writeups are due by 5:00pm on Tuesday, June 13! The assignment will be graded on correctness (60 points), efficiency (10 points), creativity (10 points), programming style (10 points), user interface (10 points).

Your program must be capable of reading the files output by Composer, as in assigment #3. We may or may not provide grader data files for this assignment. Regardless, be prepared to show one or more precomputed images that include at least one triangle mesh with interpolated shading. Images should be antialiased using your supersampling as in assignment #3.

Provide an enable/disable option for displaying a visualization of the X, Y, and Z components of your surface normals at each pixel. We suggest three separate visualizations or one button-controlled visualization rather than mapping X, Y, and Z to R, G, and B. The latter is acceptable if you also provide button-control over which one of R, G, or B is displayed. We require this visualization both to help you debug your own program and to help us evaluate where your problems lie if any arise during the demos.

Working in teams

You may work alone or in teams of two or three. For a team of two, you must implement two of the following bells and whistles. For a team of three, you must implement five. Alternatives are acceptable if approved in advance. If you have completed the assignment and wish to earn extra credit, you may add more bells and whistles.

  1. Render a texture on a triangle mesh. In this case, you'll have to establish a mapping from sequences of vertices to appropriately spaced points in your input texture image. Use a mapping that is continuous across the mesh; don't simply copy the same texture onto every triangle. For generalized cylinders (like vases), such a mapping is easily derived by converting triangle vertex coordinates from Cartesian to cylindrical space, which can then be mapped to a 2D image.

  2. Support a local viewer and however many local (i.e. point) lights are given to you by Composer. This will require you to compute and normalize a new viewing vector V and lighting vector L at each pixel as discussed in class and in the online tutorial.

  3. Generate a solid texture that incorporates the Perlin Turbulence function (see page 1047 and plate IV.7 in the textbook). For additional details (and some inspiring pictures), see K. Perlin, ``Hypertexture'', Proc. Siggraph '89, p. 255, and K. Perlin, ``An Image Synthesizer,'' Proc. Siggraph '85. (Both are available at the library.)

  4. Dice triangles into micropolygons as described in the REYES paper (handout #11) and implement displacement mapping. Specifically, use a procedurally generated or interactively generated (i.e. painted) texture to modify the 3D coordinates of micropolygon vertices. See Plate II.37 in the textbook or Upstill's RenderMan Companion (available at the bookstore) for ideas.

  5. Implement texture prefiltering using mip maps or summed area tables as described in section 17.4.3 of the textbook to yield properly filtered textures even in severe perspectives and when triangles are rotated nearly on edge.

  6. Develop a language to specify shade trees. At minimum, the shade tree must include mix nodes driven by textures as in Cook (handout #12). Don't spend a lot of time on the interpreter - a simple syntax will do.

  7. Implement shadows using Lance William's Z-buffer-based shadow map algorithm (see L. Williams, ``Casting Curved Shadows on Curved Surfaces,'' Proc. Siggraph '78, pp. 270-274. Worth 2 bells. For even more credit, implement the improved algorithm described in W. Reeves, D. Salesin, R. Cook, ``Rendering Antialiased Shadows with Depth Maps,'' Proc. Siggraph '87, pp. 283-291.

  8. Any bell or whistle from assignment #3 that you have not already implemented. If you implemented a 3D paint program, extend it so that it creates a texture that is mapped to your mesh instead of just applying color at triangle vertices.

The competition

At 4:00pm on Monday, June 12, a judging will be held to select the best rendering. Participation in this competition is not required.

Entries may be made by individuals or teams, and may consist of any number of images or animations. You are allowed to use only i3dm, Composer, the renderer you wrote for this course, any modeling software you wrote for the course (e.g. procedural modeler or shading languages), and tools available on our SGI, Dec, or Sparc workstations. You may not use GL. If you wish to use other tools, you must obtain approval and be prepared to make them available to all competitors.

The jury will consist of prominent computer graphics experts from academia or industry. Your prof will preside. During the judging, each individual or team will display their entry and briefly explain any exotic techniques used in its creation. This process is expected to take approximately 45 minutes. The winning submission will then be decided in private by the jury and announced to the gathered multitudes.

While grades for the programming project are based solely on "technical merit", the competition will be judged on both "technical merit" and "artistic impression". In particular, the jury will look for photorealism, creativity, and elegance.

There will be one grand prize - an all-expenses-paid trip to Siggraph '95 in Los Angeles, August 7-11, one second-place prize - dinner for two at Il Fornaio in Palo Alto and a copy of the Siggraph '94 Film and Video Show on VHS videotape, and three third-place prizes - a copy of the Siggraph '94 videotape. If the grand prize is won by a team, it must be split among the team members. All other prizes will be duplicated as necessary to cover the team.

The party

Immediately following the render-off, there will be a party in the graphics lab and on the terrace outside Sweet Hall to celebrate the winner, your survival of this course, and the arrival of Summer. Refreshments will be provided.
Friday, 20-Feb-1998 15:46:51 CST