Material and Lighting (2)
Plan
- Recap last time, using
tutors/lightmaterial and answer
questions.
- Look at
twColor() and twGrayLight in TW.py
- Discuss next homework (creative scene)
- (10) lab exercise using materialTutor2, which uses TW's restricted API
for material and lighting. You can still use the more powerful stuff!
- Defining surface normals. Why and how. Look at
twSolidBarn() in TW.py
- (30) lab exercise on material and lighting
- (20) If there's time, we'll discuss issues of material and lighting, using demos
- diffuse versus specular demo
- flat versus smooth shading
- directional versus positional lights
- zero ambient light
- spotlights, and lighting big quads
- (if time) Second exercise on the more powerful OpenGL material and lighting API.
Exercise
Today, I want you to create a gray light illuminating a slightly bluish
sphere and a slightly greenish triangle. We'll proceed in steps.
- I suggest starting with the material-and-lighting/TeddyBearLit.py
code. Copy it to
light-lab.py
- Remove the bear code and expand the bounding box some, so you can
work with reasonable size numbers.
- First, get gray light falling on a blueish sphere. You'll know you've
succeeded when the sphere looks the right color.
- Adjust the position and direction of the light so that you get a nice
specular highlight on the sphere. Use smooth shading so that it looks
nicer.
- Now, make the triangle. We save the triangle for last because we need
to be sure to remember the surface normal (the sphere automatically has
them) and because we have to worry about which side of the
triangle we're viewing. The triangle should be angled so that neither the
eye nor the light are hitting it perpendicularly. First make the triangle
white, then adjust the color.
- The result of phase 1 might be:
- Try making the light pinkish.
- If there's time:
- Experiment with global ambient.
- Experiment with the shininess of the sphere so you can see the specularity
Demos
Next time, we'll look at the following issues and demos:
Exercise Solution
Here is a solution
to the exercise. The goal is not to duplicate mine exactly, but to
gain control of the tools of material and lighting.
Written by Scott D. Anderson
scott.anderson@acm.org

This work is licensed under a Creative Commons
License.