Illumination Models
Illumination models calculate how light interacts with surfaces. The Phong reflection model is the most widely used local illumination model, consisting of ambient, diffuse, and specular components.
Phong Reflection Model
I = Ia*ka + kd*(L·N)*Id + ks*(R·V)^n * Is
Components:
Ia*ka = Ambient light
kd*(L·N)*Id = Diffuse reflection
ks*(R·V)^n * Is = Specular reflection
Variables:
I = final intensity
Ia = ambient light intensity
ka = ambient reflectance coefficient
kd = diffuse reflectance coefficient
L = light direction (toward light)
N = surface normal
Id = light intensity
ks = specular reflectance coefficient
R = reflection direction
V = view direction (toward camera)
n = shininess exponent
Is = specular light intensity
Ambient Light
Simulates indirect illumination by adding a constant base color. This prevents shadowed areas from being completely black.
Ambient = ka * Ia
ka: material ambient coefficient (0-1)
Ia: ambient light color/intensity
Example: dark blue ambient
ka = 0.2, Ia = (0.1, 0.1, 0.3)
ambient = 0.2 * (0.1, 0.1, 0.3) = (0.02, 0.02, 0.06)
Diffuse Reflection (Lambertian)
Simulates matte surfaces. Light is scattered equally in all directions. The intensity depends on the angle between the light and surface normal (Lambert's cosine law).
Diffuse = kd * max(0, L·N) * Id
L = normalize(light_pos - surface_pos)
N = surface normal
L·N = cosine of angle between light and normal
Example:
L = (0, 1, 0) (light from above)
N = (0, 1, 0) (surface facing up)
L·N = 1.0 (maximum diffuse)
N = (0.707, 0.707, 0) (45° tilt)
L·N = 0.707 (reduced diffuse)
Specular Reflection
Creates bright highlights on shiny surfaces. Depends on the viewing angle and is concentrated around the perfect reflection direction.
Specular = ks * (R·V)^n * Is
R = 2*(L·N)*N - L (reflection direction)
V = normalize(camera - surface)
n = shininess (higher = tighter highlight)
n = 10 → broad, dull highlight (plastic)
n = 100 → sharp, bright highlight (metal)
n = 500 → very sharp highlight (mirror)
Blinn-Phong variant (more efficient):
H = normalize(L + V) (halfway vector)
specular = ks * (N·H)^n * Is
Light Sources
Point Light:
L = normalize(light_pos - surface_pos)
Intensity falls off with distance:
I = I0 / (kc + kl*d + kq*d²)
Directional Light:
L = constant direction (sun)
No distance attenuation
Spot Light:
Adds cone angle constraint:
intensity *= dot(-L, spot_dir) > cutoff ? 1 : 0