# The Projection Matrix

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

## Recommended Posts

This is just a really quick question. What is the result after multiplying by the projection matrix? The Model/World and View matrices are simply transforms, rotates, and scales. The projection matrix returns something in "clip space" What exactly is stored in Z and W (3rd and 4th) component of the result. Basically vertexpos * modelviewproj = {x position on screen, y position on screen, What is this, What is this?) I know that the depth buffer is z/w ... so what is Z and what is W?!

##### Share on other sites
It's not really valid to think about what comes out of the projection matrix, since there's an extra DOF in there. What IS valid to think about, is what comes out of the perspective division immediately afterwards. And what comes out there is the projection-space coordinates, with the reciprocal of the depth in the Z component. The W component, of course, is 1. You can find more information on this by looking up "perspective division".

##### Share on other sites
Quote:
 And what comes out there is the projection-space coordinates, with the reciprocal of the depth in the Z component. The W component, of course, is 1.

I don't quite get what you mean. Can you elaborate further. Z does not appear to be reciprocal depth because smaller values are closer to the camera. Also z/w is the depth. This means if W is 1, then z/w = z and I know that's not the case just from experimentation.

##### Share on other sites
Nevermind, I get it now. So assuming z' = z/w what will 1/z' give you? Is that depth-(zmin of the camera clipping plane)?

##### Share on other sites
Pretty much.... well, scaled to the distance between the near and far clipping planes. The reason you don't want to deal directly with the depth (as opposed to its reciprocal) is that it doesn't linearly interpolate correctly in screen-space (which it needs to, for Z-buffering to work).

##### Share on other sites
That makes sense. Ok, so the 1/(z/w) is the depth or rather w/z is the depth. What is this in the scale of 0-1, zmin-zmax. I can't seem to get a straight answer just by experimenting.

Basically the goal here is that I want the depth in the scale of 0-1 in a linear fashion.

##### Share on other sites
That makes sense. Ok, so the 1/(z/w) is the depth or rather w/z is the depth. What is this in the scale of 0-1, zmin-zmax. I can't seem to get a straight answer just by experimenting.

Basically the goal here is that I want the depth in the scale of 0-1 in a linear fashion.

1. 1
2. 2
3. 3
Rutin
22
4. 4
frob
16
5. 5

• 9
• 33
• 13
• 12
• 10
• ### Forum Statistics

• Total Topics
632579
• Total Posts
3007178

×

## Important Information

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!