Microsoft DirectX 8.1 (vertex shader versions 1.0, 1.1) |
Calculates the maximum of the sources.
max dest, src0, src1
To learn more about registers, see Registers.
The following code fragment shows the operations performed.
dest.x=(src0.x >= src1.x) ? src0.x : src1.x; dest.y=(src0.y >= src1.y) ? src0.y : src1.y; dest.z=(src0.z >= src1.z) ? src0.z : src1.z; dest.w=(src0.w >= src1.w) ? src0.w : src1.w;
This example compares two registers to find the maximum component values. vs.1.0 m4x4 oPos, v0, c0 ; transform vertices by view/projection matrix mov r0, c4 ; load green mov r1, c5 ; load pink max r2, r0, r1 ; pick max color values mov oD0, r2 ; output // The resultant vertex color is part green and part pink 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 float colorPink[] = {0.75, 0, 0, 0}; m_pd3dDevice->SetVertexShaderConstant(5, &colorPink, 1); // The c0 register is loaded with the view and projection matrix // using the m4x4 instruction (the m4x4 instruction also uses the // c1, c2 and c3 registers). The last two methods set the constant // color registers.