coplanar rendering artifacts

I have a set of utils that do PostScript-style stroking with extrusion. When I use them to draw several strokes along a graph the faces of the strokes are of course coplanar where the strokes intersect. The result is some weird looking artifacts. the colors are almost randomly mixed with odd looking Moire effects. (see attached screenshot). Each stroke is completely rendered separately (i.e. in its own begin/end). I assume this is effect is somehow related to the tesselator/GL rendering being unable to decide who is on top?

I should add that GL_DEPTH_TEST is enabled and set to GL_LESS.

Any suggestions or comments?

TIA

Good old Z-fighting there… :slight_smile: You’d want to disable depth testing (at least depth writing), or do one or both of following: a) move the strokes apart in Z, b) increase the depth buffer accuracy (try moving near & far clip planes).

Thanks, MH. That was exactly the problem. I was hoping not to have to twiddle their position (hoping for some magic I didn’t know about). But it turned out to be relatively straightfoward. Turning off the depth test just made a mess out of the strokes since GL couldn’t figure out what was in front and what was in back. But adjusting the Z value by a tiny amount was the trick. I was actually surprised how little it took. A few binary trials showed that with the model matrix set as

	glu.gluPerspective( 15.0f, (double) width / (double) height, 0.1f, 100.0f);

It only took increments of 0.00002 to make the difference. As you can see here.

Thanks again for pointing out the obvious for me! :slight_smile:

Check out glPolygonOffset for the recommended solution to z-fighting. It takes account of tedious stuff like depth-buffer precision, distance from the camera, etc, that your current solution is still sensitive to.