Microsoft DirectX 8.0 (Visual Basic)

Introduction to Pixel Shaders

The following example illustrates a way to introduce pixel shaders and their syntax as understood by the Direct3DX pixel shader assembler.

ps.1.0          // DirectX8 version.
tex t0          // Declare the texture.
tex t1          // Declare the light map.

mov r0, t0
mul r0, r0, t1  // Modulate the light map.
mul r0, r0, v0  // Modulate the diffuse.
add r0, r0, v1  // Add the specular.

This pixel shader declares a base texture with a light map, diffuse color, and specular add.

Pixel shaders control the color and alpha blending operations and the texture addressing operations. Microsoft® Direct3D® for Microsoft DirectX® 8.0 defines a procedural paradigm for defining pixel and texture blending operations. This model includes a definition of a virtual machine architecture and a set of instructions and modifiers that define its behavior. This paradigm does not necessarily imply a processor-based implementation.

The pixel shaders extend and generalize the multitexture capabilities of DirectX 6.0 and 7.0 in the following ways.

To support this increased flexibility more efficiently , the application programming interface (API) syntax is changed from DWORD pairs to an ASCII assemble code syntax. This exposes the functionality offered by procedural pixel shaders.

Note  When you use pixel shaders, specular add is no longer specifically controlled by a render state, and it is up to the pixel shader to implement if needed. However, fog blending is still applied by the fixed-function syntax.

For further details and information on how to use the Direct3DX pixel shader assembler, see Pixel Shader Assembler Reference.