Alpha blending problem

In my engine i must render the transparent polygons after i rendered the other polygons. If i dont do that i can only see some of the other polygons thru my transparent polygon.
It seems like an sorting problem or something.
Or must the transparent polygon always be putted in after all the other solid polygons?

Sorry for my bad english.

Yes, I think so. First you draw your non transparent things then you draw transperant things back to front.

The reason why you have to draw the transparent polygion after all other polygons, is that the z-buffer is updated when you draw a transparent polygon. So if you draw a solid polygon behind a transparent one, you can’t see because it fails z-buffer tests.

Maybe it’s possible to disable z-bufferupdates (but still test z-buffer when drawing) when you draw a transparent polygon…

Bob

Something like this should work (assuming that you’re using a depth- (Z) buffer):

  1. Draw opaque objects with depth-buffer writing ON

  2. Disable depth-buffer writing

  3. Draw transparent/translucent objects. Objects will be tested against depth-buffer but no values will be written to it.

  4. Enable depth-buffer writes

I.e.

TheDrawFunction() {

DrawOpaqueObjects()

glDepthMask(GL_FALSE);

DrawTransObjects();

glDepthMask(GL_TRUE);

}

I forgot - using the scheme above the z-order of opaque and transparent/translucent objects is not important, but … Depending on what kind of transparent objects you are drawing, the individual order of transparent objects might be important (since you’re not updating the depth-buffer).

(Oh, I also forgot a “;” behind DrawOpaqueObject(), but I guess you noticed that)