The Transparency Conundrum

Started by
11 comments, last by Yann L 12 years, 10 months ago
I have been working on my scene graph in C++, and I am fairly pleased with results so far. However, I have run into a major roadblock; I know I cannot be the first with this problem. I am curious as to what the accepted solutions are.

After my scene graph tree updates all the matrices, I place the items into buckets (to be rendered) organized primarily by shader. (I plan on sub-organizing by texture soon because I understand that to be an expensive operation as well.) However, now I am stuck on the issue of transparency. I have my buckets sorting the items by distance from the camera in order to properly render from back to front (for proper transparency). What do I do if I have items A B C D E where A C and E are in one bucket but B and D are in another? Do I really have to bite the bullet and rapidly switch shaders/textures to draw them in the right order? Is there another solution I am unaware of?
Amateurs practice until they do it right.Professionals practice until they never do it wrong.
Advertisement
You'll have to render semi-transparent objects after all the opaque objects. You're free to sort the objects within those two groups any way you like.

You'll have to render semi-transparent objects after all the opaque objects. You're free to sort the objects within those two groups any way you like.


The sorting of the semi-transparent objects matters. You have to sort them back to front for most situations. The only exception that I know of is if you are using cumulative transparency (accumulating colour*alpha in the colour buffer) and have depth writing turned off.
Graphics hardware has now advanced to a point where OIT (order independent transparency) is often just as fast, or even faster than the age-old CPU presorted transparent geometry. With the added benefit of pixel perfect transparency in all cases, the availability of much more advanced programmable blending and the possibility to easily add thickness dependent effects like refraction or fogging.

I've switched my engine to OIT some time ago, removing all this distance sorting crap. I never looked back.
How does order independent transparency work?

To OP: Your objects with any sort of transparency should have a separate bucket and it should be the last bucket to draw.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal


Graphics hardware has now advanced to a point where OIT (order independent transparency) is often just as fast, or even faster than the age-old CPU presorted transparent geometry. With the added benefit of pixel perfect transparency in all cases, the availability of much more advanced programmable blending and the possibility to easily add thickness dependent effects like refraction or fogging.

I've switched my engine to OIT some time ago, removing all this distance sorting crap. I never looked back.


I am very interested in hearing more about this. I had no idea we had progressed to this point. How does one go about achieving this OIT? I am using GLSL for all my rendering. What is the next step?
Amateurs practice until they do it right.Professionals practice until they never do it wrong.
Me too actually... is this something exposed by the graphics card as a feature?
Latest project: Sideways Racing on the iPad
Things to google for would be "depth peeling", "weighted average" or "weighted sum" in combination with order independent transparency. Or get a quick overview of some methods (from 2008) here: http://www.slideshare.net/acbess/order-independent-transparency-presentation
f@dzhttp://festini.device-zero.de

Me too actually... is this something exposed by the graphics card as a feature?


No, it is not. It is a technique that you implement.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Things to google for would be "depth peeling", "weighted average" or "weighted sum" in combination with order independent transparency. Or get a quick overview of some methods (from 2008) here: http://www.slideshar...cy-presentation


cheers, should come handy
Latest project: Sideways Racing on the iPad

This topic is closed to new replies.

Advertisement