Jump to content
  • Advertisement
Sign in to follow this  
Lode

4x4 matrices in video hardware

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

Are all matrices in the hardware of the video cards and/or 3D API 4x4? Is it possible that the bottom row of the matrix is not stored in memory? After all it's always 0 0 0 1, except for doing a perspective projection, but you can as well just divide x and y through z. Also, are length 4 are length 3 vectors used? And, is the hardware and/or 3D API constantly dividing x, y and z of length 4 vectors through w to make sure that w is 1 all the time? After all, doing something like taking the average position doesn't make a lot of sense if w is different in both. I'm especially wondering if it stores the bottom row of the 4x4 matrix, because memory is the most expensive thing that can be attempted to reduce to as little as possible for efficiency. I'm wondering if it's actually more efficient to store the bottom row for all rotation, translation, etc... matrices to support this one matrix that does the perspective transformation, or that it turns out to be more efficient to reduce memory.

Share this post


Link to post
Share on other sites
Advertisement
When using shaders this is up to you. Personally, I store world, view, worldview, bone matrices, etc as 4x3, and projection or worldviewproj as 4x4.

4x3 matrices not only save constants, but also save an instruction if they're oriented correctly. A 4x4 can be multipled by a vector as either mul, mad, mad, mad, OR dp4, dp4, dp4 dp4, depending on if the matrix is stored transposed or not. A 4x3 can be multipled by a vector as either mul, mad, mad, mad, OR dp4, dp4, dp4 (or 3 dp3s for normals and tangents).

Share this post


Link to post
Share on other sites
Sign in to follow this  

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