PDA

View Full Version : What is the default direction for Z depth testing



dabltu
03-04-2013, 12:46 PM
I am not specifying a transformation matrix. All my data is inbetween -1 and 1 in X, Y and Z. If I use Z depth testing it shows a triangle with -Z values in front of triangles with +Z values. I always thought the default view is pointing down the -Z axis. If this were the case then +Z values would be in front of -Z values.

What is the default direction for Z depth testing?

David

tonyo_au
03-04-2013, 09:55 PM
Depth testing has nothing to do with the world Z values. It is a non-linear relative value based on how far the fragment is from the eye point. So if the camera is looking in the -z direction (the result of using the identity matrix) then more positive z values appear in front of less positive ones; but if the camera is looking in the +z directions the reverse is true.

Have a read of this
http://www.songho.ca/opengl/gl_transform.html