?/TD>
Microsoft DirectX 9.0

Vertex Shaders


Prior to Microsoft?DirectX?8.x, Microsoft Direct3D?operated a fixed function pipeline for converting 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 runtime.

Programmable shaders add a new dimension to the graphics pipeline by allowing the transform, lighting, and rendering functionality to be modified at runtime. A shader is declared at runtime but, when done, the user can change which shader is active and control the shader data dynamically, using streaming data. This gives the user a new level of dynamic flexibility over the way that pixels are rendered.

A vertex shader file contains vertex shader instructions. Vertex shaders can control vertex color and how textures are applied to vertices. Lighting can be added through the use of vertex shader instructions. The shader instruction file contains ASCII text so it is readable and in some ways looks similar to assembly language. A vertex shader is invoked after any DrawPrimitive or DrawIndexedPrimitive call. Shaders can be dynamically switched using SetVertexShader to specify a new shader file, or by changing the instructions in the ASCII text shader file using the streaming data inputs. The Vertex Shader 1_1 has a complete listing of shader instructions.

Instruction sets evolve rapidly. For details about ordering instructions to avoid problems, refer to the hardware vendor's Web site. Alternatively, use the High-Level Shader Language to get efficiently compiled shader instructions using Direct3D extensions (D3DX).



© 2002 Microsoft Corporation. All rights reserved.