Archived

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

athlon

RHW component in customvertex

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
www.creative-asylum.com

Share this post


Link to post
Share on other sites