Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Z-buffer accuracy analysis  (Read 3302 times)
Lenn
Customers
Community Member
*****
Posts: 876

+/-


« on: June 04, 2010, 09:05:58 AM »

I wanted to make a test to see how accurate the Z-buffer is in practice. It can be calculated in theory based on the near plane, far plane, and floating point accuracy, but somehow that didn't seem right in practical terms.

So I made a test. Two triangles are positioned at xyz = 0,0,0 and then the second triangle is moved back by a small amount. I then move the camera back until the triangle behind starts z-fighting with the triangle in front, and note down the distance at which it happened and the z-difference between triangles. If the z-buffer was "perfect" this would never occur.

Here are my results (click for big):




There are 4 series based on values for the camera near and far planes. For example, the 4th series has the near plane set at 5, and the far plane at 80000. You can see that for example, if the distance between two polygons is 3 tv units and the camera is at above 8000 units there will be z-fighting, and bellow, there won't. I guess that's pretty clear.

These values were obtained by comparing two triangles triangles which had their XY size at 1000x300 , so this is more realistic since there will usually be an angle at which you see geometry, so in fact the distances to some pixels were greater and if calculated strictly by the z-buffer accuracy formula, they would be lower, but for practical purposes this seemed better for me. I'm sure nobody needs this, but I just thought I'd post it anyway. Smiley
Logged

TV3D 6.5 Community Docs - Read, use and please contribute!
Lenn
Customers
Community Member
*****
Posts: 876

+/-


« Reply #1 on: June 04, 2010, 10:25:58 AM »

Oh and BTW, another thing that's important to note is that in case when the near plane was 10 and the far changed from 40k to 80k, (series 1 and 2) the z-fighting distance didn't change (you can see the two plotted points are almost the same). So this is a lesson for everyone, the near plane is much much more important in solving z-fighting than the far plane. If you have z-fighting that's bothering you, try to increase the near plane primarily, and don't worry about the far plane.
Logged

TV3D 6.5 Community Docs - Read, use and please contribute!
ZaPPZion
Moderator
Community Member
*****
Posts: 555


« Reply #2 on: June 05, 2010, 03:22:59 AM »

Thanks Lenn, that's some incredibly usefull information Smiley
I think it's about the ratio between the far and near plane, so that's why increasing the near plane seems to help more than increasing the far plane.
Logged

Check out my website: www.bartkuipers.com
Lenn
Customers
Community Member
*****
Posts: 876

+/-


« Reply #3 on: June 05, 2010, 08:30:58 AM »

Somebody finds it useful? Shocked
Hehe yeah, it's ratio near/far but since it's exponential, the near value is something like N^2 as important, or multiplied in calculation (or if not N^2 then some value like that, i forget).
Logged

TV3D 6.5 Community Docs - Read, use and please contribute!
RuntimeError101
Customers
Community Member
*****
Posts: 252


« Reply #4 on: June 19, 2010, 10:58:18 PM »

Well, thanks for posting this anyway...   Smiley

I've always known about changing the near plane and z-fighting and that, but it was always a bit foggy.  This clears everything up, so now we have a bit of data to work with.
Logged
SylvainTV
Administrator
Community Member
*****
Posts: 4946


WWW
« Reply #5 on: June 23, 2010, 06:03:09 AM »

Also remember that the Z is not really stored directly in Z buffer.
It's rather a multiple of 1/z that is stored to have more precision close to the near plane
Logged

Regards

Sylvain Dupont
TrueVision3D Developer
sylvain@truevision3d.com

TV3D IRC at http://chat.truevision3d.com or on server irc.truevision3d.com #Truevision3D. Come talk with us !
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks