Order independent transparency and temporary buffers

In both Cass original paper about order independent transparency and Mark Kihlgards presentation at this years siggraph it’s implied that you need to store each off the layers in a temporary buffer which you composite back to front at the end.

I don’t see why this needs to be the case, for most types of transparency it should be possible to do the compositing on the fly.

If we for example use blending of the form glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) and have three layers (just so I can explicitly type out the result, the approach works with any number of layers) the final color should be:

rgb_final = rgb_0 * a_0 + (1 - a_0) * (rgb_1 * a_1 + (1 - a_1) * (rgb_2) * a_2) = 
            rgb_0 * a_0 + (1 - a_0) * a_1 * rgb_1 + (1 - a_0) * (1 - a_1) * a_2 * rgb_2

This means that if we keep the product of (1 - a_0) … (1 - a_i) in the alpha channel of our destination buffer we can multiply the incoming rgb-layers with this before adding them to the destination buffer.

In short:

  • A fragment program outputs [rgb * a, 1 - a]
  • Set glBlendFuncSeparate(GL_DST_ALPHA, GL_ONE, GL_ZERO, GL_SRC_ALPHA)
  • The destination buffer is cleared with [0, 0, 0, 1] before we start rendering

At the end of the rendering we will have correct rgba-channels in the destination buffer to correctly blend it with the background using glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA).

Am I missing something here, why haven’t I seen this in any of the order independent transparency presentations?

/A.B.

Originally posted by brinck:
[b] In both Cass original paper about order independent transparency and Mark Kihlgards presentation at this years siggraph it’s implied that you need to store each off the layers in a temporary buffer which you composite back to front at the end.

I don’t see why this needs to be the case, for most types of transparency it should be possible to do the compositing on the fly.

Am I missing something here, why haven’t I seen this in any of the order independent transparency presentations?[/b]
Simple, because the simplest and by far the fastest way is to just use openGL’s built in blending or write a shader that simulates this process in detail.

I didn’t analyze your code that much, and i don’t know if it will work, but it sure could use a bit of clarification. (shorter code != faster code)

Perhaps you should just test your idea? That would answer all your doubts better than any of our speculations here.

I don’t really under stand what you are doing, but maybe it could be related to an idea I posted a few years back?

http://www.opengl.org/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic;f=11;t=000118#000000

After looking at your math, I can’t see how it would work. Or if you are doing depth peeled layers from back-to-front (like I do) why you don’t just do standard blending?

I don’t see how you can use this for order independant transparency. All you do is you change the order to front-to-back. So when you are already sorting, you can just as well sort back-to-front and do normal transparency.