Jump to content
  • Advertisement
Sign in to follow this  
xinvar

Transparent Objects

This topic is 4795 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, My objective is to display many objects in the scene, some transparent, some not. I read the NeHe tutorial and searched this forum (and google of course) but wasn't lucky enough. Basically I already know that I would need to display the opaque objects first, then transparent objects with depth test enabled but depth buffer writing disabled. I also need to sort all vertices of transparent objects and display them back-to-front (or front to back) with GL_BLEND enabled and the corresponding BlendFunction. Is my understanding correct? Are there any detailed tutorials on this? I would appreciate any hints.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by xinvar
My objective is to display many objects in the scene, some transparent, some not. I read the NeHe tutorial and searched this forum (and google of course) but wasn't lucky enough. Basically I already know that I would need to display the opaque objects first, then transparent objects with depth test enabled but depth buffer writing disabled.

It doesn't really matter whether depth buffer writing is enabled, since you're drawing back-to-front. Also, you don't HAVE to draw all the opaque objects first; it just helps increase efficiency by reducing either overdraw or sorting time.
Quote:
I also need to sort all vertices of transparent objects and display them back-to-front (or front to back) with GL_BLEND enabled and the corresponding BlendFunction.

You need to sort the faces, not the vertices. Sorting the vertices will have a rather bizarre effect if you're using them in triangle strips or something. Otherwise, yeah, you've got it pretty much the same.

Share this post


Link to post
Share on other sites
Thanks a lot for the quick answer, Sneftel!

Quote:
It doesn't really matter whether depth buffer writing is enabled, since you're drawing back-to-front.

That's the point! Actually I was wondering why none of the information I read talked about disabling depth buffer writing.

Quote:
Also, you don't HAVE to draw all the opaque objects first; it just helps increase efficiency by reducing either overdraw or sorting time.


Can I draw all transparent objects then some opaque objects? Say when I draw an opaque object that happens to be in between of two transparent objects, since depth writing wasn't disable when I drew the transparent objects, this opaque object would be totally occluded by the front transparent object. But the desired fact is to see-through the transparent to the opaque object.

Quote:
You need to sort the faces, not the vertices. Sorting the vertices will have a rather bizarre effect if you're using them in triangle strips or something. Otherwise, yeah, you've got it pretty much the same.


How can I sort faces? What if two faces intersect?

Share this post


Link to post
Share on other sites
Quote:
Original post by xinvar
Can I draw all transparent objects then some opaque objects? Say when I draw an opaque object that happens to be in between of two transparent objects, since depth writing wasn't disable when I drew the transparent objects, this opaque object would be totally occluded by the front transparent object. But the desired fact is to see-through the transparent to the opaque object.

If you aren't drawing back-to-front, you need to use Z-writing. If you are drawing back-to-front, you don't need to use Z-writing. I'm not sure what your line of thought here is.

Quote:
How can I sort faces? What if two faces intersect?
There's no good way to deal with intersecting faces in a one-pass situation. Luckily, situations where partially transparent faces intersect and actually matter are rare. If you absolutely need this, check out "depth peeling".

Share this post


Link to post
Share on other sites
Quote:
If you aren't drawing back-to-front, you need to use Z-writing. If you are drawing back-to-front, you don't need to use Z-writing. I'm not sure what your line of thought here is.


Okay I see your point here.

Quote:
There's no good way to deal with intersecting faces in a one-pass situation. Luckily, situations where partially transparent faces intersect and actually matter are rare. If you absolutely need this, check out "depth peeling".


Here's a simple question: I have two (big) quads with texture, both of them are transparent. They intersect in the middle. I could display each quad as two seperate quads (so in total I would have 4 quads) then sort them. Is there a better way to do this?

Share this post


Link to post
Share on other sites
Yes, you can tesselate them so that they no longer intersect. The "better" method (doesn't involve tesselation, which is slow, but does involve multiple passes, which is also slow) is, as I mentioned, depth peeling. Depth peeling basically allows you to draw transparent objects without sorting.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
Also, you don't HAVE to draw all the opaque objects first; it just helps increase efficiency by reducing either overdraw or sorting time.


I am pretty sure that in order for transperancy to be rendered correctly, you have to draw the transparent objects last in back-to-front order.

Share this post


Link to post
Share on other sites
Yep, you're right. you do.

...what was your point? I think we're saying the same thing. If you want, you can sort the opaque objects along with the transparent ones; if not, you have to render them all before the transparent ones.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
If you want, you can sort the opaque objects along with the transparent ones;


I sorta didn't catch that point.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!