| Microsoft DirectX 8.1 (vertex shader versions 1.0, 1.1) | 
Computes the reciprocal of the source scalar.
rcp dest, src
To learn more about registers, see Registers.
The following code fragment shows the operations performed.
if(src.w == 1.0f)
{
    dest.x = dest.y = dest.z = dest.w = 1.0f;
}
else if(src.w == 0)
{
    dest.x = dest.y = dest.z = dest.w = PLUS_INFINITY();
}
else
{
    dest.x = dest.y = dest.z = m_dest.w = 1.0f/src.w;
}
The output must be exactly 1.0 if the input is exactly 1.0. A source of 0.0 yields infinity.
Precision should be at least 1.0/(222) absolute error over the range (1.0, 2.0) because common implementations will separate mantissa and exponent.
If the source has no subscripts, the x-component is used.
// This example changes the vertex color from green to white. // The max instruction clamps the result to 1.0. vs.1.0 m4x4 oPos, v0, c0 ; transform vertices by view/projection matrix rcp r0, c5 ; take the reciprocal of 0.5 max r1, r0, c4.y ; clamp the output to max of 1 mov oD0, r2 ; result is white // The resultant vertex color is white 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 colorGray[] = {0, 0, 0, 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 the color green. The last SetVertexShaderConstant method 
binds the C5 register with the color gray.