Z buffer clipping question

I have a question about the Z-buf. From what I’ve read, and based on some experimentation, I have come to understand that the Z buffer seems to be clamped to a range of 0 to 1.0 and anything outside that range has it’s Z value clamped. Unfortunately, I have a scene which goes deeper than 1.0 and is not being drawn properly due to this clamping of Z. Is there a way to extend the depth of the z-buffer? (Unfortunately, scaling the scene to get the Z values inside 1.0 isn’t really an option.)

Well, the values in the depth buffer are in the range [0, 1], that’s true. However, this is the value after the projection matrix, and you use the projection matrix to scale the scene. You can make the visible part of the scene larger by adjusting the near and far clip planes.

Points located on the near clip plane will be scaled to 0.0 when written in the depth buffer, and points at the far clip planes will be scaled to 1.0 when written in the depth buffer. This means the clip planes defines what is visible, and then they automatically scale the scene to fit it into the depth buffers range.

So you really should forget about the depth buffer range, and only care about the near and far clip planes. If you can get the scene within the clip planes, you will get it into the depth buffer automatically.

or you can use the infinite projection matrix…

marcio