Archived

This topic is now archived and is closed to further replies.

gamedream

X,Y,Z, RHW

Recommended Posts

gamedream    122
In Direct3D, FVF, it have a "rhw", Actually, I don''t know what is the meaining of rhw, it looks like same as the meaning as Z, but I don''t know is it...can anyone tell me?

Share this post


Link to post
Share on other sites
FenrirWolf    288
Actually, RHW refers to whether or not a vertice is already transformed by the graphics hardware. In other words, converting from the 3d-space X,Y,Z coordinates to a planar screen 2d-space with just a X,Y. If you specify a RHW value of 1.0, then the graphics accelerator will not touch the values and instead just start rasterizing the triangle in screen coordinates.

---
[[ Gaping Wolf Software ]] [[ GameGenesis Forums ]]

Share this post


Link to post
Share on other sites
hplus0603    11347
I think "RHW" stands for "Right Handed W" (which is kind-of weird, seeing as DirectX is generally left-handed).

Specifying it as 1 everywhere means that the card will use the vertex data as-is; that''s true. However, you won''t get perspective correct texture correction that way. If your scene is actually a 3D scene, and you are supplying transformed vertices, then you have to supply the correct W.

Share this post


Link to post
Share on other sites
FenrirWolf    288
Yup, though doing your own transforms is kind of odd. Might as well let the 3d hardware do it, as it most likely is accelerated.

In effect, if you want to draw screen-space oriented triangles (useful for things like HUDs), then set the RHW component to 1.0.

If I remember my software rasterizers right, W comes from the fact that the hardware is converting homogeneous XYZ values back into 3D space for the perspective divide. That probably doesn''t make much sense, I gotta go brush up on it again.

---
[[ Gaping Wolf Software ]] [[ GameGenesis Forums ]]

Share this post


Link to post
Share on other sites
don    431
RHW is an acronymn for "Reciprocal of Homogeneous W". This is just a mathematician''s favorite way of saying 1/W.

To transform a vertex position (x, y, z), the position is first extended to its homogeneous form (x, y, z, 1), then multiplied by the concatenation of the 4x4 transformation matrices. The resulting output coordinate''s x, y, and z values are then each divided by w (or multiplied by 1/w, depending on how you want to look at it), then w is replaced by 1/w (RHW).
RHW is stored in the output vertex instead of w so that when the w value is needed in the rasterizer (for fog and perspective texture mapping calculations), that a multiplication operation can be used to divide a value by w, rather than having to perform a rather expensive divide.

Share this post


Link to post
Share on other sites