The Math of Computer Graphics
Math · Intermediate · Lesson 8 of 8

Light and Shade

Lighting with dot products

An interactive lesson with 8 steps, about 7 minutes: you predict, drag and solve, with instant feedback on every answer. It runs in your browser and needs JavaScript.

What you’ll learn

  • Lambert: matte brightness = max(0, n · l) = cos of the angle to the light.
  • Phong highlights: (r · v)^s, where r = 2(n · l)n − l.
  • Higher shininess s gives smaller, sharper highlights.

Steps

  1. The cosine law
  2. Lighting a sphere
  3. A dot product
  4. Half brightness
  5. Shiny highlights
  6. Ray tracing
  7. The reflected ray
  8. Just off the highlight