?/TD>
Microsoft DirectX 9.0

Texture Considerations


The pixel shader completely replaces the pixel-blending functionality specified by the Microsoft?DirectX?6.0 and 7.0 multi-texturing application programming interfaces (APIs), specifically those operations defined by the D3DTSS_COLOROP, D3DTSS_COLORARG1, D3DTSS_COLORARG2, D3DTSS_ALPHAOP, D3DTSS_ALPHAARG1, and D3DTSS_ALPHAARG2 texture stage states, and associated arguments and modifiers. When a procedural pixel shader is set, these states are ignored.

Texture Stage and Sampler States

When pixel shaders are in operation, the following texture stage states are still observed. They are version dependent as shown in the table.

Texture stage stateVersion(s)
D3DTSS_BUMPENVMAT001_1 - 1_4
D3DTSS_BUMPENVMAT011_1 - 1_4
D3DTSS_BUMPENVMAT101_1 - 1_4
D3DTSS_BUMPENVMAT111_1 - 1_4
D3DTSS_BUMPENVLSCALE1_1 - 1_3
D3DTSS_BUMPENVLOFFSET1_1 - 1_3
D3DTSS_TEXCOORDINDEX1_1 - 1_3. Valid only for fixed function vertex processing.
D3DTSS_TEXTURETRANSFORMFLAGS1_1 - 1_3. Valid only for fixed function vertex processing.

When pixel shaders are in operation, the following sampler states are still observed.

Sampler stateVersion(s)
D3DSAMP_ADDRESSUAll
D3DSAMP_ADDRESSVAll
D3DSAMP_ADDRESSWAll
D3DSAMP_BORDERCOLORAll
D3DSAMP_MAGFILTERAll
D3DSAMP_MINFILTERAll
D3DSAMP_MIPFILTERAll
D3DSAMP_MIPMAPLODBIASAll
D3DSAMP_MAXMIPLEVELAll
D3DSAMP_MAXANISOTROPYAll
D3DSAMP_SRGBTEXTUREAll
D3DSAMP_ELEMENTINDEXAll
D3DSAMP_DMAPOFFSETVertex shaders only (displacement mapping)

Because these texture stage states are not part of the pixel shader, they are not available at shader compile time so the driver can make no assumptions about them. For example, the driver cannot differentiate between bilinear and trilinear filtering at that time. The application is free to change these states without requiring the regeneration of the currently bound shader.

Pixel Shaders and Texture Sampling

Texture sampling and filtering operations are controlled by the standard texture stage states for minification, magnification, mip filtering, and the wrap addressing modes. For more information, see Texture Stage States. This information is not available to the driver at shader compile time, so shaders must be able to continue operation when this state changes. The application is responsible for setting textures of the correct type (image map, cube map, volume map, etc.) needed by the pixel shader. Setting a texture of the incorrect type will produce unexpected results.

Post-Shader Pixel Processing

Other pixel operations—such as fog blending, stencil operations, and render target blending—occur after execution of the shader. Render target blending syntax is updated to support new features as described in this topic.

Pixel Shader Inputs

For pixel shader versions ps_1_1 - ps_2_0, diffuse and specular colors are saturated (clamped) to the range 0 through 1 before use by the shader because this is the range of valid inputs to the shader.

Color values input to the pixel shader are assumed to be perspective correct, but this is not guaranteed in all hardware. Colors generated from texture coordinates by the address shader are always iterated in a perspective correct manner. However, they are also clamped to the range 0 to 1 during iteration.

Pixel Shader Outputs

For pixel shader versions ps_1_1 - ps_1_4, the result emitted by the pixel shader is the contents of register r0. Whatever it contains when the shader completes processing is sent to the fog stage and render target blender.

For pixel shader versions ps_2_0 and above, output color is emitter from oC0 - oC4.



© 2002 Microsoft Corporation. All rights reserved.