i
i
i
i
i
i
i
i
Chapter 5
Visual Appearance
“A good picture is equivalent to a good deed.”
—Vincent Van Gogh
When you render images of three-dimensional models, the models should
not only have the proper geometrical shape, they should also have the
desired visual appearance. In many cases (but not all—see Chapter 11)
the goal is photorealism—an appearance very close to photographs of real
objects. To reach this goal, it is worthwhile to use reality as our guide.
This chapter first discusses some of the ways in which light and materials
behave in the real world. A simple lighting and surface model is used as an
example of how such models can be implemented by using programmable
shaders.
The remainder of the chapter introduces additional techniques that can
be used to give rendered models a realistic appearance. These include
transparency, antialiasing, and compositing.
5.1 Visual Phenomena
When performing a realistic rendering of a scene such as the one in Fig-
ure 5.1, it helps to understand the relevant physical phenomena. These
are:
Light is emitted by the sun or other sources (natural or artificial).
Light interacts with objects in the scene; part is absorbed, part is
scattered and propagates in new directions.
Finally, light is absorbed by a sensor (human eye, electronic sensor,
or film).
In Figure 5.1, we can see evidence of all three phenomena. Light is
emitted from the lamp and propagates directly to the objects in the room.
99
i
i
i
i
i
i
i
i
100 5. Visual Appearance
Figure 5.1. A photograph of a room showing a light source and various objects.
The object surfaces absorb some and scatter some into new directions. The
light not absorbed continues to move through the environment, encounter-
ing other objects. A tiny portion of the light traveling through the scene
enters the sensor used to capture the image, in this case the electronic
sensor of a digital camera.
In the following sections we will discuss these phenomena and how they
can be portrayed using the rendering pipeline and GPU shaders from pre-
vious chapters.
5.2 Light Sources
Light is variously modeled as geometric rays, electromagnetic waves, or
photons (quantum particles with some wave properties). Regardless of
how it is treated, light is electromagnetic radiant energy—electromagnetic
energy that travels through space. Light sources emit light, rather than
scattering or absorbing it.
Light sources can be represented in many different ways for rendering
purposes. Here we will discuss a simple light model—more complex and ex-
pressive models will be discussed in Section 7.4 and Chapter 8. Extremely
distant light sources like the sun are simplest to simulate; their light travels
in a single direction that is the same throughout the scene. For this reason
they are called directional lights. For rendering purposes, the directionality
of such a light source is described by the light vector l, specified in world
space. The vector l is always assumed to be of length 1 whenever encoun-
i
i
i
i
i
i
i
i
5.2. Light Sources 101
l
Figure 5.2. The light vector l is defined opposite to the direction the light is traveling.
tered in this book. For directional lights, l is typically normalized (scaled
to a length of 1) by the application to avoid the need to renormalize it
during shading. The light vector l is usually defined pointing in a direction
opposite to the direction the light is traveling (see Figure 5.2). The reason
behind this will become clear shortly.
Besides the light’s direction, the amount of illumination it emits also
needs to be specified. The science of measuring light, radiometry, will be
discussed in Section 7.1; this chapter will present only the relevant concepts.
The emission of a directional light source can be quantified by measuring
power through a unit area surface perpendicular to l (see Figure 5.3). This
l
Figure 5.3. Measuring the magnitude of light emitted by a directional light source.

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.