Microsoft DirectX 8.1 (vertex shader versions 1.0, 1.1)

m3x4

Computes the product of the input vector and a 3x4 matrix.

m3x4 dest, src0, src1

Registers

dest
Destination register.
src0
Input source register.
src1
Input source register.

To learn more about registers, see Registers.

Remarks

 
// m3x4 operates as shown in the following equation.
dest.x = (src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z);
dest.y = (src0.x * src2.x) + (src0.y * src2.y) + (src0.z * src2.z);
dest.z = (src0.x * src3.x) + (src0.y * src3.y) + (src0.z * src3.z);
dest.w = (src0.x * src4.x) + (src0.y * src4.y) + (src0.z * src4.z);

The input vector is in register src0, the input 3x4 matrix is in register src1 (and the next two higher registers in the same register file--as shown in the expansion below).

This operation is commonly used for transforming a position vector by a matrix that has a projective effect, but applies no translation. This macro instruction is implemented as a pair of dot products as shown below.

m3x4   r5, v0, c3

which is performed as four dot products:
dp3 r5.x, v0, c3
dp3 r5.y, v0, c4
dp3 r5.z, v0, c5
dp3 r5.w, v0, c6

The swizzle and negate modifiers are not allowed on this instruction.

Example

// This example scales the object in the y direction.

// shader file

mov r0, v0	    	; load vertex position
m3x4 r1, r0, c5		; scale in y
mov r1.w, c4.y		; set w component to 1
m4x4 oPos, r1, c0	; transform vertices by view/projection matrix

mov oD0, c4		; output constant color

// The resultant green object is 3/4 the height and is shown below.
// Additional code is used to initialize the constant registers

D3DXMATRIX mat, matView, matProj;
D3DXMatrixMultiply(&mat, &matView, &matProj);
D3DXMatrixTranspose(&mat, &mat);
// set C0 with the view and projection matrix
m_pd3dDevice->SetVertexShaderConstant(0, &mat, 4);

// set register c4
float colorGreen[4] = {0, 1, 0, 0};
m_pd3dDevice->SetVertexShaderConstant(4, &colorGreen, 1);

// set register c5 (also sets registers c6, c7, c8)
// 4 rows x 3 cols
float scaleY[][4] = {{1, 0, 0, 0},{0, 0.75, 0, 0},{0, 0, 1, 0},{0, 0, 0, 1}};
m_pd3dDevice->SetVertexShaderConstant(5, &scaleY, 4);

// The first SetVertexShaderConstant method binds the c0 register 
// with the first row of the view/projection matrix (rows 2, 3 and 4 are 
// bound to registers C2, C3 and C4 also). The m4x4 instruction (in the 
// shader file) loads the data.
// The second SetVertexShaderConstant method binds the c4 register 
// with the data for the color green. The last SetVertexShaderConstant 
// method binds the c5 register with the first row of the scale matrix 
// (rows 2, 3 and 4 are bound to registers C6, C7 and C8). The m3x4 instruction 
// (in the shader file) loads the data.