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?
The Transparency Conundrum
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.
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.
To OP: Your objects with any sort of transparency should have a separate bucket and it should be the last bucket to draw.
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?
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
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.
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement