Lighting and shading

Level UniversityDifficulty ★★★★★Application⌖ Open in the map

What is it?

Computing the colour of a surface point from the light, the normal and the viewer. Lambertian diffuse light is max⁡(0,n⋅l)\max(0, n\cdot l); specular highlights use (n⋅h)s(n\cdot h)^s. Values are interpolated across triangles.

Formulas

I=kdmax⁡(0,n⋅l)+ks(max⁡(0,n⋅h))s,h=l+v∥l+v∥I = k_d\max(0, n\cdot l) + k_s\big(\max(0, n\cdot h)\big)^{s}, \qquad h = \frac{l + v}{\norm{l + v}}
Blinn–Phong

The mathematics behind it

  • Dot product★★★★★fundamental

    Diffuse lighting is max⁡(0,n⋅l)\max(0, n \cdot l), the dot product of the unit normal and the light direction.

  • Trigonometric functions★★★★★frequent

    Lambert's law: diffuse light is proportional to cos⁡θ\cos\theta between normal and light direction.

  • Interpolation★★★★★frequent

    GPUs interpolate colours, normals and texture coordinates across each triangle (barycentric interpolation).

Where is it used?

Computing topics reachable from here, through the chain of ideas that leads to them:

What depends on it

This page has the essentials. A fuller treatment (intuition, formal definition, worked example) is on the way.

↑ ↓ to navigate · ↵ · Esc