i
i
i
i
i
i
i
i
3.8. Effects 49
Figure 3.9. A wide range of materials and post-processing effects are possible with pro-
grammable shaders. (Images produced by FX Composer 2, courtesy of NVIDIA Corpo-
ration.)
i
i
i
i
i
i
i
i
50 3. The Graphics Processing Unit
ZEnable = true;
ZWriteEnable = true;
ZFunc = LessEqual;
AlphaBlendEnable = false;
}
}
These state settings force the Z-buffer to be used in the normal way—
enabled for reading and writing, and passing if the fragment’s depth is
less than or equal to the stored z-depth. Alpha blending is off, as models
using this technique are assumed to be opaque. These rules mean that if
the fragment’s z-depth is equal to or closer than whatever was stored, the
computed fragment color is used to replace the corresponding pixel’s color.
In other words, standard Z-buffer usage is used.
A number of techniques can be stored in the same effect file. These
techniques are usually variants of the same effect, each targeted at a dif-
ferent shader model (SM 2.0 versus SM 3.0, for example). A huge range
of effects are possible. Figure 3.9 gives just a taste of the power of the
modern programmable shader pipeline. An effect usually encapsulates re-
lated techniques. Various methods have been developed to manage sets of
shaders [845, 847, 887, 974, 1271].
We are at the end of the tour of the GPU itself. There is much else
the GPU can do, and many ways in which its functions can be used and
combined. Relevant theory and algorithms tuned to take advantage of
these capabilities are the central subjects of this book. With these basics
in place, the focus will move to providing an in-depth understanding of
transforms and visual appearance, key elements in the pipeline.
Further Reading and Resources
David Blythe’s paper on DirectX 10 [123] has a good overview of the mod-
ern GPU pipeline and the rationale behind its design, as well as references
to related articles.
Information about programming vertex and pixel shaders alone can eas-
ily fill a book. Our best advice for jumping right in: Visit the ATI [50] and
NVIDIA [944] developer websites for information on the latest techniques.
Their free FX Composer 2 and RenderMonkey interactive shader design
tool suites provide an excellent way to try out shaders, modify them, and
see what makes them tick. Sander [1105] provides an implementation of
the fixed-function pipeline in HLSL for SM 2.0 capable hardware.
To learn the formal aspects of shader programming takes some
work. The OpenGL Shading Language book [1084] picks up where the Red
i
i
i
i
i
i
i
i
3.8. Effects 51
Book [969] leaves off, describing GLSL, the OpenGL programmable shading
language. For learning HLSL, the DirectX API continues to evolve with
each new release; for related links and books beyond their SDK, see this
book’s website (http://www.realtimerendering.com). O’Rorke’s article [974]
provides a readable introduction to effects and effective ways to manage
shaders. The Cg language provides a layer of abstraction, exporting to
many of the major APIs and platforms, while also providing plug-in tools
for the major modeling and animation packages. The Sh metaprogram-
ming language is more abstract still, essentially acting as a C++ library
that works to map relevant graphics code to the GPU.
For advanced shader techniques, read the GPU Gems and ShaderX
series of books as a start. The Game Programming Gems books also have
a few relevant articles. The DirectX SDK [261] has many important shader
and algorithm samples.
i
i
i
i
i
i
i
i
..................Content has been hidden....................

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