clipplane, multipass, and display lists

I have a multipass rendering system.

When I have an object clipped with a clipplane0 I see my first object poking through in certain cases. Basically some angles I see it rendered in correctly, some angles I see just the first pass. Other times I see the just first pass, but on some parts I see the 2nd pass correctly interacting-it looks like z fighting.

When I use display lists this zfighting problem goes away on my GF4Ti.

My use of display lists is pretty limited. I set up all rendering (textures, lighting, depth buffer, etc) then call my display list, which if I disable for compatiblity reason just does the following: apply/lock a vertex buffer, call glDrawElements, unlock vertex buffer.

Anybody have any ideas about what I can do about this situation?


That’s a common problem with clipping planes, different clipping plane setups don’t produce invariant depth values. One way to get around it is to draw the first pass with polygonOffset, and then draw the subsequent passes without, using glDepthTest(GL_LESS).

Another option is to replace the clipping plane with an alpha texture that clips away (sets alpha to zero) the same fragments as the clipping plane would. That way you get the invariance back, propably with some speed increase too. I guess it’s possible that the driver does this optimization automatically when compiling a display list. Could it be, that’s a pretty wild optimization, I’d say…