PDA

View Full Version : "z fighting" when clip plane is exactly on top of a face



Dboy
05-09-2003, 08:59 AM
Hey all,
Thought you might be able to help me out here. I have a GLClipPlane that is getting inserted exactly on top of face on my model. (They have the same normal and point) When I start to rotate the model, I get very bad destruction on the face. Some of the face is visible and some is clipped. It looks very much like Z fighting. This happens even when I turn off hardware acceleration.

I read a previous post that had a similar problem and the possible solution was a polygon offset, which is what I have been looking at as well.

Is this fighting between the clip plane and the face enabled just something that is going to happen or is there another way to get rid of it?

Thanks

SirKnight
05-09-2003, 01:19 PM
You will have to use glPolygonOffset to get rid of the z-fighting. There are other little tricks you can do with the depths of your objects but polygon offset will be the best thing to do. Try this before you render the face and see if it helps any:
glPolygonOffset( -1, -2 );

If that doesn't work, then tweak those values a bit. Any document will describe the two parameters so you can know what you are doing a little better. http://www.opengl.org/discussion_boards/ubb/smile.gif

-SirKnight

SirKnight
05-09-2003, 01:20 PM
Oh also I almost forgot. You will also want to enable GL_POLYGON_OFFSET_FILL before you render and disable it after you are finished of course.

-SirKnight

dorbie
05-09-2003, 02:19 PM
Polygon offset will not help with a clip plane issue like this.

If large contiguous portions of the polygon are flickering on and off then you're really looking at numerical rounding issues as the vertices vs the plane equation are transformed through the modelview with slightly differing rounding errors.

OTOH you may have some kind of texture based fragment kill clip plane, on an NVIDIA this may produce visible aliasing in the texture interpolator when the plane equation of the clip is coplanar with a surface, or it may just have the same issues as geometry clip (or both).

These are really different manifestations of a similar problem, the root cause is you're asking the graphics hardware to answer an impossible question.

Offset the clip plane from the surface if you can.


[This message has been edited by dorbie (edited 05-09-2003).]

SirKnight
05-09-2003, 05:09 PM
Polygon offset will not help with a clip plane issue like this.


Oh...well how about that. http://www.opengl.org/discussion_boards/ubb/biggrin.gif

-SirKnight