Jump to content
  • Advertisement


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


RHW component in customvertex

This topic is 6353 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What does the rhw component do in customvertices and why does''nt the settransform function change the position of vertices with rhw.

Share this post

Link to post
Share on other sites
NVidia docs state that DX un-projects your vertices using rhw and then tries to clip them (sounds pretty dumb to me). As for SetTransform, while position doesn''t change (since it''s already projected - why should it?), texture and fog appearances do.

Share this post

Link to post
Share on other sites
By CUSTOMVERTEX I assume you mean a transformed and lit vertex (ie. one where you are doing the transformation and lighting and are supplying vertices in SCREEN SPACE or CLIP SPACE. (Also assuming D3D, though this is generally applicable too).

1. SetTransform has nothing to do with the vertex because you''re doing your own transformation.

2. The vertex is only back-transformed (un-projected) if you ask for clipping on the vertices - clipping is performed by the D3D transformation engine, and since you have skipped that stage, it has to go back by one step to camera or world space.

3. RHW is the Reciprocal of Homogenous W.

a. The transformation required for the projection needs a homogenous 4x4 matrix rather than a 4x3.

b. Which means the position vector for each vertex also gets an extra element called W (X,Y,Z,W) which is initially set to 1 (X,Y,Z,1).

c. W is transformed by the projection matrix in the same way as X,Y,Z would be if you did the transform by hand (vector = vector * Matrix).

d. RHW is 1/W (the Reciprocal of W in Homogenous space)

4. Hardware often interpolates RHW across all 3 vertices of a triangle (in the same way as colours with Gouraud shading) - the interpolated value is used for perspective correct texturing, fogging, W-buffering amongst other things.

Simon O''''Connor
Creative Asylum Ltd

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!