PDA

View Full Version : Z Fighting - I know, I know, use polygon offset, but...



Robbo
04-29-2002, 05:26 AM
The thing is, Polygon Offset doesn't seem to work correctly for me. The situation is like this:

I have 3 concentric cylinders which may or may not touch at certain points. Now, where they touch I'm hopefully alpha-testing fragments away but sometimes the fragment isn't alphad' away and I'm left with a bit of z fighting where that fragment shows through. Because the fragments are all part of cylinders, its difficult to work out what parameters to use in polygon offset or even whether its appropriate at all!

Any hints? (ehem...)

chrisATI
04-29-2002, 06:50 AM
Originally posted by Robbo:

The thing is, Polygon Offset doesn't seem to work correctly for me. The situation is like this:

I have 3 concentric cylinders which may or may not touch at certain points. Now, where they touch I'm hopefully alpha-testing fragments away but sometimes the fragment isn't alphad' away and I'm left with a bit of z fighting where that fragment shows through. Because the fragments are all part of cylinders, its difficult to work out what parameters to use in polygon offset or even whether its appropriate at all!

Any hints? (ehem...)
what are you using for your near and far clip planes?

iNsaNEiVaN
04-29-2002, 04:40 PM
use the stencil buffer.

Robbo
04-29-2002, 11:29 PM
Stencil buffer sounds ideal but the problem is it isn't hardware accelerated - so its going to slow down my fps considerably.

My near\far clip plane is currently 1.0 to 150.0 - however, I've played around with it (ie. 0.1 - 200.0 or 1.0 to 1000.0 etc.).

I've solved the problem for now by alpha testing away bits that touch or might touch - not quite correct but it works.

GeLeTo
04-30-2002, 12:16 AM
By moving the near plane or using glDepthRange you can get similar functionality as polygon offset. I've had much more consistent results using the above methods than using glPolygonOffset.

Robbo
04-30-2002, 01:04 AM
Actually, I think the stencil buffer is the answer because changing the near\far planes or using glPolygonOffset will alter selection buffer results anyway - and I'm using the GL selection buffer at the moment (pending geometry based hit testing implementation).