Jump to content
  • Advertisement
Sign in to follow this  
QQemka

Blending order

This topic is 754 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

Hello. I've read that to make blending work you have to first render all opaque objects and then the transparent, because the opaque object would spoil the effect when rendered on the transparent. Is there any way around this? It seems extremely hard to separate transparent and opaque objects to render them in proper order when you have many objects on your scene. Whats the solution?

Greetz

Share this post


Link to post
Share on other sites
Advertisement

You also have to render all your transparent triangle back to front.  This is the basic reason you need to lay down opaque objects first... you need a dest color "to begin with".

 

edit - also are you talking about a forward or deferred renderer?

Edited by Infinisearch

Share this post


Link to post
Share on other sites

Hello. I've read that to make blending work you have to first render all opaque objects and then the transparent, because the opaque object would spoil the effect when rendered on the transparent. Is there any way around this? It seems extremely hard to separate transparent and opaque objects to render them in proper order when you have many objects on your scene. Whats the solution?

Greetz

You have to separate transparent stuff from opaque, transparents require separate handling no matter what technique you use. There are ways around the order dependence of rendering transparent objects, but those come with their own drawbacks, and you have to still handle the rendering of these objects separately. Now the thing is, that separating the two types of objects is a problem that can be solved easily, simply by marking either the object or the objects materials as transparent manually. (Basicly puting a checkbox up in the level editor or somewhere that marks if the object is transparent or not. If I remember correctly UE4 does it similarly.) It's something that cannot be automated properly, even if you detect somehow that the objects texture have a valid alpha channel, who knows if that channel's values are actually use for transparency, or the shader that reads the texture uses them for something entirely different. After you have the bool flags set, the rendering itself is easy, either you loop through your objects twice, or you build two separate lists of objects, and loop through those during rendering.

Share this post


Link to post
Share on other sites
I'm afraid there's no shortcut here if you want "real world" results with blending vs opaque objects

Share this post


Link to post
Share on other sites

Okay, so the basic idea is - first render all opaque, then all transparent (no difference in order of transparent) - profit?

Share this post


Link to post
Share on other sites
There are "order independent transparency" methods, but they are more complicated, require more resources, and have corner-cases where they give wrong results.
So, in general, you need to render opaque first.

Okay, so the basic idea is - first render all opaque, then all transparent (no difference in order of transparent) - profit?


Render all opaque (preferably front to back, for speed reasons, but it's not required).
Render all transparent objects (must be back to front, or the visuals will be wrong).

Share this post


Link to post
Share on other sites

The only case where you don't have to render translucent objects in back-to-front order is where they don't overlap.  The whole point of back-to-front order is so that rendering of overlapping translucent objects will work right, both in terms of the blend equation and of depth testing.

 

Checking that objects don't overlap might be more expensive than just doing the sort, however.

 

Some cases you're just not going to bother sorting every single translucent object.  If, for example, you have multiple particle emitters in a scene, each emitting hundreds of particles, you're probably going to want to sort by emitter rather than by particle, and the result can look OK.

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!