I am trying to use the stencil buffer to cap a clipped solid.
1- But the geometry contains coplanar faces and this creates artifacts : I guess it is the classical z-fighting.
It is too difficult to change the geometry ; Is there a way with opengl to manage the z-fighting problem ?
2- There is anoter artifact : a lot of edges of the non-clipped solids have the color of the capping plane. I guess that it is the same z-fighting problem on the intersection of 2 faces. How do you solve this problem ?
Thanks for your help
Z-Fighting can be avioded by small increments/decrements to the final z-values. OpenGL provides
and the state
to account for situations like the one you mentioned.
I did a quick test using your advice and I obtained better results on the edges. So I will look to this function to find the good parameters and maybe obtain good results for the faces.
Thanks for your answer.
I looked at glPolygonOffset. With this function I need to know what to offset. In my case I do not know the geometry. But maybe I can know the sets of polygons which represent volumes.
So do you think that doing a very small different offset for each volume may be a solution ? For example :
for each volume
i = i+inc;
Do you think that a simple solution like this exists ?