Microsoft DirectX 8.1 (vertex shader versions 1.0, 1.1) |
Compares the two sources to see if either is greater than the other. Sets the destination to 1.0 if the first source operand is greater than or equal to the second source operand; otherwise, the destination is set to 0.0.
sge dest, src0, src1
To learn more about registers, see Registers.
The following code fragment shows the operations performed by the sge instruction.
dest.x = (src0.x >= src1.x) ? 1.0f : 0.0f; dest.y = (src0.y >= src1.y) ? 1.0f : 0.0f; dest.z = (src0.z >= src1.z) ? 1.0f : 0.0f; dest.w = (src0.w >= src1.w) ? 1.0f : 0.0f;
// This example compares the component color values between two sources. vs.1.0 m4x4 oPos, v0, c0 ; transform vertices by view/projection matrix mov r0, c4 ; load pink sge r1, c5, r0 ; compare gray to pink, component to component mov oD0, r1 ; output result // The resultant vertex color is cyan (0,1,1) and is shown below. // The red component is 0 because src0.x < src1.x. The green component // is 1 because src0.y > src1.y and the blue component is 1 because // src0.z > src1.z.
// 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 colorPink[] = {0.75, 0, 0, 0}; m_pd3dDevice->SetVertexShaderConstant(4, &colorPink, 1); // set register C5 float colorGray[] = {0.5f, 0.5f, 0.5f, 0.5f}; m_pd3dDevice->SetVertexShaderConstant(5, &colorGray, 1); // 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 // data for the color pink. The last SetVertexShaderConstant method binds // the C5 register with data for the color gray.