i
i
i
i
i
i
i
i
216 7. Advanced Shading
A few words are in order about this equation. First, in older texts, it is
often given as Y =0.30R +0.59G +0.11B. Poynton [1028] discusses how
this form is based on older NTSC phosphors; the equation given above is
based on modern CRT and HDTV phosphors. This brings us full circle
to the photometric curve shown on page 209. This curve, representing
how a standard observer’s eye responds to light of various wavelengths, is
multiplied by the spectra of the three phosphors, and each resulting curve
is integrated. The three resulting weights are what form the luminance
equation above. The reason that a grayscale intensity value is not equal
parts red, green, and blue is because the eye has a different sensitivity to
various wavelengths of light.
The gamut affects the rendering process in a number of ways. The
gamuts and white point locations of monitors vary, both because of the
physical makeup and due to the adjustment of brightness and contrast,
meaning that how a color looks on one monitor will not be the same as
on another. The gamuts of printers differ more still from monitors, so
that there are colors that can display well on one printer, but not another.
Custom inks can be used to print outside the normal gamut, for both
artistic effect and for creating items such as banknotes. Scanners also have
a gamut of colors they can record, and so have similar mismatches and
limitations. Monitor gamuts are always triangles, by the nature of how
they produce colors. Film, print, and other media have gamuts that are
roughly triangular, but with curved edges or other irregularities, due to the
characteristics of the chemicals or inks used to capture color.
While any given spectrum can be precisely represented by an RGB
triplet, it does not follow that using RGB colors for materials and lights
is a precise basis for computations. In other words, multiplying two RGB
colors to obtain an RGB result is not the same as multiplying two spectra
together and then converting the resulting spectrum to RGB. As a simple
thought experiment, imagine a light with a spectrum going from 550 to
700 nm, and a material that has a spectral response of 400 nm to 549
nm. Ignoring red and blue, these two spectra will each convert to RGB
triplets that both have at least some positive green component. When
these two RGB values are multiplied together, the green component in
the result will also be positive. However, the spectra themselves, when
multiplied together, yield an entirely black spectrum, which would have no
green component. That said, while experiments have been done showing
differences when spectra are used instead of RGBs, in practice multiplying
RGBs together works surprisingly well [111].
The CIE XYZ system is useful for precise description, but there are
many other color spaces with different strengths and uses. For example,
CIELUV and CIELAB define color spaces that are more perceptually uni-
form [1225]. Color pairs that are perceptibly different by the same amount
i
i
i
i
i
i
i
i
7.4. Light Source Types 217
can be up to 20 times different in distance in CIE XYZ space. CIELUV
improves upon this, bringing the ratio down to a maximum of four times.
Other color systems common in computer graphics include HSB (hue,
saturation, brightness)andHLS(hue, lightness, saturation) [349].
CMYK (cyan, magenta, yellow, black) is for the inks used in standard
four-color printing. YUV is the color model used in many video standards,
and represents luminance (Y) and two chroma values. YIQ is a similar
color space used for NTSC television. Dawson [230] gives a good overview
of color display and perception issues concerning real-time applications and
television.
Though colorimetry has strong mathematical underpinnings, the ba-
sis is the perception of color by some set of observers under controlled
conditions. Even under these conditions, observers’ genetic, physical, and
mental states affect results. In the real world, there are many more vari-
ables that affect human perception of a color patch, such as the lighting
conditions, the surrounding colors, and past conditions. Some of these per-
ceptual effects can be put to good use. For example, using red lettering on
a blue background has long been a way to grab attention, because the blue
surrounding color further accentuates the perceived brightness of the red.
Another important effect for computer graphics is that of masking [341]. A
high-frequency, high-contrast pattern laid on an object tends to hide flaws.
In other words, a texture such as a Persian rug will help disguise color band-
ing and other shading artifacts, meaning that less rendering effort needs to
be expended for such surfaces.
This section has touched on only the basics of color science, primarily to
bring an awareness of the relation of spectra to color triplets and to discuss
the limitations of devices. Stone’s book [1224] is a good place to learn about
digital color. Glassner’s Principles of Digital Image Synthesis [408, 409]
discusses color theory and perception. Ferwerda’s tutorial discusses vision
research relevant to computer graphics [341]. Reinhard’s recent book [1060]
gives a thorough overview of the whole area of study.
7.4 Light Source Types
In real-world scenes, light sources can be natural (like the sun), or artificial.
An artificial light source (such as a tungsten filament) is often paired with
a housing that shapes the directional distribution of the emitted light (the
combination of light source and housing is called a luminaire). In rendering
it is common to model the luminaire as a light source with a directional
distribution that implicitly models the effect of the housing.
Directional light sources were discussed in Chapter 5. Directional lights
are the simplest model of a light source—they are fully described by l (their
i
i
i
i
i
i
i
i
218 7. Advanced Shading
world-space direction vector) and E
L
(their irradiance contribution mea-
sured in a plane perpendicular to l). Recall that since E
L
varies for different
wavelengths, it is expressed as an RGB vector for rendering purposes.
In Section 7.1 point lights were introduced. Like directional lights, point
lights are an approximation to real light sources. However the assumption
used (that the distance between the light and the illuminated surfaces is
large compared to the size of the light source) is much more likely to be
applicable than the assumption underlying directional lights (that the dis-
tance between the light and the illuminated surfaces is large compared
to the extents of the entire rendered scene). The sun is well modeled as
a directional light source, and perhaps some artificial lights might be far
enough away from the scene to be appropriately represented with direc-
tional lights as well, but most other light sources in a scene will probably
be modeled as point lights.
In this chapter we discuss rendering with lights that are variants of
directional and point lights. Although we will see many options for varying
these lights, there is one thing they all have in common: At a given surface
location, each light source illuminates the surface from one direction only.
In other words, the light source covers a zero solid angle as seen from the
surface point. This is not true for real-world lights, but in most cases the
approximation is good enough. In Section 8.2 we will discuss light sources
that illuminate a surface location from a range of directions.
7.4.1 Omni Lights
Point lights are defined by their position p
L
and intensity I
L
. In general,
I
L
varies as a function of direction. Point lights with a constant value for
I
L
are known as omni lights.LikeE
L
, I
L
is also expressed as an RGB
vector for rendering.
Shading equations (as we saw in Section 5.5) use the light vector l and
the irradiance contribution of the light E
L
(measuredinaplaneperpen-
dicular to l). These can be computed from I
L
and p
L
using the following
equations (p
S
is the surface position):
r = p
L
p
S
,
l =
p
L
p
S
r
,
E
L
=
I
L
r
2
.
(7.12)
Although E
L
decreasing proportionally to 1/r
2
is physically correct for
a point light, it is often preferable to use a different function to describe
how E
L
decreases with distance. Such functions are called distance falloff
i
i
i
i
i
i
i
i
7.4. Light Source Types 219
functions. This generalizes the last line in Equation 7.12 to the following:
E
L
= I
L
f
dist
(r). (7.13)
Various distance falloff functions have been in use in computer graphics
for many years. There are various reasons for using a function other than an
inverse square falloff. Alternate falloff functions can provide more control
for lighting the scene to achieve a particular desired appearance. An inverse
square function gets near to 0 with distance, but never quite reaches 0.
Falloff functions that reach a value of 0 at a particular distance can enable
better performance, since the effect of the light on any objects beyond this
distance can be ignored. Unlike inverse square falloff, which gets arbitrarily
large when close to the light source, most falloff functions used in graphics
have a finite value close to the light source. This avoids the (problematic)
need to handle arbitrarily large numbers during shading.
One historically important falloff function is part of the OpenGL and
DirectX fixed-function pipelines:
f
dist
(r)=
1
s
c
+ s
l
r + s
q
r
2
, (7.14)
where s
c
, s
l
and s
q
are properties of the light source. This falloff function
was historically not applied to physical values of E or I, but to non-physical
lighting values (typically limited to a 0 to 1 range). Using this function,
physically correct inverse square falloff, as well as other effects, can be
achieved. This function does have the drawback of never reaching 0.
A much simpler distance falloff function is often used in games and
graphical modeling applications:
f
dist
(r)=
1, where r r
start
,
r
end
r
r
end
r
start
, where r
start
<r<r
end
,
0, where r r
end
,
(7.15)
where r
start
and r
end
are properties of the light source. This falloff function
is easy to control and does reach 0 (at r
end
).
A distance falloff function used by Pixar in film rendering is described
in Barzel’s 1997 paper [70]:
f
dist
(r)=
f
max
e
k
0
(r/r
c
)
k
1
, where r r
c
,
f
c
r
c
r
s
e
, where r>r
c
.
(7.16)
This function reaches a desired value f
c
at a specific distance r
c
.Atdis-
tances closer than r
c
it gradually approaches a maximum value f
max
.The
i
i
i
i
i
i
i
i
220 7. Advanced Shading
falloff exponent s
e
controls how gradually the function decreases with dis-
tances greater than r
c
. The constants k
0
and k
1
are set to specific values
to ensure a continuous derivative at the transition point: k
0
=ln(f
c
/f
max
)
and k
1
= s
e
/k
0
. This falloff function does not reach 0 and is expensive to
compute. An interesting note in Barzel’s paper [70] is that, in film render-
ing, ad hoc near and far cutoffs are used more often than falloff functions
such as the one in Equation 7.16.
Various other falloff functions are used in real-time rendering applica-
tions, motivated by the need for fine control and fast evaluation.
7.4.2 Spotlights
Unlike omni lights, real light sources have directional variance in their
intensity. Different visual effects can be produced using different functions
to describe how I
L
varies with direction. One important type of effect is
the spotlight. Historically, these have been featured in the OpenGL and
DirectX fixed-function pipelines, which use functions based on the cosine
of the angle θ
s
between a vector s denoting the direction of the spotlight,
and the reversed light vector l to the surface. The light vector needs to be
reversed because we define it at the surface as pointing towards the light,
and here we need a vector pointing away from the light. See Figure 7.12.
The spotlight function used in the OpenGL fixed-function pipeline is
I
L
(l)=
I
L
max
(cos θ
s
)
s
exp
, where θ
s
θ
u
,
0, where θ
s
u
.
(7.17)
The function in Equation 7.17 tapers to 0 as the angle between the light
direction and s increases. The tightness of the spotlight is controlled by
s
-l
θ
u
θ
p
θ
s
Figure 7.12. A spotlight. θ
s
is the angle from the light’s defined direction s to the vector
l, the direction to the surface. θ
p
shows the penumbra and θ
u
the umbra angles defined
for the light. Beyond the umbra angle the spotlight has no effect.
..................Content has been hidden....................

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