Archived

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

Eric

A Better Projection Matrix

Recommended Posts

Eric    138
The game we''re working on transforms vertices in software (and then sends transformed-&-lit vertices to D3D). Currently my projection matrix looks like this (where x and y are just some values based on fov): x 0 0 0 0 y 0 0 0 0 0 1 0 0 1 0 By the way, the transformation code looks like this (this is pseudo-code for the actual assembly that''s used): w'' = x*m30 + y*m31 + z*m32 + m33 x'' = (x*m00 + y*m01 + z*m02 + m03) / w'' y'' = (x*m10 + y*m11 + z*m12 + m13) / w'' z'' = (x*m20 + y*m21 + z*m22 + m23) / w'' Everything works fine, but I understand there is a better way to set up the projection matrix, so that the z values are more "spread out" over the z-buffer''s range. In the SDK, they recommend this for the proj matrix: // farval = 6400, nearval = 10 // Q = farval / ( farval - nearval ), about 1.001 x 0 0 0 0 y 0 0 0 0 Q 1 0 0 -Q*nearval 0 This doesn''t work, though. It doesn''t look like this proj matrix produces good z'' values. Also, I would love to just let D3D handle all the transforms, but, for now at least, I''m stuck with this.

Share this post


Link to post
Share on other sites