Sign in to follow this  
nerdtron

transparent rendering -- question

Recommended Posts

I'm rendering a bunch of objects, followed up by a couple transparent objects (I'm using a fixed blending function so you can partially see through the objects). This works really well. By rendering the transparent objects last as is recommended, none of the opaque objects get clipped by the transparent ones and you can see through them to the objects behind them. The problem is the interaction of the transparent objects with each other. Due to the z-buffer, the one that gets rendered last, if behind another transparent object will get hidden. Is there a good way to achieve the desired result here? Namely, I don't want transparent objects to affect each other in terms of depth, but I want the opaque objects to affect the transparent ones. In other words, if a transparent object is behind an opaque one, I shouldn't see it. But if a transparent object is behind another transparent object I should see it through the first one.

Share this post


Link to post
Share on other sites
You can fix the occlusion issue by disabling writing to the z-buffer when drawing transparent objects.


//Draw Opaque Objects
...

glDepthMask(GL_FALSE);

//Draw Transparent Objects
...

glDepthMask(GL_TRUE);



While now you will be able to see all of your transparent objects, unfortunately the colors will no longer be completely accurate. This may be good enough for you depending on what your scene looks like, but if you want real transparency you have to sort all of your transparent objects from far to near.

See this for more explanation:
Transparency Sorting




Share this post


Link to post
Share on other sites
But if you just disable the depth test when drawing transparent objects, what happens when a transparent object is behind an opaque object? I still want the transparent object to be hidden by an opaque object, just not by another transparent object.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this