Microsoft DirectX 8.0 (Visual Basic)

Preparing Data for the Pixel Shader Virtual Machine

Before rendering the orange sphere with the bump and environment map data, you must load the bump and environment maps. Then set the relevant texture stage states for each of the texture operation units. This includes setting the D3DTSS_BUMPENVMAT00, D3DTSS_BUMPENVMAT01, D3DTSS_BUMPENVMAT10, D3DTSS_BUMPENVMAT11, and D3DTSS_TEXCOORDINDEX texture stage states. However, the color operations—defined by D3DTSS_COLOROP—do not need to be set. This is because the pixel shader code is used to define the operations performed on a per-pixel basis. In general, the texture stage states that remains constant while rendering a triangle, object, or frame are set before invoking the pixel shader virtual machine. This includes the 2×2 bump-mapping matrix values. However, the data that is used to shade each pixel is specified through the pixel shader language.

For this example, the front end processing that occurs in the vertex shader is not addressed. Instead, assume that the front end sets up the texture interpolation so that the bump data is passed through the oT0 channel of the vertex shader. For the orange sphere example, this means that the bump map address used to access the bump data is set to the first texture coordinate register of the pixel shader (t0). In a similar fashion, the light map address—before the modification done in the texture operation unit—is passed from the vertex shader oT1 channel to the pixel shader through t1.