0
votes

I have a scene that contains both opaque and transparent objects. I split them into 2 groups, opaque and transparent, and sort the opaque from front to back and the transparent from back to front. I turn on the depth buffer writes and the depth test and draw the opaque items from front to back. Then I turn off the depth writes keep the depth test ON and draw the transparent items from back to front.

This all works great but from what I understand I could be drawing transparent items without any specific order. I've gone through articles like this one http://www.openglsuperbible.com/2013/08/20/is-order-independent-transparency-really-necessary/ and saw that order independent transparency can be achieved by changing the blending function... But I just can't really comprehend this.

I tried using those blending equations that are suggested there but I get the wrong combined color for the transparent items that overlap, unless I use the usual (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA). Is this really as simple as it looks there? Am I just missing something simple?

1
Is this for desktop OpenGL or OpenGL ES?Nicol Bolas
Also, did you read the part of that document that talks about "When Order Matters"?Nicol Bolas

1 Answers

0
votes

"Order independent transparency can be achieved by changing the blending function... But I just can't really comprehend this."

I think this is where your misunderstanding lies.

It is not the case that order independent transparency can be achieved by changing the blending function. It is just that some blending functions are intrinsically order independent.

The two common order-independent blending functions are additive (GL_ONE, GL_ONE) and multiplicative (GL_DST_COLOR, GL_ZERO). But if those aren't the correct blend functions for your situation (and commonly they are not), then you're stuck with either sorting or using relatively expensive and complicated order-independent transparency solutions like the A-buffer mentioned in the article you linked.