In scene shading, a lighting direction vector points from a surface point toward a light source and is normalized to represent direction alone. Pair it with the surface normal vector in a dot product to estimate how strongly that point is illuminated. section 9.2.3
The dot product gives a practical lighting coefficient:
- Aligned vectors produce 1, representing maximum lighting. section 9.2.3
- Perpendicular vectors produce 0, so the surface receives no light from that direction. section 9.2.3
- Opposing vectors produce negative values, which are ignored for lighting because the light does not shine there. section 9.2.3
Shading a sphere
For each pixel, use the corresponding surface point, calculate the normalized vector from that point to the light, and take its dot product with the point’s normal. Applying the resulting coefficient to the object’s color creates shading that makes a projected sphere appear three-dimensional. section 9.2.3
Figure 9.9 Lighting in a point is determined by the dot product of the object’s normal vector and the lighting direction vector.
Use the figure to compare how the normal and lighting direction determine illumination at a point. section 9.2.3
