CS 248: Introduction to Computer Graphics

Pat Hanrahan


Assignment 4

Handed out: Thursday, February 26, 1998
Due: 5pm, Tuesday, March 10, 1998

Note: Late days cannot be used for this assignment since we need to grade it right after the due date in order to turn in final grades on time. If you need to take more time, we will need to turn in an incomplete for your final grade; please send e-mail to Prof. Hanrahan to arrange this.

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 (ie. texture coordinates). Using 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 six shaders:

Surface Shaders (16 points each, 64 points total):

Light shaders (18 points each, 36 points total)

Extra Credit

For extra credit, you can implement additional shaders. Two well-done interesting shaders are worth ten extra points. Less interesting shaders are worth fewer points. Here are a few suggestions; if you have other ideas, please send mail to cs248@graphics to make sure your idea is ok.

Surface Shaders


Submitting

To submit this assignment, you need to do two things:
Copyright © 1997--1998 Pat Hanrahan