Transparency and hardware acceleration

I’m drawing an object twice with alpha blending enabled (on the second draw pass) in order to have a transparent environment mapping on it.
I noticed that with hardware acceleration disabled the transparent drawing has big problems…
Is this a software limitation of OpenGL or am I doing something wrong?
Thanks for you time

You can see the pictures here:
Hardware accel. enabled:
Hardware accel. disabled:

The code I’m using is the following:

drawPrimitive(shape); //draw the solid object



drawPrimitive(shape); //draw the transparent object with environment mapping on it


The problem here is known as “z-fighting”, two polygons fighting for the z. The software implementation seem to have slightly different z for each type of primitive. You may try using more permitive z test (less or equal instead of strict less), or disabling depth test for second pass (or better, clear it between passes), or using polygon offset.

I believe that according to the spec, the same polygon should be rasterized the same way. Maybe try with Mesa GL software implementation ?

Yup, this is a classic problem of z invariance (or the lack of invariance) leading to z fighting. ZbuffeR is correct OpenGL does not guarantee that if you change state (like turning texturing on and off) that the depth values on the same primitive will match the earlier renderings. Most hardware today does offer z invariance even though it doesn’t have to. You could use glOffsetPolygon, enable texturing and use a white modulating texture or do as ZbuffeR suggests & try Mesa for software OpenGL, no guarantees there either.

Thanks a lot!
Using glPolygonOffset() solves the problem :slight_smile: