Archived

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

NogginBoink

Really Basic Question on Z values

Recommended Posts

Okay, the default viewport has z-clipping planes at 0.0 and at 1.0. Obviously, I don''t want all of my objects in world space to be limited to z-values between 0 and 1. What transformation is used to expand my z-depth in world space?

Share this post


Link to post
Share on other sites
Are you using perspective projection?

Syntax:

D3DXMATRIX *D3DXMatrixPerspectiveFovLH(
D3DXMATRIX *pOut,
FLOAT fovY,
FLOAT Aspect,
FLOAT zn, // Z-value of the near view-plane
FLOAT zf // Z-value of the far view-plane
);

Just change zn and zf values.

Share this post


Link to post
Share on other sites
quote:
Original post by DrunkenHyena
You''re viewport Z values are different than your World Space Z values. You set the limits with your Projection Matrix, and then they get mapped to the 0 - 1.0 range.



Right.

So what actually does the mapping?

Share this post


Link to post
Share on other sites
You set a near and far clipping plane in the projection matrix. This handles the distance to the camera and maps the clipping planes to the z-buffer values between 0.00 and 1.00.
It''s unfortunate that in 3D you have x-y-z for coordinates and that the depth buffer is called the z buffer. Still you shouldn''t mix those two z''s as they are completely different. If you are standing at (0,0,0) and the player turns 90 degrees to the right so he is looking along the x axis then the x distance is used for depth and z is left/right.

Share this post


Link to post
Share on other sites