?/TD> |
Microsoft DirectX 9.0 |
Computes the three-component dot product of the source registers.
dp3 dst, src0, src1 |
---|
where
Pixel shader versions | 1_1 | 1_2 | 1_3 | 1_4 | 2_0 | 2_x | 2_sw | 3_0 | 3_sw |
---|---|---|---|---|---|---|---|---|---|
dp3 | x | x | x | x | x | x | x | x | x |
The following code fragment shows the operations performed:
dest.w = (src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z) + (src0.w * src1.w); dest.x = dest.y = dest.z = unused;
In version 1_X, this instruction cannot be co-issued.
In version 1_X, this instruction does not automatically clamp the output result between zero and one. If clamping is necessary, use the Instruction Modifiers.
This instruction runs in the vector pipeline, always writing out to the color channels. For version 1_4, this instruction still uses the vector pipeline but may write to any channel.
dp3 r0.rgb, t0, v0 // Copy scalar result to RGB components.
An instruction with a destination register RGB write mask may be co-issued with dp3 as shown below.
dp3 r0.rgb, t0, v0 // Copy scalar result to color components. +mov r2.a, t0 // Copy alpha component from t0 in parallel.
The dp3 instruction can be modified using the Signed Scaling input argument modifier (_bx2) applied to its input arguments if they are not already expanded to signed dynamic range. For a lighting shader, the saturate instruction modifier (_sat) is often used to clamp the negative values to black, as shown in the following example.
dp3_sat r0, t0_bx2, v0_bx2 // Here t0 is a bump map, v0 contains the light direction.
Minimum operating system | Windows 98 |
---|