CS 248: Introduction to Computer Graphics

Assignment 4


Handed out: Tuesday, November 17, 1998
Due: 5 pm, Tuesday, December 1, 1998

Note: In order to give us time to grade your assignment, the last day to turn in this assignment late will be Friday, December 4, 1998, at 5 pm. Please contact Prof. Hanrahan if you find that you will not be able to make this deadline.

Overview

This assignment is designed to familiarize you with illumination and shading models used in computer graphics. In this project, you will implement functions that describe how a surface appears in given lighting conditions. Your functions will be integrated into a interactive viewer that we provide for you. Your shading function will be evaluated at many points on the surface.

Many graphics systems such as OpenGL have a fixed illumination model that describes how objects will appear in given lighting conditions. In the case of OpenGL, this illumination model is expressed as a formula. You have some ability to modify how this formula behaves by changing parameters of this formula, such as the material properties of the object being displayed and the color and position of the lights in the scene.

A more general approach to illumination is to allow a user-defined function to be called whenever the color at a particular point on the surface needs to be computed. This function (a surface shader) has access to information about the scene such as the location of the point on the surface being illuminated, the location of the light sources, the properties of the surface, and the parameterization of the surface (i.e. texture coordinates). With this information, the function computes the color of the point on the surface using some model of how lighting in the environment interacts with the surface.

You can also think of calling a shading function (called a light shader) every time you need to know the color of a light in the scene. This allows you to implement lights whose intensity or color changes based on the outgoing light direction. It also allows you to write a light shader that simulates a mask in front of the light source as follows: every time you call the light shader, the ray from the point on the surface being illuminated to the light source is intersected with the mask. If the ray passes through an "open" part of the mask, the point on the surface is illuminated. Otherwise, it is left in darkness.

What you need to do

First, start by reading the online guide we wrote to getting started on this assignment, which is linked off of the class Web pages. Then, you need to implement the following seven shaders:

Surface Shaders (50 points total)

Light shaders (50 points total)

All of your shaders must be implemented in the file shader.c, and you must include one configuration file for each of your shaders. Please name your configuration files so that it's obvious which configuration file goes with which shader, and please comment your configuration files so we can figure out how the various shader parameters you placed in these files affect the rendered output.

You must also prepare an image for each of your shaders and put them on a web page. For each shader, save a PPM file from the viewer, then copy these files to your WWW directory and make a small web page with links to the images. Include a URL for this web page in your README file, and please verify that the links to images are actually correct. Please do not assume that we will go hunting down your web page. We will take off 5 points if the URL is not in your README file.

When grading your shaders, some of the criteria we will be looking at are:

Please take these criteria into consideration when writing your shaders. Also, please make sure to check the Assignment 4 FAQ every so often. You are responsible for any information given there.


Extra Credit

For extra credit, you can implement additional shaders. The shaders should model real surfaces or real lighting effects. For example, you might pick a surface from your room, from outside your window, or from our page of sample real-world surfaces. You should clearly document your extra credit shaders in your README file, including a description of what each shader models and what choices you made while implementing each shader.

Two interesting, well-done shaders are worth a maximum of 10 extra points. The more interesting and convincing your shaders are, the more points will be awarded. Please do not hesitate to e-mail cs248@graphics if you have any doubts as to how interesting a particular shader is.


Submitting

To submit this assignment, you need to do two things:
CS248: Introduction to Computer Graphics, Pat Hanrahan, Fall 1998