Lab 4: Lighting, Normals and Color Ramps
CS 445: Computer Graphics, Fall 2008


[previous lab][schedule][next lab]

Goals


Practice - Lighting and Shading the Teapot

This part is intended to give you practice using lights and materials. There is nothing to turn in. Create a simple JOGL project with a camera pointed at a teapot or other glut object (glut objects include normals so you don't have to worry about adding them yourself). Experiment by trying the following:

Lighting, Color Ramps, and Calculating Normals for Terrains

Copy over the Netbeans project FractalLandscapeSimple located on enfuzion. The DrawFractal method should look like the familiar JOGL event handler Code. The FractalLandscape code generates vertices for a fractal landscape. The vertices are stored in the array vertices[][][]. The landscape is basically a rectangular grid in the x-z plane with varying height values (y-values). if you run the code, you will find that the landscape is just white as shown here:

It looks this way because there are no lights or colors, and the normals are not set properly Your job is to do the following:

  1. Add lights (in the initLighting() method in the class DrawFractal)
  2. Fix the calculation of the normals (in the calcNormals() method in the class FractalLandscape)
  3. Add a color ramp so that that it looks a bit more like a landscape. The color ramp should be based on the height of the landscape (in the calcColor() method in the class DrawFractal). For example, your color ramp should transition from blue for the water up to white for snow.

Below are what the above changes should give you.
Lights addedNormals fixedColor Ramp added

Note, if you are interested in the diamond-square algorithm used for generating the terrain, go look at the web page Generating Random Fractal Terrain.

Deliverables: By class time on Tuesday, Nov 4: Place the jar file of the final version (with lights, normals and color ramp) on enfuzion. Email the corresponding zipped project code to gorr. Be prepared to discuss in class what you discovered.


[top]  [Schedule]  [Home]