View Single Post
Old Feb 28, 2002, 01:23 AM   #3
Near Dark
Join Date: Sep 2000
Location: Ohio, USA
Posts: 874
Boke is still being judged by the masses


"what do the 3 & 4 stand for, what do they mean.. "

The dp3 and dp4 just multiply two vectors together and return a scalar which is the sum of the 3( or 4) multiplications. Just like you are describing.
dp3 does an xyz or rgb multiply between two 3 component vectors.
dp4 does an xyzw or rgba multiply between two 4 component vectors.

They can be used for many things.. but the main thing you'll see them used for is matrix multiplies to transform vertices.

In direct3d the m4x4 instruction is really just a macro.

So... m4x4 r0, v0, c0 expands to->
dp4 r0.x, v0, c0
dp4 r0.y, v0, c1
dp4 r0.z, v0, c2
dp4 r0.w, v0, c3

v0 is the vertex being transformed.
c0 is the first row of a 4x4 matrix.
c1 is the second row.
c2 is the third row.
c3 is the fourth row.
The result of the transformation is stored in r0.

The shader registers are made up of 4 numbers. You access the individual parts with modifiers... hence the r0.x, r0.y...
The c0 and v0 above, because they have no modifiers, are treated just as if you had typed c0.xyzw or v0.xyzw . ( I think I read that this will change with the 2.0 shader version... you will have to type in the modifiers )

One thing the dp3 instruction can be used for is to transform normals, since you don't need any translation or perspective applied to them you don't need the fourth row & column. ( I hope I don't have my rows/columns mixed up )

Last edited by Boke : Feb 28, 2002 at 01:36 AM.
Boke is offline   Reply With Quote
Advertisement (Guests Only)
Login or Register to remove this ad