View Full Version : z-buffer fighting
11-03-2000, 04:18 AM
is there anything else, beside keeping your znear/zfar ratio sensible, that can eliminate nasty z-buffer fighting? just wanted to see from the more experienced if there are techniques I am not aware of...
11-03-2000, 07:09 AM
For static scene, you can sort the polygons for each normal direction (+X,-X,+Y,-Y,+Z,-Z) :
Draw the carpet before the floor,
Draw a poster before the wall…
and use GL_LESS for Z-buffer comparison.
The problem remains for polygons that have different orientation but it’s better than before!!!
11-03-2000, 08:49 AM
if it's about polygons that have the same orientation and are virtually on the same plane (like posters on the wall or burnt spots from using the flamethrower in a game http://www.opengl.org/discussion_boards/ubb/wink.gif) polygon offset would be the way to go... just set the polygon offset to a value != 0 (+ or - depends on your depth buffer function) and then draw the poster/burnt spot. the offset will be added (i think, not sure) to the zbuffer values before the depth test, so that even polys that are in exactly the same plane can be rendered over each other.
11-04-2000, 05:57 AM
The obvious solution is to increase the depth buffer bits. 16bit->32bit.
also its possible to use 2 or more differnet depth ranges in your program so draw all all near stuff with one range and change it for the far stuff
11-08-2000, 03:32 AM
Thanks for replies. However, I'm not sure if and how I could use some of these techniques in my particular application. I'm basically rendering a bsp map with frustum and back face culling, so the number of faces to draw changes dynamically. Dunno how I could efficiently add z buffer sorting on top of this. Currently, I set my znear and zfar to 1.0 and 4000.0 respectively, so the ratio seems ok, but I'm experiencing nasty z buffer problems, like banding, texture distortions...
I use GL_LESS. I request 32-bit depth buffer.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.