Jump to content
  • Advertisement


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


A Better Projection Matrix

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

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

  • 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!