Sign in to follow this  
AtmaWeapon

The Projection Matrix

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this