Lambertian shading

Figure 7.2: In the Lambertian shading model, the light reaching the pixel depends on the angle $ \theta $ between the incoming light and the surface normal, but is independent of the viewing angle.

Now consider lighting each pixel and recall the basic behavior of light from Section 4.1. The virtual world simulates the real-world physics, which includes the spectral power distribution and spectral reflection function. Suppose that a point-sized light source is placed in the virtual world. Using the trichromatic theory from Section 6.3, its spectral power distribution is sufficiently represented by R, G, and B values. If the viewing ray hits the surface as shown in Figure 7.2, then how should the object appear? Assumptions about the spectral reflection function are taken into account by a shading model. The simplest case is Lambertian shading, for which the angle that the viewing ray strikes the surface is independent of the resulting pixel R, G, B values. This corresponds to the case of diffuse reflection, which is suitable for a ``rough'' surface (recall Figure 4.4). All that matters is the angle that the surface makes with respect to the light source.

Let $ n$ be the outward surface normal and let $ \ell $ be a vector from the surface intersection point to the light source. Assume both $ n$ and $ \ell $ are unit vectors, and let $ \theta $ denote the angle between them. The dot product $ n \cdot \ell = \cos\theta$ yields the amount of attenuation (between 0 and $ 1$) due to the tilting of the surface relative to the light source. Think about how the effective area of the triangle is reduced due to its tilt. A pixel under the Lambertian shading model is illuminated as

\begin{displaymath}\begin{array}{l} R = d_R I_R \;\mbox{max}(0,n \cdot \ell)  ...
...\ell)  B = d_B I_B \;\mbox{max}(0,n \cdot \ell) , \end{array}\end{displaymath} (7.1)

in which $ (d_R,d_G,d_B)$ represents the spectral reflectance property of the material (triangle) and $ (I_r,I_G,I_R)$ is represents the spectral power distribution of the light source. Under the typical case of white light, $ I_R = I_G = I_B$. For a white or gray material, we would also have $ d_R = d_G = d_B$.

Using vector notation, (7.1) can be compressed into

$\displaystyle L = d I \;$max$\displaystyle (0,n \cdot \ell)$ (7.2)

in which $ L = (R,G,B)$, $ d = (d_R,d_G,d_B)$, and $ I = (I_R,I_G,I_B)$. Each triangle is assumed to be on the surface of an object, rather than the object itself. Therefore, if the light source is behind the triangle, then the triangle should not be illuminated because it is facing away from the light (it cannot be lit from behind). To handle this case, the max function appears in (7.2) to avoid $ n \cdot \ell < 0$.

Steven M LaValle 2020-01-06