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 = ,
(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.
i
i
i
i
i
i
i
i
7.1. Radiometry 203
infrared
ultraviolet
750 700 650 550 500 450 400
400 450
2.75
500
600
550
2.25
600 650 700 750
3.0 2.5 2.0 1.75
λ(nm)
ν
(THz)
Q(eV) Q(eV)
ν(THz)
λ(nm)
Figure 7.1. The visible spectrum. The top scale shows wavelength in nanometers, the
middle scale shows frequency in terahertz (10
12
Hertz), and the bottom scale shows
photon energy in electron-volts (the amount of energy required to move a single electron
over an electrical potential difference of one volt).
Radiometric Quantity: Units
radiant energy: joule (J)
radiant flux: watt (W)
irradiance: W/m
2
radiant intensity: W/sr
radiance: W/(m
2
sr)
Table 7.1. Radiometric quantities and units.
In radiometry, the basic unit is energy or radiant energy Q,measuredin
joules (abbreviated “J”). Each photon has some amount of radiant energy
that, as we have seen, is proportional to its frequency. For example, at a
wavelength of 550 nm, by Equation 7.1 there are 2.77 × 10
18
photons per
joule.
The radiant flux or radiant powerorP, of a light source is equal
to the number of joules per second emitted (i.e., dQ/dt). The watt (W)
is another term for joules per second. In principle, one can measure the
radiant flux of a light source by adding up the energies of the photons it
emits in a one-second time period. For example, a given light bulb may
emit 100 watts of radiant flux (of which only part would be visible)—see
the upper-left part of Figure 7.2.
Irradiance (briefly discussed in Chapter 5) is the density of radiant flux
with respect to area (i.e., dΦ/dA). Irradiance is defined with respect to
a surface, which may be an imaginary surface in space, but is most often
i
i
i
i
i
i
i
i
204 7. Advanced Shading
φ = 100 watts
E
L
= 0.3 watts/m
2
I = 15 watts/s
r
Figure 7.2. A light bulb. In the upper-left part of the figure, the light bulb’s radiant flux
of 100 watts is shown. In the lower part of the figure, the light bulb is illuminating a
small scene from a distance, so that its irradiance contribution E
L
(measured in a plane
perpendicular to the light direction) is a constant 0.3 watts per square meter over the
scene. In the upper-right part of the figure, the intensity of the light bulb is measured
in a given direction as 15 watts per steradian.
the surface of an object. In photometry, presented in the next section, the
corresponding quantity illuminance is what is measured by a light meter.
As shown previously, irradiance E is used to measure light flowing into a
surface and exitance M (also called radiosity or radiant exitance)isused
to measure light flowing out of a surface. The general term radiant ux
density is sometimes used to refer to both irradiance and exitance. Chap-
ter 5 showed how to use irradiance to measure the illumination of an ideal
directional light source. Such light sources are a useful approximation for
situations where the distance to the light is much larger than the extent of
the rendered scene—for example, a small pile of toys on the other side of
the room from the light bulb (see the bottom part of Figure 7.2). The ir-
radiance from the light bulb E
L
(measured in a plane perpendicular to the
light direction) is approximately constant over the scene (in this example,
0.3 watts per square meter—again, only part of this is visible radiation).
For closer light sources (or larger scenes), E
L
varies with distance and
cannot be treated as a constant. Imagine concentric spheres around the
light bulb, starting at a distance much larger than the size of the bulb (see
the upper-right side of Figure 7.2). Since the bulb is relatively small, we
i
i
i
i
i
i
i
i
7.1. Radiometry 205
assume that all its light is emitted from a point at its center. We want to
examine the light emitted in a particular direction (the orange arrow), so
we construct a narrow cone, its axis along this direction and its apex at
the center of the bulb. Intersecting this cone with the spheres produces
a sequence of patches, increasing in area proportionately to the square of
their distance from the light. Since the radiant flux through the patches is
the same, irradiance decreases by the same proportion:
E
L
(r)
1
r
2
. (7.2)
The constant of proportionality in Equation 7.2 is a value that does not
change with distance:
E
L
(r)=
I
r
2
,
I = E
L
(r)r
2
.
(7.3)
This quantity, I, is called intensity or radiant intensity. If the distance
r equals 1, then intensity is the same as irradiance—in other words, inten-
sity is flux density with respect to area on an enclosing radius-1 sphere.
The significance of area on a radius-1 sphere can be seen from an analogy
with the definition of radians: An angle is a set of directions in a plane,
and its size in radians is equal to the length of the arc it intersects on an
enclosing radius-1 circle. A solid angle is a three-dimensional extension of
the concept—a continuous set of directions, measured with steradians (ab-
breviated “sr”), which are defined by patch area on a radius-1 sphere [409]
(solid angle is represented by the symbol ω). From this, we can see that
intensity is actually flux density with respect to solid angle (dΦ/dω), unlike
irradiance, which is flux density with respect to area. Intensity is measured
in watts per steradian.
The concept of a solid angle is sometimes difficult to grasp, so here is an
analogy that may help. Solid angle has the same relationship to direction
that surface area has to a surface location. Area is the size of a set of
locations, and solid angle is the size of a set of directions.
Most light sources do not emit the same intensity in all directions.
The light bulb in Figure 7.2 emits varying intensities of light in different
directions, as can be seen from the density of arrows in the upper-left part
of the figure. In the upper right, we see that the value of the light bulb’s
intensity in the direction represented by the orange arrow is 15 watts per
steradian.
In two dimensions, an angle of 2π radians covers the whole unit circle.
Extending this to three dimensions, a solid angle of 4π steradians would
cover the whole area of the unit sphere. The size of a solid angle of 1
steradian can be seen in Figure 7.3.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset