Microsoft DirectX 8.1 (Visual Basic)

Pixel Shaders

Before Microsoft® DirectX® 8.x, Microsoft® Direct3D® used a fixed function pipeline for converting three-dimensional (3-D) geometry to rendered screen pixels. The user sets attributes of the pipeline that control how Direct3D transforms, lights, and renders pixels. The fixed function vertex format is declared at compile time and determines the input vertex format. Once defined, the user has little control over pipeline changes during run time.

Shaders add a new dimension to the graphics pipeline by allowing the vertex transform, lighting, and individual pixel coloring functionality to be programmed. Pixel shaders are short programs that execute for each pixel when triangles are rasterized. This gives the user a new level of dynamic flexibility over the way that pixels are rendered.

A pixel shader contains pixel shader instructions made up of ASCII text. Arithmetic instructions can be used to apply diffuse and/or specular color. Texture addressing instructions provide a variety of operations for reading and applying texture data. Functionality is available for masking and swapping color components. The shader ASCII text looks similar to assembly language and is assembled using Direct3DX assembler functions from either a text string or a file. The assembler output is a series of opcodes that an application may provide to Direct3D by means of Direct3DDevice8.CreatePixelShader. The Pixel Shader Reference has a complete listing of shader instructions.

To understand more about pixel shaders, see the following sections.