Microsoft DirectX 8.1 (pixel shader versions 1.0, 1.1, 1.2, 1.3)

texm3x2tex

Performs the final row of a 3×2 matrix multiply and uses the result to do a texture lookup. texm3x2tex must be used in conjunction with the texm3x2pad instruction.

texm3x2tex dest, src

Registers

Argument Description RegistersVersion
vn cn tn rn
dest Destination register x 1.0, 1.1, 1.2, 1.3
src Source register x 1.0, 1.1, 1.2, 1.3

To learn more about registers, see Registers.

Remarks

The instruction is used as one of two instructions representing a 3×2 matrix multiply operation. This instruction must be used with the texm3x2pad.

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
                              // Perform first row of matrix multiply.
texm3x2tex  t(m+1), t(n)      // Perform second row of matrix multiply 
                              // to get (u,v) to sample texture 
                              // associated with stage m+1.

Here is more detail about how the 3×2 multiply is accomplished.

// The texm3x2pad instruction performs the first row of the multiply to find u'.
u' = t(n)RGB • TextureCoordinates(stage m)UVW   

// The texm3x2tex instruction performs the second row of the multiply to find v'.
v' = t(n)RGB • TextureCoordinates(stage m+1)UVW   

// The texm3x2tex instruction samples the texture on stage (m+1) with (u',v') and 
// stores the result in t(m+1).
t(m+1)RGB = TextureSample(stage m+1)RGB using (u', v') as coordinates.

Example

// Here is an example shader with the texture maps and
// the texture stages identified.
ps.1.0
tex t0                // Bind texture in stage 0 to register t0.
texm3x2pad  t1,  t0   // First row of matrix multiply.
texm3x2tex  t2,  t0   // Second row of matrix multiply to get (u,v)
                      // with which to sample texture in stage 2.
mov r0, t2            // Output result.

// This example requires the following textures in the following texture stages.
//
// Stage 0 takes a map with (x,y,z) perturbation data.
//
// Stage 1 holds texture coordinates. No texture is required in the texture stage.
//
// Stage 2 holds both texture coordinates as well as a 2-D texture set at 
// that texture stage.