Microsoft DirectX 8.0 (Visual Basic) |
Performs a conditional operation, comparing the value in r0.a with 0.5.
cnd tDest, tSrc0, tSrc1, tSrc2
This instruction can only be used to compare the value in r0.a with 0.5. If the alpha (r0.a) is greater than 0.5, then the first source is returned as the result; otherwise, the second source is returned.
The following example shows how this instruction might be used.
cnd d, r0.a, s1, s2 ; d = ( r0.a >0.5 ? s1 : s2 )
To compare two values you can use the following pixel shader code because a - (b - 0.5) = a - b + 0.5.
sub r0, v0, v1_bias cnd r0, r0.a, c0, c1
As mentioned above, r0.a is the only value that can be placed in the first source argument and the compare value must be "greater than 0.5."