Game Development Reference
In-Depth Information
19.1 Techniques and Passes
An effect file consists of one or more techniques . A technique is a partic-
ular way of rendering some special effect. So in other words, an effect
file provides one or more different ways of rendering the same special
effect. Why the need for several different implementations of the same
effect? Well, some hardware might not support a particular implemen-
tation of an effect. Therefore, it is necessary to implement several
versions of the same effect targeting different levels of hardware.
Note: For example, we might implement two versions of an effect,
one implemented with shaders and one implemented with the fixed
pipeline. In this way, users who have cards that support shaders can
take advantage of the shader implementation, while those who do not
can still use the fixed pipeline.
Being able to implement all versions of an effect in one effect file gives
us more complete encapsulation of the overall effect, which is one of
the goals of the effects framework—encapsulation.
Each technique contains one or more rendering passes. A rendering
pass encapsulates the device states, samplers, and/or shaders used to
render the geometry for that particular pass.
Note: An effect is not limited to use with the programmable pipe-
line only. For example, they can be used for the fixed function pipeline
for controlling device states, such as lights, materials, and textures.
The reason for multiple passes is because some special effects are
achieved by rendering the same geometry multiple times but with dif-
ferent device states, shaders, etc., for each particular pass. For
example, recall that in Chapter 8 we had to render the same geometry
multiple times per frame with different device states each time to
achieve the reflection effect.
As an example, here is a skeleton of an effect file with two tech-
niques, where the first technique consists of one pass and the second
technique consists of two passes:
// effect.txt
...
technique T0
{
// first and only pass for this technique
pass P0
{
...[specify pass device states, shaders, samplers, etc.]
}
}
Search WWH ::




Custom Search