Light & Normals
Move a light around a surface and watch the shading model respond, term by term.
What you should come away with: Why normals need the inverse-transpose, and what separates flat, Gouraud and Phong.
- light
- normals
The shading equation
N = normalize(normalMatrix * normal) L = normalize(lightDir) H = normalize(L + V) colour = base × (0.12 + 0.80 × max(0, N·L)) + 0.50 × max(0, N·H)^32
Normal matrix (inverse-transpose)
| 1.00 | 0.00 | 0.00 |
| 0.00 | 1.00 | 0.00 |
| 0.00 | 0.00 | 1.00 |
A normal is not a position: it describes an orientation, so it does not transform like one. Scaling a sphere flat in y makes its surface shallower, which means the normals must tilt up, not get squashed down with the geometry. The inverse-transpose is what encodes that. Under uniform scale it reduces to the model matrix, which is why the mistake is invisible until the day someone scales one axis.