Date: Mon, 16 Dec 1996 22:10:44 GMT Server: NCSA/1.5 Content-type: text/html Last-modified: Fri, 09 Feb 1996 12:53:53 GMT Content-length: 6491 CS418 Lab 6

CS 418: Laboratory 6

Phong Lighting

Introduction.

In this exercise you will code the lighting equation as a series of compute statements. You will bypass the default illumination model which is built into the Image module. By doing this, you will be able to control lighting effects directly. For example, you will be able to define a spotlight or make the intensity of an object drop off with distance.


Procedure:

First you need to download several example files. To do this, click on each of the filenames shown below. When the text window opens, use the "save as" option to put the file in your own directory. Name each file with the same name as shown below.

The program LightTemplate.net implements a spotlight entirely within DX using compute modules. Ambient, diffuse and specular terms are each computed and added together to obtain the intensity of each point. Follow the flow of the program to see how the intensities are computed. For the initial program it is assumed that the light is at a finite distance from the objects, but the viewer is very far away in a direction V.

Some examples of the program's output are shown below. The first shows a spotlight oriented along the y-axis with a "width" of 3.0. (A width of 3.0 means (D dot L)^3.0.) The small white dot is an icon showing where the light is. The arrow is an icon showing the direction of the spotlight.

The next image is the same light position, but with the spotlight width=0.0 so that the light is omnidirectional. The bright spots on the surfaces near the light are due to a large (L dot N) in the diffuse term. Notice that the diffuse reflection has the color of the surface, while the specular reflection has the color of the light (white).

You can turn off the default shading in DX by collecting a single AmbientLight with the object you are rendering. An AmbientLight ingores normal information. All you see is the color defined for the object as if it were lighted from all directions uniformly. The example program constructs a surface, calculates the surface normals, then throws away the lighting information to produce an unshaded surface (because there is an AmbientLight module). The colors you calculate become the color of the objects in the image module. Note that you must use the Camera/Display module to show the image because the view-vector, V, must be available to the program. Do not use an Image module.Throughout this exercise, leave the viewing distance at infinity, that is, leave the Camera module perspective flag at 0.

Bugs as of 4/11/95


Questions/Writeup:

Be prepared to demo all of the functions specified in the first three bullets above: ambient lighting, diffuse lighting, light position, light directionality, and specular reflections of two kinds in one program. All interactors should be labeled, have appropriate ranges and step sizes and be in no more than two control panels. The code should be well documented and organized.

Be prepared to demo the flying light in a separate program.

  1. What seem to be the differences between the (R dot V) and (N dot H) specular lighting models in terms of the appearance of objects.

  2. Write the formula you used to make a surface more shiny at high angles.

  3. Write the formula you used to impelment a sharp cutoff spotlight.

Back to Main Page
Go to Lab 7


Last modified, 1/25/95, B.Land.
Copyright Statement