Game Development Reference
In-Depth Information
18.1 Multitexturing Overview
Multitexturing is perhaps the simplest of the techniques that can be
implemented using a pixel shader. Furthermore, since pixel shaders
replace the multitexturing stage, it follows then that we should have a
basic understanding of what the multitexturing stage is and does. This
section presents a concise overview of multitexturing.
When we originally discussed texturing back in Chapter 6, we
omitted a discussion on multitexturing in the fixed function pipeline for
two reasons: First, multitexturing is a bit of an involved process, and
we considered it an advanced topic at the time. Additionally, the fixed
function multitexturing stage is replaced by the new and more powerful
pixel shaders; therefore it made sense not to spend time on the out-
dated fixed function multitexturing stage.
The idea behind multitexturing is somewhat related to blending. In
Chapter 7 we learned about blending the pixels being rasterized with
the pixels that were previously written to the back buffer to achieve a
specific effect. We extend this same idea to multiple textures. That is,
we enable several textures at once and then define how these textures
are to be blended together to achieve a specific effect. A common use
for multitexturing is to do lighting. Instead of using Direct3D's lighting
model in the vertex processing stage, we use special texture maps
called light maps , which encode how a surface is lit. For example, sup-
pose we wish to shine a spotlight on a large crate. We could define a
spotlight as a D3DLIGHT9 structure, or we could blend together a tex-
ture map representing a crate and a light map representing the
spotlight as Figure 18.1 illustrates.
Figure 18.1: Rendering a crate lit by a
spotlight using multitexturing. Here
we combine the two textures by multi-
plying the corresponding texels
together.
Search WWH ::




Custom Search