-
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.
-
Junior Member
Regular Contributor
Re: Alpha blending problem
Yes, I think so. First you draw your non transparent things then you draw transperant things back to front.
-
Senior Member
OpenGL Guru
Re: Alpha blending problem
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
-
Re: Alpha blending problem
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);
...
}
-
Re: Alpha blending problem
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)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules