Results 1 to 7 of 7

Thread: Transparency - depth test in 3D

  1. #1
    Guest

    Transparency - depth test in 3D

    Hello
    I got in a little rendering pb..

    I have 3 3d objects that are transparent and, depending on your rotation, can superposed.

    So How to get rid of the effect resulting in the drawing order ? depending of your view no other object is drawn behind the first you draw (which is transparent).


    So I don't get a uniform transparent behavior.
    In the red book they talk about glDepthMask() when you have a fully opaque object and a transparent one but what about several 3d transparent objects ?

    Thanks for your help

    Paul

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jan 2002
    Posts
    292

    Re: Transparency - depth test in 3D

    Originally posted by paul32:

    In the red book they talk about glDepthMask() when you have a fully opaque object and a transparent one but what about several 3d transparent objects ?
    Why dont you try it and see if it works?

  3. #3
    Guest

    Re: Transparency - depth test in 3D

    Originally posted by mancha:
    Why dont you try it and see if it works?
    Because ALL my objects are transparent. The trick in the red book works because the first object you draw in opaque. In my case it is transparent so when the first object drawn is in front of another transparent object all part of objects that I should see behind the first object are not drawn..

    That is why the red book solution doesn't work for multiple transparent 3d objects

    Paul

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

    Re: Transparency - depth test in 3D

    Your problem is an advanced one. The only real solution is to draw the objects from back to front, meaning to draw the objects that are far away first and the nearest last.
    Real engines do this usually with BSP-Trees (Binary Space Partitioning Trees). If you are interessted in this topic do a search in google.
    However BSP-Trees are a bit work to implement.
    Maybe your program doesnīt need a very complex solution. Maybe you can just take your objects and calculate their center-points. When you draw them you calculate the distance of the camera to the center-points and then draw them in back-to-front order.
    As far as i know there is also an extension that allows to draw blended objects in any order. I donīt know how it is called and i think this extension is not implemented in many drivers, so you certainly wonīt want to use it. Anyway, this is the link to SGIs extension-registry: http://oss.sgi.com/projects/ogl-sample/registry/ .

    Jan.
    GLIM - Immediate Mode Emulation for GL3

  5. #5
    Guest

    Re: Transparency - depth test in 3D

    Originally posted by Jan2000:
    Your problem is an advanced one. The only real solution is to draw the objects from back to front, meaning to draw the objects that are far away first and the nearest last.
    Real engines do this usually with BSP-Trees (Binary Space Partitioning Trees). If you are interessted in this topic do a search in google.
    However BSP-Trees are a bit work to implement.
    Maybe your program doesnīt need a very complex solution. Maybe you can just take your objects and calculate their center-points. When you draw them you calculate the distance of the camera to the center-points and then draw them in back-to-front order.
    As far as i know there is also an extension that allows to draw blended objects in any order. I donīt know how it is called and i think this extension is not implemented in many drivers, so you certainly wonīt want to use it. Anyway, this is the link to SGIs extension-registry: http://oss.sgi.com/projects/ogl-sample/registry/ .

    Jan.
    THank you Jan.

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Jun 2000
    Location
    Shreveport, LA, USA
    Posts
    1,502

    Re: Transparency - depth test in 3D

    This has been discussed many times on the forum. You simply need to sort your triangles, and draw them from far to near. If the objects are allowed to penetrate one another, then you would also need to split some triangles in order to get the correct rendered scene. However, if you have a highend video card, like a fast GeForce 3 or Geforce 4 Ti, then there is a document available on the nvidia developer web page that descibes how to draw transparent objects without sorting.

  7. #7
    Member Newbie
    Join Date
    Jun 2002
    Posts
    33

    Re: Transparency - depth test in 3D

    Hi All,

    Along the same lines of this questrion (and maybe a partial answer) could you not just draw all your non-transparent objects. Turn off writting to depth buffer then draw all the clear objects (read this somewhere else). If all the objects have the same transparency (and colour?) it doesn't matter which you draw first since the effect of drawing any of them is the same?

    fringe

Similar Threads

  1. Perform stencil test only if depth test fails
    By Ray1184 in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 09-23-2015, 01:21 AM
  2. Transparency doesn't work? - Depth test disabled & blend enabled.
    By joehot200 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-15-2014, 03:14 PM
  3. Framebuffer depth test with depth and stencil buffer
    By moldyviolinist in forum OpenGL: Basic Coding
    Replies: 10
    Last Post: 07-29-2013, 08:21 PM
  4. Does Depth Buffer Allow Writing Into When Disabling Depth Test
    By wilburn in forum OpenGL: Basic Coding
    Replies: 16
    Last Post: 12-23-2006, 01:23 AM
  5. Can Alpha Test work the same way as Depth Test?
    By Rong Yao in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 05-13-2004, 02:40 PM

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