Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Drawing a scene with transparent and opaque objects correctly...

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2012
    Posts
    21

    Drawing a scene with transparent and opaque objects correctly...

    Hello.
    In case I want to draw a scene having both transparent and opaque objects, should I do the following:

    1. Draw the opaque objects first, with Z-Buffer enabled.
    2. Specify alpha-blending function.
    3. Mask Z-Buffer (Z-Buffer is read, but not updated).
    4. Draw the transparent objects.

    Am I right?

    Thanks,
    Heinrich

  2. #2
    Junior Member Regular Contributor
    Join Date
    Jan 2011
    Location
    Paris, France
    Posts
    230
    Yes

    Another solution is to use one Order Independent Transparency algo such as Dual Depth Peeling
    http://www.google.fr/url?sa=t&rct=j&...GzqJCA&cad=rja
    @+
    Yannoo

  3. #3
    Member Regular Contributor
    Join Date
    Apr 2010
    Posts
    491
    4. Draw the transparent objects.
    Nitpick: for correct blending this should be "draw transparent objects from back to front".

  4. #4
    Junior Member Newbie
    Join Date
    Aug 2012
    Posts
    1
    Quote Originally Posted by The Little Body View Post
    Yes

    Another solution is to use one Order Independent Transparency algo such as Dual Depth Peeling
    http://www.google.fr/url?sa=t&rct=j&...GzqJCA&cad=rja
    Hi,
    I am using the dual depth peeling algorithms in my application to render transparent primitives. I have 2 lists in my application, one consists of transparent primitives, and the other one of opaque primitives. I have observed that if I render any opaque primitives BEFORE rendering transparent primitives using one of the algorithms in the dual depth peeling demo, the opaque primitives do not get rendered.
    On the contrary, If I draw the opaque primitives AFTER rendering transparent primitives using the algorithm, the order of rendering gets disturbed, and the output, consequently, does not come out as expected.

    Is there any restriction while using the algorithm for rendering transparent and opaque primitives together that I'm not aware of/that I've missed? Please help me as I'm stuck with this for almost a week.

  5. #5
    Member Regular Contributor Rosario Leonardi's Avatar
    Join Date
    Aug 2008
    Location
    Italy
    Posts
    352
    You should check your status.
    There are two main way to blend transparent object. OVER and UNDER (and other less used method like MAX, MIN, ADDITIVE blending that always create artifact)
    Over operator is the most popular, you have to render object from the farthest to the nearest with color = source * srcAlpha + dest * (1-srcAlpha)

    With the under operator you draw object from the nearest to the farthest. You have to use the following operation color = destAlpha * (srcAlpha * srcColor) + destColor and alpha = (1-srcAlpha) * destAlpha
    Cause this you have to clear the alpha to 1.0 then draw your alpha object with UNDER operator and then render opaque object with the same formula (but the alpha will alway be one).

    The problem with under operation is that you always have blending enable. Otherwise you have to render alpha object on another buffer and the compose the buffer at the end.
    ~ ~ I tell you, realtime 3D is made of blood, sweat and screams! ~ ~

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •