The classic blend vs depth problem.


    Jul 02 2008 | 4:01 pm
    Hi,
    Here is a patch in which I tried to illustrate the problem as clearly as possible.
    Plane A intersects plane B, A and B are both half-transparent. But they never blend as expected, like in the attached image. Either A blends with B or B blends with A, depending on which one is rendered first.
    I know this problem is impossible to solve due to the hardware restrictions of the graphics card. But there have been miracles in this community before, so in case anyone comes up with a trick, feel free to let me know ;)
    Mattijs

    • Jul 02 2008 | 5:05 pm
      The most interesting solution I know to this problem is here: http://www.shaderx6.com/TOC.html
      "3.5 Deferred Rendering using a Stencil Routed K-Buffer by Louis Bavoil and Kevin Myers"
      It's certainly non-trivial to implement but simple in concept. What you do is write fragments that stack on top of each other into a buffer such that when everything is drawn, you can sort them based on z depth. They use the stencil buffer as a counter and a multi-sampling texture hack with feedback to store the drawn fragments. I know this is not terribly helpful right now, but I thought I pass the info along since it's the most efficient method to do this that I've read about.
      wes
    • Jul 02 2008 | 5:20 pm
      Wesley,
      This is definitely helpful, thanks! At least we have a clue where to look for a solution.
      So what you're saying is they render the objects separately and then sort them per pixel based on the z-depth? You're right, that concept seems simple. But it sounds like swapping around a few megabytes per object for every frame. Although, as you say, if they did it in the book it might be time to see if we can transform the code from the book to Jitter :)
      Mattijs
      Quote: wesley.hoke@gmail.com wrote on Wed, 02 July 2008 19:05 ---------------------------------------------------- > The most interesting solution I know to this problem is here: > http://www.shaderx6.com/TOC.html > > "3.5 Deferred Rendering using a Stencil Routed K-Buffer by Louis > Bavoil and Kevin Myers" > > > It's certainly non-trivial to implement but simple in concept. What > you do is write fragments that stack on top of each other into a > buffer such that when everything is drawn, you can sort them based on > z depth. They use the stencil buffer as a counter and a > multi-sampling texture hack with feedback to store the drawn > fragments. I know this is not terribly helpful right now, but I > thought I pass the info along since it's the most efficient method to > do this that I've read about. > > wes > ----------------------------------------------------