Game Development Reference
In-Depth Information
Chapter 19
The Effects Framework
A rendering effect is typically composed of the following components: a
vertex and/or pixel shader, a list of device states that need to be set,
and one or more rendering passes. Furthermore, it is often desirable to
have a fallback mechanism for rendering effects on different grades of
graphics hardware (that is, to have several versions of an effect avail-
able that implements the same effect or attempts to implement the
same effect as closely as possible, using the capabilities of different
grades of hardware). It is clear that all these necessary tasks are associ-
ated with one effect. Therefore, it is a logical step to try to encapsulate
these tasks into one unit.
The Direct3D effects framework provides such a mechanism for
encapsulating tasks related to rendering effects in an effect file . Imple-
menting effects in effect files has a couple of advantages. For one thing,
it allows us to change the implementation of an effect without having to
recompile the application source code. This makes the process of
updating an effect, whether it is to fix a bug, make a simple enhance-
ment, or take advantage of the latest 3D hardware feature, easier.
Secondly, it encapsulates all the components of an effect in one file.
This chapter guides you through the necessary information and
steps to writing and creating an effect file. We note that effect files can
be written in any ASCII file format just like our HLSL programs.
Objectives
To gain an understanding of the structure and organization of an
effect file
To find out about some additional intrinsic objects in HLSL
To learn how device states are specified in an effect file
To learn how to create and use an effect
To gain some experience working with the effects framework by
studying some sample programs
335
Search WWH ::




Custom Search