Real-Time Shader Programming

The input registers are how data gets passed to the pixel shader. All registers consist of a four-element vector, with at least 8 bits of precision per component in some of the earlier hardware implementations, which may cause round-off to be a problem in long, complicated shaders. In PS 1.4 class hardware or later, if you need more precision, then you can use texture coordinate registers to pass in higher precision values. See the Texture Registers subsection later in this section for more information.
Input to the pixel shader consists of the vertex color registers, the texture registers, and the constant registers. The vertex color registers are the direct output of the vertex shader, the values in oD0 and oD1, or if no vertex shader was used, the diffuse and specular colors are generated by the fixed function pipeline. The float constant registers are constants that are set up prior to the shader being called or are set inside the shader code itself. The texture registers are interpolated values taken from the vertex data.
Pixel shader vertex color registers consist of two read only registers that are generated as output from the vertex shader or the fixed function pipeline. If the current render state is flat shading D3DSHADE_FLAT, then the vertex color registers use only the vertex shader color data from the first vertex in the triangle. If Gouraud shading is enabled (i.e., D3DSHADE_GOURAUD), then the pixel values will...