3d z-buffer issue

Andreas Raab Andreas.Raab at gmx.de
Sun Sep 22 02:46:04 UTC 2002


Jon,

> Are you saying that if I a world size of (2000.0 @ 2000.0) 
> the z-buffer precision isn't high enough to do that?

I did a quick google search to find a relevant site explaining the
problem and here is one (there are probably gigazillions more since your
question ranks very high in the FAQ of real-time graphics):

http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html

I'll quote the most relevant below:

The Resolution of Z.
What people often fail to realise is that in nearly all machines, the Z
buffer is non-linear. The actual number stored in the Z buffer memory is
related to the Z coordinate of the object in this manner: 

  z_buffer_value = (1<<N) * ( a + b / z )

  Where:

     N = number of bits of Z precision
     a = zFar / ( zFar - zNear )
     b = zFar * zNear / ( zNear - zFar )
     z = distance from the eye to the object

  ...and z_buffer_value is an integer.


This means that the precision of Z is proportional to the reciprocal of
the actual Z value - and hence there is a LOT of precision close to the
eye and very little precision off in the distance. 
This reciprocal behaviour is somewhat useful because you need objects
that are close to the eye to be rendered in great detail - and you need
better Z precision for detailed objects. 

However, the consequence of this is that most of your Z buffer's bits
are storing insanely fine detail close to the near clip plane. If you
pull the near clip closer to your eye, then ever more bits are dedicated
to the task of rendering things that are that close to you, at
considerable cost to the precision a bit further out. 

It follows that in most cases, flimmering can be greatly reduced - or
even eliminated by moving the near clip plane further from your eye.

...

Cheers,
  - Andreas




More information about the Squeak-dev mailing list