Shadow
Buffers
NVIDIAs
GeForce3 Ti Graphics Processing Units (GPU) are changing the face of lighting
techniques for PC graphics. NVIDIAs new GPUs are the first to bring
hardware acceleration for realistic shadows to consumer PCs. Special hardware
features in the texture unit of the GeForce3 Ti family enable these GPUs
to create and use shadow buffers for real-time shadows. The technique
of using shadow buffers has been field proven for such animated films
as Columbia Pictures computer generated (CG) motion picture Final Fantasy:
The Sprits Within. Until now, shadow buffering was only available on professional
rendering equipment outside of the consumers reach (like SGIs
Octane workstation).
NVIDIA shadow
buffer technology closes the gap between PC gaming and cinematic style
special effects for realistic, real-time shadows. This outlines the techniques
used to create and utilize shadow buffers. It also describes the unique
hardware features in the GeForce3 Ti GPUs that enable this groundbreaking
capability and its benefits for end users.
Realistic
Shadows Captivate Users
The
fundamental goal of computer graphics is to create the perception of an
alternate reality. Graphic imagery becomes more compelling as it gets
closer to replicating a real world visual experience. Until now, lighting
techniques for real-time computer graphics were missing a key element:
realistic shadows. Artists and photographers have always known the power
of lighting and shadows. In fact, black and white film is still used for
artistic photography because of the powerful effects that lighting and
shadows, even without color, have on people. These same effects can be
used to captivate users and draw them into real-time graphics environments.
Creating
Real-Time Shadows
The
NVIDIA shadow buffer technique used by the GeForce3 Ti processors involves
creating a map of which objects are lighted in the scene.
This map is stored in a shadow buffer so that it can be used later and
accessed like a texture through the special shadow buffer hardware located
in the texture engine within the GeForce3 Ti GPUs. This is a block diagram
that shows where the shadow buffer hardware is located in the GeForce3
Ti GPUs.
While mapping
the lighted areas instead of the shadowed areas may seem odd, this technique
is faster and simplifies the hardware because, while there is only one
lit pixel per XY location, there may be many shadowed pixels behind it.
Shadow buffer support requires a number of new hardware features in the
GeForce3 Ti GPU, but also leverages the general render-to-texture and
texture-mapping capabilities previously implemented in the NVIDIA texture
engines. As a result, shadow buffers enable the GeForce3 Ti to use texture-filtering
techniques to create soft edges on shadows.
None of this would be possible however, if the GeForce3 Ti GPU did not
have the special hardware features required to create and use a shadow
buffer. These special hardware features include the ability to:
- Designate
an area of graphics memory as a shadow buffer.
- Render
the shadow map into the shadow buffer.
- Read data
from the shadow buffer for the mathematical calculation to determine
if a specific pixel in the frame buffer is completely shadowed, partially
shadowed or not shadowed at all.
To create
a shadow map, the GeForce3 GPU renders the scene from the point of view
of the light, as if the viewer were located at the same position and looking
inthe same direction as the light. As the GeForce3 renders the scene,
it stores the depth information, or Z-value, for each pixel in the shadow
buffer. The hardware has a special algorithm to bias this Z-value to avoid
undesirable artifacts from precision errors. All of the objects in the
scene are rendered, but only the smallest biased Z-value for each pixel
is kept to ensure that the shadow buffer represents only the objects that
are closest to the light.
Once a shadow
map is created and stored in the shadow buffer, it is ready to be used.
When the GeForce3 Ti GPU renders the scene, it performs the following
steps:
- Transform
the pixel into the coordinate system defined by the light source.
- Use the
texture filtering techniques to read multiple Z-values stored in the
shadow buffer from locations that surround the XY location of the pixel.
The multiple Z-values are used for two important calculations:
- Using
a proprietary shadow algorithm, the multiple Z-values are compared
to the single Z-value for the pixel to determine what fraction of
the pixel is in shadow. This enables up to 256 discrete levels of
shadow to create soft edges for shadows.
- Using
texture-filtering algorithms, the multiple Z-values are filtered
down to a single Z value.
- The results
of steps 2a and 2b are used by the nfiniteFX engine as input data for
pixel shading operations. If the Z value of the pixel is equal to (or
very close to equal to) the Z value stored in the shadow buffer, then
the pixel is lit. Otherwise, the pixel is shadowed with the degree of
shadow determined by the result of step 2a. The nfiniteFX engine can
also turn off specular highlights for any pixel that is in shadow, enhancing
the realism of the image.
The following
images illustrate this process visually. To render the scent in Image
1, it is necessary to first create the shadow map showing in Image 2.
Not the direction of the light source in Image 1 and you'll see how teh
image in Image 2 is rendered from the light's point of view.
Note that
Image 2 simply looks like a gray-scale image of the scene from the point
of view of the light source.
Image 3 shows
the shadow buffer image rendered in full color to highlight the fact that
everything that is "in view" of the light, will not be shadowed;
everything else is shadowed.
NVIDIA
Shadow Mapping Techniques
There are
many techniques for rendering shadows and each of them have their strengths.
However, shadow mapping with NVIDIA shadow buffers has a number of key
advantages over alternative shadow rendering techniques:
Complex
Scenes
Works equally well for arbitrarily complex scenes (many objects or
complex shapes). |
|
 |
|
|
|
Soften
shadow edges
Shadow mapping can soften shadow edges using the proprietary shadowfiltering
algorithm with up to 256 discrete levels of shadowing based on the
percentage coverage of the pixel, if the pixel area is partially shadowed
and partially lighted. |
|
 |
|
|
|
Self
Shadow
Objects can self shadow (a persons arm can cast a shadow
on their chest.) Note the wings on the spacecraft cast a shadow on
other parts of the craft |
|
 |
|
|
|
Compatible
with multi-texture rendering
NVIDIA shadow buffers are compatible with multi-texture rendering.
Stenciled shadow volumes can force multi-pass rendering, reducing
performance if the application is either fill rate limited or memory
bandwidth limited. |
|
 |
Conclusion
NVIDIA shadow
buffers represent a giant leap forward for the PC graphics industry. The
unique hardware features of the GeForce3 Ti GPUs make realistic, real-time
shadows available for the first time ever on consumer PCs and bridge the
gap between cinema style shadow effects and the state-of-the-art for PC
graphics.
Appendix
A - How Shadow Buffers Work
Here
we use a heavy black line to show which values get stored in the shadow
buffer, leaving other locations 'in shadow' because they are 'behind'
some other object or part of an object. |
|
 |
|
|
|
Here
we show how objects that are hidden from the light (i.e. shadowed)
can be visible to the eye when the scene is rendered from the eyes
perspective. Note that the yellow circle is visible to the eye, but
is hidden from the light. That simply means that it is in shadow. |
|
 |
|
|
|
The
specific test to determine whether the pixel is shadowed or lighted
is the comparison of the distance Zlight to the filtered Z value
from the shadow buffer. The upper image explicitly shows these two
values via two arrows with the length of the arrows representing
the distance of the object from the image plane, which has a value
of Z=0.
An
alternate scenario would be where the yellow circle moves toward
the light source until it is closer to the light than the green
square. As shown in the lower image, the yellow circle would cast
a shadow on part of the green square, because A approx/= B.
|
|
 |
|