Archived

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

Meaning of D3DFVF_XYZ/RHW

This topic is 5396 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

D3DFVF_XYZ = Untransformed for 3D
Vertices are specified in world space and will undergo transformations from world space to viewpoint to projection/screen space.

D3DFVF_XYZRHW = Transformed for 2D
Vertices are specified in projection/screen space (i.e. they won''t need to be transformed in any way). The RHW is the distance of the Z plane from the screen (set this to 1 in most cases).


pan narrans | My Website | Study + Hard Work + Loud Profanity = Good Code

Share this post


Link to post
Share on other sites
quote:
Original post by CGameProgrammer
AFAIK W can be ignored unless you''re for some reason using W-depth buffers.


W gets used tons by the rasteriser: perspective correct texture lookup (i.e. t''=t*(1/w)), perspective correct colour interpolation, fogging etc.

That''s the reason for setting RHW to 1 rather than 0 for sprites, because t''=t*0 means t=0, i.e. screwed texturing.

One of the most instructional things anyone can do to teach themselves what RHW really does is to write their own version of the T&L pipeline, i.e. take some vertices in world space and apply the transformations required to get the coordinates into screen space, then compare the results with D3D T&L.


--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
quote:
Original post by S1CA
Pan Narrans: While W _could_ be the distance in eye space, its reciprocal certainly isn''t

Sorry, I was quoting from a book and I must not have worded it correctly:

"The only real difference between the 2-D and 3-D coordinates is the addition of the rhw variable, which is the reciprocal of the homogeneous W. In English, this typically represents the distance from the viewpoint to the vertex along the Z-axis. You can safely set rhw to 1.0 in most cases."


pan narrans | My Website | Study + Hard Work + Loud Profanity = Good Code

Share this post


Link to post
Share on other sites
Well 2D transformations was what I was thinking of. There''s really no reason to do your own transformations now that there are T&L cards, and even if not using one it''s safe to assume the driver/API''s transformation code is well-optimized.

Of course writing a software engine and using no API at all is fun, I did it a couple of years ago. Well it was a software polygon renderer but not exactly an ''engine''

~CGameProgrammer( );
DevImg.net - Post screenshots, comment on others.

Share this post


Link to post
Share on other sites