> From: Alan D Workman <[EMAIL PROTECTED]>

>
> I have a question regarding the ratio (3000 to 1) of front to back clipping
> distance for 16 bit Z-Buffers. The video card I'm currently using provides
> a 32 bit Z-buffer. I'm curious as to whether I'm able to increase that
> ratio or does the ratio of 3000 to 1 still need to hold true no matter what
> the size of the video card's Z-Buffer. If having a larger Z-Buffer makes it
> possible to increase the ratio, what should I expect as a maximum tolerable
> ratio. Thanks in advance.

You'll have to experiment with your application and graphics card.  A short
answer is that you can probably make the ratio much greater (i.e. 800K).

The problem is that the loss of resolution is really a non-linearity in the
transformation of z-values.  With a high ratio, the resolution of the z-buffer
near the front plane gets higher and but the resolution gets worse near the back
plane.   More bits of Z will give you more resolution at near the back plane,
but the non-linearity will be the same.

Perhaps this will help.  The OpenGL reference manual says:

"The greater the ratio of zFar to zNear is, the less effective the depth buffer
will be at distinguishing between surfaces that are near each other.  If

        r = zFar / zNear

roughly log2(r) bots of depth buffer precision are lost.  Because r approaches
infinity as zNear approaches 0, zNear must never be 0".

I'm not sure exactly what "loosing" bits of precision means or where the log2()
equation comes from.  Long ago I played with the math involved here and it gets
nasty very fast.  Perhaps the bits of precision lost refers to the loss of
resolution at the back plane.  Anyway, let's play with this idea a bit.

If a ratio of 3000 "looses" log2(3000) ~= 11-12 bits of precision (2^11 = 2048),
for a 16 bit depth buffer this leaves 4-5 bits of resolution, which would
indicate only 16-32 "units" of depth buffering.  This seems awfully coarse, I
suspect that 3000 is the limit of what a 16-bit z-buffer can handle without
being complely useless. The resolution near the front is good and at the back it
is pretty bad.

The javadoc for View suggests that a ratio of 100-1000 is better.  So let's plug
in 128.  This "looses" 7 bits of resolution leaving 2^11 or 2048 "units" of
resolution.  For a 24 bit depth buffer this would leave 17 bits of resolution,
or 130K units of resolution.  For a 32 bit depth buffer this would leave 21 bits
of resolution or 2M units of resolution.  Put another way, a ratio of 128 on a
16 bit depth buffer equals a ratio of 32K on a 24 bit depth buffer and a ratio
of 8M on a 32 bit depth buffer.

All this makes me think that 3000 is probably a pretty good limit for a 24-bit
depth buffer, which would make the equivalent ratio on a 32 bit depth buffer be
3000 * 2^8  ~= 800K.  This also means that the equivalent ratio on a 16-bit
z-buffer would be on 12!

Doug Gehringer
Sun Microsystems

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to