Microsoft DirectX 8.0 (C++) |
Loads the three-component vector dot-product of the two colors in the source operand registers.
dp3 tDest, tSrc0, tSrc1
This instruction generates a scalar result, but replicates it to all specified output channels.
dp3 r, s1, s2 ; s1 dot s2 replicated to all channels
Note that the dp3 instruction is a fundamentally a vector operation, and is therefore always performed in the vector pipeline. Using it with the Alpha Replicate input argument modifier (.a) input argument modifier just indicates that its result should be propagated to the alpha channel as well. In other words, dp3 can be specified as an alpha operation only when it is also the color operation, and must also use the same arguments.
dp3 r0.rgb, t0, v0 dp3 r0.a, t0, v0
Or equivalently,
dp3 r0, t0, v0
will cause the grayscale result of the dp3 operation to be copied into both the color and alpha channels of r0.
A different instruction can be specified in the alpha channel of the result.
dp3 r0.rgb, t0, v0 mul r0.a, t0, v0
The dp3 instruction usually benefits from the Signed Scaling input argument modifier (_bx2) applied to its input arguments if they have not already been expanded to signed dynamic range. When used for lighting, the saturate instruction modifier (_sat) instruction modifier is often used to clamp the negative values to black, as shown in the following example.
dp3_sat r0, t0_bx2, v0_bx2 ; t0 is bump, v0 is light direction