# 4x4 matrices in video hardware

This topic is 4508 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
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).

1. 1
2. 2
3. 3
4. 4
Rutin
19
5. 5

• 14
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
632926
• Total Posts
3009252
• ### Who's Online (See full list)

There are no registered users currently online

×