CS 248: Introduction to Computer Graphics

Pat Hanrahan


Assignment 4

Handed out: Tuesday, March 4, 1997
Due: 5pm, Thursday, March 13, 1997

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) You will submit the file shader.c that contains all of your shaders, plus a README file containing the description of your real-world surface shader, plus any other items you would like to point out to your graders. You will also prepare images that you have rendered using your shaders. Full submission details will be made available by email and on the Web page in the following week.

hanrahan@cs.stanford.edu
beers@graphics.stanford.edu

Copyright © 1997 Pat Hanrahan and Andrew C. Beers