Specular highlights
The shiny spot where a surface mirrors the light into the camera, from the reflected or the half vector.
Cards
One live example to tweak, learn and copy.
How it works
A glossy surface doesn’t scatter light evenly. Part of what hits it bounces off like a slightly blurred mirror, and you
see that part only where the mirror angle sends the light into your eye: a bright spot that slides across the surface
as you move. That spot is the specular highlight. Unlike diffuse light it depends on the viewer, so a shader needs the
direction toward the camera as well as the surface normalA unit vector perpendicular to a surface, pointing the way it faces. Lighting and Fresnel effects compare it with other directions. Normal A unit vector perpendicular to a surface, pointing the way it faces. Lighting and Fresnel effects compare it with other directions.
There are two classic ways to measure “how close is this point to the mirror angle”:
- Phong reflects the light direction about the normal with
reflectand compares the result with the view direction:pow(max(dot(reflect(-l, n), v), 0.0), shininess). - Blinn-Phong takes the half vectorThe unit direction halfway between the direction toward the light and the direction toward the camera. Where it lines up with the normal, the surface would mirror the light straight into the camera; Blinn-Phong highlights measure that alignment.Technique
Half vector
The unit direction halfway between the direction toward the light and the direction toward the camera. Where it lines up with the normal, the surface would mirror the light straight into the camera; Blinn-Phong highlights measure that alignment.
H = normalize(L + V)Sourcesbetween the light and view directions and compares it with the normal:pow(max(dot(n, normalize(l + v)), 0.0), shininess).
Both are a dot productMultiplies two vectors component by component and adds the results. For unit vectors it is the cosine of the angle between them, from 1 (same direction) to -1 (opposite). Dot product Multiplies two vectors component by component and adds the results. For unit vectors it is the cosine of the angle between them, from 1 (same direction) to -1 (opposite).dot(a, b) = |a| |b| cos θ
The highlight’s color says what the material is. Plastics, paint and other dielectrics reflect light without tinting it, so their highlight takes the light’s color while the diffuse part carries the paint. Metals tint the highlight with their own color and have almost no diffuse part. Physically based shading replaces the power curve with a microfacet distribution such as GGX and adds Fresnel and energy conservation, but the half vector stays at its center.
Further reading
- dot (opens in a new tab)Reference
- Dot product (opens in a new tab)Reference
- Basic Lighting (opens in a new tab)Article
- Normal (geometry) (opens in a new tab)Reference
- Normal Mapping (opens in a new tab)Article
- reflect (opens in a new tab)Reference
- refract (opens in a new tab)Reference
- Snell's law (opens in a new tab)Reference
- Blinn–Phong reflection model (opens in a new tab)Reference
- Advanced Lighting (opens in a new tab)Article
- pow (opens in a new tab)Reference
- normalize (opens in a new tab)Reference