CSC 240: Computer Graphics

Lab 10: Lighting in OpenGL

The goal of this lab is to understand how simple lighting models work in OpenGL and how light sources can be animated to create lighting effects. We will also practice pair programming again!

Note: this lab will not be graded, but it will help us get ready for the solar system homework.

  1. Download lab10.py and make sure you can run
    python lab10.py 
    You should see a "sphere" that looks something like this:

    moon1

    The sphere is lit by ambient lighting only.

  2. Comment out the ambient lighting in the code and comment in the diffuse lighting and lighting position code. You should see a sphere that looks like:

    moon2

    Comment in the ambient lighting as well to achieve both effects:

    moon3

  3. Maybe that is too much ambient lighting. Turn down the ambient lighting and make some modifications to achieve a red moon like this:

    moon4

  4. Finally, change the position of the light in an animation to make the moon look like it's waxing and waning (like phases of the moon).