i
i
i
i
i
i
i
i
Chapter 7
Advanced Shading
“Let the form of an object be what it may, light, shade, and
perspective will always make it beautiful.”
—John Constable
The Gouraud shading model was invented in 1971 [435]. Phong’s specu-
lar highlighting equation was introduced around 1975 [1014]. The concept
of applying textures to surfaces was presented a year later by Blinn and
Newell [96]. As part of the standard fixed-function pipeline, these algo-
rithms were the mainstay of graphics accelerators for years. The advent of
programmable shaders has vastly increased the available options—modern
GPUs can evaluate (almost) arbitrary shading models. This moves the
focus from “what is possible?” to “what are the best choices for this ap-
plication?”
An understanding of the underlying physical and psychological princi-
ples pertinent to rendering is important in navigating these choices. The
previous chapters presented the technologies for controlling the graphics
pipeline and the basic theory behind their use. In this chapter some of
the scientific underpinnings of rendering are discussed. Radiometry is pre-
sented first, as this is the core field concerned with the physical transmission
of light. Our perception of color is a purely psychological phenomenon, and
is discussed in the section on colorimetry. A shading model is comprised of
two main parts: the light source and the material model. Sections on both
describe the various options that are available. The final sections detail
methods for the efficient implementation of shading models.
The options covered in this chapter are limited by one basic assumption.
Each light source is assumed to illuminate a surface location from one
direction only—area, ambient, and environment lighting are not covered.
Chapter 8 will describe the theory and practice necessary for the use of
more general types of illumination.
201
i
i
i
i
i
i
i
i
202 7. Advanced Shading
7.1 Radiometry
The explanation of the example shading model in Chapter 5 included a
brief discussion of some concepts from radiometry. Here we will go over
those concepts in more depth, and introduce some new ones.
Radiometry deals with the measurement of electromagnetic radiation.
Such radiation consists of a flow of photons, which behave as either par-
ticles or waves, depending on circumstance. Using the mental model of
photons as particles works well for the most part. Although some physical
phenomena cannot be modeled without accounting for the wave properties
of photons,
1
these are usually ignored by even high-quality batch rendering
systems [1089].
One wave-related property of photons that cannot be disregarded is
the fact that each has an associated frequency or wavelength.
2
This is
an important property, because the energy of each photon is proportional
to its frequency, which affects interactions between photons and matter.
Most importantly, it affects the interaction of photons with sensors such
as the rods and cones in the human eye. Different frequencies of photons
are perceived as light of different colors (or not perceived at all, if they
are outside the limited range of human vision). The relationships between
a photon’s wavelength λ (in meters), frequency ν (in Hertz, or cycles per
second) and energy Q (in joules) are
ν =
c
λ
,
λ =
c
ν
,
Q = hν,
(7.1)
where c is the speed of light (2.998 ×10
8
meters/second) and h is Planck’s
constant (6.62620 × 10
−34
joule-seconds).
Electromagnetic radiation exists in a range of frequencies and energies,
from ELF (extremely low frequency) radio waves to gamma rays. Photons
with wavelengths between roughly 380 to 780 nanometers are perceptible to
the human eye, so only this range, the visible spectrum, is typically used for
rendering. Figure 7.1 shows the colors perceived for monochromatic (single-
wavelength) light throughout the visible spectrum. Recall that photon
energy is proportional to frequency: “bluer” photons are more energetic;
“redder” photons are less energetic.
In this section, we will discuss the various radiometric units and their
relationships. They units are summarized in Table 7.1.
1
These phenomena include polarization, interference, and diffraction.
2
Quantum theory shows that each photon actually has a range of associated frequen-
cies, but this fact can be ignored for rendering.
Get Real-Time Rendering, Third Edition, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.