More Lighting in OpenGL

Tom Kelliher, CS 320

Apr. 20, 2011

Administrivia

Announcements

Assignment

Read 8.7-8.9 (texture mapping).

From Last Time

Light lab.

Outline

  1. Walk-through code.

  2. Lab.

Coming Up

Texture mapping.

Code Walk-Through

  1. Lines 13-24: The experiments.

  2. Lines 76-78: Disable all lighting to render the sphere representing the moving light as a 2-D object.

  3. Lines 143-144: Disable and enable the fixed spotlight.

  4. Lines 210-216: Specifying GL_LIGHT1's position here, before the call to gluLookAt() results in the light being positioned in eye coordinates.

  5. Line 227: glLightModel*(pname, param):
    1. This call correctly computes specular reflections by correctly determining the viewer angle. Otherwise, the viewer is assumed to be at infinity and the view angle will be along the -z axis.

    2. Other pnames:
      1. GL_LIGHT_MODEL_AMBIENT: Set global ambient parameters.

      2. GL_LIGHT_MODEL_TWO_SIDE: Set to !0 to enable two-sided lighting using back material parameters.

    For details, RTFM.

  6. Lines 228-230: Note that lighting and individual lights are enabled separately.

Lab

Refer to source code.



Thomas P. Kelliher 2011-04-19
Tom Kelliher