# Thread: Transparency - depth test in 3D

1. ## 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 ?

Paul

2. ## 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. ## 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. ## 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.

5. ## 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. ## 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. ## 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

#### Posting Permissions

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