07 Surfaces and light
dot: the simplest lighting
The more a surface faces the light, the larger the dot product, the brighter it is.
-22
-22
00.5
Exercise
Runs once per pixelDrag numbers, or edit the code
JS side
gl.uniformMatrix4fv(uModel, …) // rotation -0.35 / 0.10The dot of two unit vectors is the cosine of their angle; max(dot(N, L), 0) is Lambert diffuse lighting.
Try it
- Move the light behind the object
- Set ambient to 0: the unlit side goes fully black