Microsoft DirectX 8.1 (pixel shader version 1.3)

texm3x2depth

Calculate the depth value to be used in depth testing for this pixel.

texm3x2depth dest, src

Registers

Argument Description RegistersVersion
vn cn tn rn
dest Destination register x 1.3
src Source register x 1.3

To learn more about registers, see Registers.

Remarks

This instruction must be used with the texm3x2pad instruction.

When using these two instructions, texture registers must use the following sequence.

tex t(n)                     // Define tn as a standard 3-vector.(tn must be 
                             // defined in some way before it is used.
texm3x2pad   t(m),   t(n)    // Where m > n
                             // Calculate z value.
texm3x2depth t(m+1), t(n)    // Calculate w value; use both z and w to
                             // find depth.

The depth calculation is done after using a dot product operation to find z and w. Here is more detail about how the depth calculation is accomplished.

// The texm3x2pad instruction calculates z. 
z = TextureCoordinates(stage m)UVW • t(n)RGB    

// The texm3x2depth instruction calculates w.
w = TextureCoordinates(stage m+1)UVW • t(n)RGB    

// Calculate depth and store the result in t(m+1).
if (w == 0)
  t(m+1) = 1.0
else
  t(m+1) = z/w

The calculated depth is tagged to be used in the depth test for the pixel, replacing the existing depth test value for the pixel.

Be sure to clamp z/w to be in the range of (0-1). If z/w is outside this range, the result stored in the depth buffer will be undefined.

After executing tex3x2depth, register t(m+1) is no longer available for use in the shader.

When multisampling, using this instruction eliminates most of the benefit of the higher resolution depth buffer. Because the pixel shader executes once per pixel, the single depth value output by texm3x2depth/texdepth will be used for each of the sub-pixel depth comparison tests.