Oren-Nayer: physical, based on micro-facets, expensive
Isotropic Specular
Phong: heuristic, simple
Blinn-Phong: faster variant of Phong
Gaussian: heuristic, more complex than Phong
Beckmann: physical, based on micro-facets, expensive
Cook-Torrance: physical, modifies Beckmann to obey Fresnel’s
law
GGX: physical, a different derivation that obeys Fresnel’s law
Anisotropic Specular
not discussed here
Once we have a point in space mapped to a pixel, one of the most
common tasks is to approximate the color and lighting at that point.
These include BRDFs
for when light doesn’t move inside the object and BSDFs
when it does. There are many such models known; here we describe only
some of the best known named approximations of BRDFs.
Easily-computed BRDFs generally break light into three parts:
ambient, diffuse, and specular.
For each part, the object’s material may have a color 1ma, md, and ms, and those could differ: for
example, a white shine spot on a red apple suggest md is red but ms is white. In addition, there are
various models for deciding how intense the illumination from a given
type of light is, the scalars la,
ld, and ls, with various formulae for computing each
given in the sections below. And each light in the set of all lights
L has a color lc which also contributes to the
overall color of the object.
Each of these will generate a color vector for each light source;
these color vectors are then multiplied element-wise2 by
the color of the object. which may be different for each type of light:
(ma⊗l∈L∑lalc)+(md⊗l∈L∑ldlc)+(ms⊗l∈L∑lslc)
The remainder of this page defines various forumalae for the la, ld,
and ls terms above. It uses the
following notation:
n is the unit-length surface
normal vector.
e a unit-length vector that
points towards the eye of the viewer.
ℓ a unit-length vector that
points towards the light source.
la, ld, and ls
are the ambient, diffuse, and specular light intensities,
respectively.
[[a]]
to mean max(0,a) in this section for
compactness of notation.
cos−1(x) means the inverse of
cos(x), also called the arc-cosine or
acos.
cos−2(x) means (cos−1(x))2.
In all cases the discussion below assumes no attenuation of light
with distance or angle; to add attenuation, simply multiply the results
below by an attenuation factor (ex: since point light falls with the
square of the distance, we would simply multiply all the results below
by d21 to model its
attenuation).
1 Ambient Light
Ambient light is assumed to come from everywhere and reach everywhere
equally. Thus, the ambient light color is independent of the object;
la is simply a constant. There is no
ambient light in the real world; instead, it is a substitute for tracing
light that reaches an object by first bouncing off other objects. In
general, keep the ambient light small, no more than 20% of the total
light possible.
2 Diffuse Light
Diffuse light is the main component we think of when considering a
matte object. There are several different models for generating it.
In the Lambert model, ld=[[n⋅ℓ]]. This is what would happen if
every photon bounced in a completely random direction on a smooth
surface.
The Minnaert model extends the Lambert model by biasing the light to
bounce away from the surface; the bias is given by a constant k∈[0,1], and the formula is ld=[[n⋅l]]k[[n⋅e]]1−k. This was created to model the appearance of the moon;
the lower k the brighter the edges of
an object will appear.
The Oren-Nayer models assumes an object is made out of a
sub-pixel-resolution bumps and crevices. It is quite complicated, but
very close to what real-world objects look like. Let σ∈[0,1] be the roughness of the
surface. Then the Oren-Nayer model is
Any of these can be turned into a toon shader by simply picking a
cutoff value of ld and clamping
numbers above it to 1, numbers below it
to 0.
3 Specular Light
The specular highlight of an object (shiny spot) has even more
versions than does diffuse lighting. Most of versions rely on a hardness
number n≥1 which makes the shine
spot small, on the reflection of the light off the surface r=2(n⋅ℓ)n−ℓ, and/or on the vector halfway between the light and the eye
h=∥ℓ+e∥ℓ+e.
The Phong model is ls=[[r⋅e]]n and the Blinn-Phong is ls=[[h⋅n]]n.
They are similar in look and are easy to compute; generally Blinn-Phong
is used in conjunction with a single approximate e and ℓ while Phong is used if ℓ and/or e vary across
the scene.
The Gaussian model is more accurate, but likewise more expensive to
compute: ls=e−mcos−2[[n⋅h]] (note e is Euler’s number, e is the vector to the eye). Better and
more expensive is the Beckmann distribution ls=[[n⋅h]]4me−mtan2(cos−1[[n⋅h]]).
Fresnel’s law specifies how much light penetrates a transparent
object; this can be combined with the Beckmann distribution to get the
Cook-Torrance model. Let λ be the
Fresnel factor and β the computed
Beckmann distribution; then Cook-Torrance gives ls=β[[e⋅n]](1+[[e⋅n]])λmin1,e⋅h2(h⋅n)2(e⋅n),e⋅h2(h⋅n)2(ℓ⋅n).
GGX lighting is an alternative to Beckman that is empirically closer
to how specular highlighting looks than Beckman, and can be combined
with the Fresnel effect directly. Let σ∈[0,1] be the roughness of the surface and f be the F0 value representing how much light
is refelected at a 0° incidence angle; then GGX is expressed as π([[n⋅h]]2(σ2−1)+1)2([[ℓ⋅h]]2(1−0.25σ4)+(0.5σ2))[[n⋅ℓ]]σ2(f+(1−f)(1−[[ℓ⋅h]])5)
There are also a variety of anisotropic models (notably
Heidrich-Seidel and Ward) which depend additionally upon the principle
tangent vector of the surface and can give the appearance of brushed
metal, hair, and the like, but which are beyond the scope of this
document.