how to render overlapping transparent objects?

9 replies to this topic

#1MarekKnows.com

Valued Member

• Members
• 190 posts
• LocationOntario, Canada

Posted 09 December 2005 - 03:34 PM

I am using OpenGL to render my scene but I'm run into a problem when trying to render two transparent objects that are overlapping one another. My two objects are inner twined so that at some points, object A is on top of object B and in other points it is the other way around. A simplification of this would be to image the lower case letter n and u. if you but the n on top of the u and then have the left side such that the n is ontop of the u but the right side with the n under the u then you get the same overlapping problem.

anyway back to my problem.... so I have two objects that are semi transparent. How do I render these objects so that the colors are calculated correctly.

If I render object A first then B then where ever B is below A, the colors don't look right.
C++, 3D OpenGL and Game Programming video tutorials:
www.MarekKnows.com
Play my free games: Ghost Toast, Zing

#2roel

Senior Member

• Members
• 698 posts

Posted 09 December 2005 - 03:40 PM

depth peeling

#3MarekKnows.com

Valued Member

• Members
• 190 posts
• LocationOntario, Canada

Posted 09 December 2005 - 04:19 PM

what does that mean?
C++, 3D OpenGL and Game Programming video tutorials:
www.MarekKnows.com
Play my free games: Ghost Toast, Zing

#4Alex

Valued Member

• Members
• 152 posts

Posted 09 December 2005 - 04:47 PM

Why exactly do the objects intersect? Is there no way to avoid that? (Split the object into convex subobjects). Then do the normal z sorting of transparent objects.

Alex

#5MarekKnows.com

Valued Member

• Members
• 190 posts
• LocationOntario, Canada

Posted 09 December 2005 - 07:44 PM

Alex said:

Why exactly do the objects intersect? Is there no way to avoid that? (Split the object into convex subobjects). Then do the normal z sorting of transparent objects.

Alex

I'm writing a general 3D graphics rendering program. therefore the objects that are rendered are out of my control.... it depends on what the user trys to render on the screen. If the user chooses to make two transparent objects that are aligned in such a way that they are overlapping as shown in http://www.maduckgam...z3d/overlap.jpg , then my rendering code doesn't work
C++, 3D OpenGL and Game Programming video tutorials:
www.MarekKnows.com
Play my free games: Ghost Toast, Zing

#6Reedbeta

DevMaster Staff

• Administrators
• 5308 posts
• LocationSanta Clara, CA

Posted 09 December 2005 - 07:54 PM

Most rendering systems do not correctly handle intersecting transparent objects; as roel mentioned, depth peeling is the way to do this, but it is relatively slow and it is not easy to detect when it should be applied. Ordinarily z-sorting is enough and that is all that most graphics engines do.

In other words, if your users make transparent objects intersect and don't split them into enough sub-components for z-sorting to work, it's their own fault
reedbeta.com - developer blog, OpenGL demos, and other projects

#7MarekKnows.com

Valued Member

• Members
• 190 posts
• LocationOntario, Canada

Posted 09 December 2005 - 08:01 PM

hmm, interesting. I thought that there should be an easy solution to this problem because when I load my VRML scene in any web browser that has a vrml viewer, the scene is rendered correctly.
C++, 3D OpenGL and Game Programming video tutorials:
www.MarekKnows.com
Play my free games: Ghost Toast, Zing

#8Alex

Valued Member

• Members
• 152 posts

Posted 09 December 2005 - 09:12 PM

Well..you have the usual generality/quality/speed trade off.

It's certainly possible to write something that handles all these cases properly..

The big crap about current 3d hardware is that it is rather inefficient at rendering the kind of data you normally want to render (many diverse, semi transparent animated objects). Actually...that's not quite right... there is no efficient way to supply this kind of data to the hardware.

Alex

#9XORcist

Member

• Members
• 39 posts

Posted 12 December 2005 - 06:54 AM

Quote

The big crap about current 3d hardware is that it is rather inefficient at rendering the kind of data you normally want to render (many diverse, semi transparent animated objects). Actually...that's not quite right... there is no efficient way to supply this kind of data to the hardware.

Oh yeah.. Something we've been arguing for like an year:whistle: . Seemingly simple things get so complicated.

You will face this problem in case of alpha-channel blend modes( blend_src_alpha , blend_inv_src_alpha ).

For additive translucency blend-modes, sorting is not needed. Depth writes must be turned off.

#10Goz

Senior Member

• Members
• 575 posts

Posted 13 December 2005 - 04:12 PM

mmakrzem said:

I'm writing a general 3D graphics rendering program. therefore the objects that are rendered are out of my control.... it depends on what the user trys to render on the screen. If the user chooses to make two transparent objects that are aligned in such a way that they are overlapping as shown in http://www.maduckgam...z3d/overlap.jpg , then my rendering code doesn't work

Actually in the case you show there its easy. Use alpha testing and you can draw in any order ya like ... mmmm ... 1-bit alpha.

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users