Page 1 of 9 12345 ... LastLast
Results 1 to 10 of 83

Thread: True transparency

  1. #1
    Senior Member Frequent Contributor
    Join Date
    Dec 2005
    Location
    Italy
    Posts
    659

    True transparency

    Hi All,


    We have always believed that true transparency was an hard thing to code. Yesterdeay a coworker suggested the following trick:

    Actually, in OpenGL rendering both opaque (alpha=1) and transparent
    (alpha<1) objects in the same scene is quite easy: First you draw all the
    opaque objects, with depth buffer in normal operation. Then you toggle the
    depth buffer read-only (by glDepthMask(GL_FALSE)), draw the transparent
    objects and make the depth buffer writable again afterwards
    (glDepthMask(GL_TRUE)). There is should be no need for sorting objects by
    their viewpoint distances.
    What do you think?


    Thanks,

    Alberto

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: True transparency

    This "trick" is very old and used by a lot of people.
    But it does not solve the order problems that can happen *between* translucent faces (between 2 convex objects or within 1 concave object).
    That is where you need sorting. Or use order independent transparency, such as additive blending or darken etc.

  3. #3
    Senior Member Frequent Contributor
    Join Date
    Dec 2005
    Location
    Italy
    Posts
    659

    Re: True transparency

    Hi ZbuffeR,

    As always, thanks for your help.

    Can you give me more info (or point me to some resources) about additive blending, darken, etc.

    Our customers are striving for a more realistic transparency.

    Thanks so much again,

    Alberto

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Dec 2005
    Location
    Italy
    Posts
    659

    Re: True transparency

    ZbuffeR,

    I want to be more clear, suppose to have a more complex scenario like the following:



    Is it possible that the only solution is to skip objects' display lists and to sort triangles at each frame before drawing them? It looks so slow...

    Can you please list all the OpenGL transparency approaches sorted from easy to complex to implement?

    We need something more realistic but we are scared from the complexity that always turns out.


    Thanks again,

    Alberto

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Dec 2000
    Location
    Reutlingen, Germany
    Posts
    2,042

    Re: True transparency

    Transparency is a bitch.

    To get it working, you can sort all triangles from back to front (for example using a BSP-Tree). That is computationally expensive and not fun to implement. I can't advise you to do so, though, with complex scenes this won't run fast enough.

    Another solution is to to use "depth-peeling". However that method requires modern hardware and will still be quite slow, but at least you don't need to sort anything. However, from your other posts i suspect, that you need to support older hardware, so that's not really an option, either.

    A third solution, is to only sort by "object" (e.g. group of triangles) and render them roughly from back to front. That's an approach taken very often, because it works well in many situations and isn't difficult to implement (usually). But there will always be situations where it doesn't work properly.

    Looking at your screenshot, i find that your results look quite nice already. If you are not doing it already, you could add sorting by object, and leave it at that.


    There are not really many options, when it comes to transparency. All completely correct solutions are complex and slow.

    Jan.
    GLIM - Immediate Mode Emulation for GL3

  6. #6
    Super Moderator OpenGL Guru imported_dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,966

    Re: True transparency

    You still need to depth sort the transparent objects.

    As has been said it's an old trick, however it is flawed because transparent objects can occlude other transparent objects and can self-occlude.

    You have a nice solution BUT transparency blend results are not order invariant.

    If you have two 75% transparent objects and one occludes the other or vice versa the result will be highly dependent on drawing order. For it to be correct it needs to be sorted back to front.

    Transparency occluding opaque objects in a zbuffered scene has never been a problem except for inexperienced graphics developers.

    Sorting isn't a huge problem either although it can increase state changes etc, however the real problem is that object level sorting is not always sufficient to get it correct.

    Picture two transparent interlocking tori (two chain links).

    Which order do you draw them in as objects to get the correct result? There is no correct order in this scenario.

    A simple object level sort is sufficient for most applications. Rather than a depth sort, try to insert a plane between them and decide which side of the plane the eye is on. Use this mechanism to sort for best object level results.

  7. #7
    Super Moderator OpenGL Guru imported_dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,966

    Re: True transparency

    Quote Originally Posted by Jan
    There are not really many options, when it comes to transparency. All completely correct solutions are complex and slow.
    Yes. Although some graphics hardware with deferred shading internals can handle it automatically (not avilable on mainstream platforms). At the application level there's a need to compromise for good performance.

  8. #8
    Senior Member Regular Contributor LangFox's Avatar
    Join Date
    Oct 2001
    Location
    Shen Zhen, Guangdong, China
    Posts
    102

    Re: True transparency

    Alpha-to-Coverage with MSAA can do the trick.
    Best Regards,
    LangFox


    http://hi.baidu.com/lang_fox

  9. #9
    Senior Member Frequent Contributor
    Join Date
    Dec 2005
    Location
    Italy
    Posts
    659

    Re: True transparency

    Hi Guys,


    Thanks a lot for your thoughts, just a little clarification on the image: this was taken on the internet, it's from SolidWorks CAD application, it doesn't belong to us...

    We already implemented object based sorting (using distances from centroid) but simply putting a semi-transparent box inside another semi-transparent box - with the same centroid - will give an incorrect result.

    Can we say that all modern 3D applications are using "depth-peeling" and require high end hardware? I mean 3D Studio Max, LightWave3D, Maya, etc.


    Where can we find very clear instructions on "depth-peeling"?


    Thanks again,

    Alberto

  10. #10
    Senior Member Regular Contributor LangFox's Avatar
    Join Date
    Oct 2001
    Location
    Shen Zhen, Guangdong, China
    Posts
    102

    Re: True transparency

    depth-peeling can be found in nVidia SDK, GPU Gems and ShaderX series.
    Best Regards,
    LangFox


    http://hi.baidu.com/lang_fox

Page 1 of 9 12345 ... LastLast

Similar Threads

  1. NSOpenGLView visual transparency vs. mouse transparency
    By hidefromkgb in forum OpenGL: macOS
    Replies: 1
    Last Post: 05-12-2015, 01:05 PM
  2. true colour transparency
    By whitedragon10101 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-18-2006, 11:21 AM
  3. TRUE MODE
    By Azazel in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-27-2004, 11:47 PM
  4. True layered fog
    By RCMaster in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 08-22-2002, 06:23 PM
  5. OpenGL window transparency and texture transparency
    By ramalhais in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 03-15-2002, 09:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean