07 Surfaces and light
Normals: which way a surface faces
Encode the surface’s facing as an RGB colour.
-3.143.14
Exercise
Runs once per pixelDrag numbers, or edit the code
JS side
gl.uniformMatrix4fv(uModel, …) // rotation 0.50 / 0.35A normal is a direction the surface faces, not a position; mapping −1…1 to 0…1 lets you see it as colour.
Try it
- Turn the cube: what colour is the face pointing at you?
- Delete * 0.5 + 0.5: negative directions turn black