PDA

View Full Version : Alpha blending problem



cOg
02-23-2000, 11:45 PM
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.

AndersO
02-24-2000, 12:02 AM
Yes, I think so. First you draw your non transparent things then you draw transperant things back to front.

Bob
02-24-2000, 12:59 AM
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

02-24-2000, 01:18 AM
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);
...
}

02-24-2000, 01:31 AM
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)