Sorting of transparent objects, special case: particles

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Sorting of transparent objects, special case: particles

      Hello everyone!

      As i have been promoted from wiritng physics to reworking the whole scene-graph and rendering part of our engine i am currently working on a lot of stuff all at once. One of the tings is correct sorting of objects to ensure artifact-less transparency. For most of the objects i am thinking about sorting the triangles and not the complete objects, that should give me enough precision for most cases.

      But we have one special case in which this will not be good enough: Explosions and other dense particle effects where lots of billboard objects are placed in a small area. And this is where i am currently a little bit stuck. There are some realy complex techniques out there to do this but i am looking for a simple and always working solution.

      So does anyone have an idea on how to do this? Maybe a fragment wise sorting technique?

      Thanks :)
    • AFAIK, sometimes people use additive blending for smoke/dust particle effects, this way you don't have to sort particles.

      Anyway, I think sorting tons of particles is way to slow for the real-time game engine.

      For what I've read you either use alpha cutouts or additive blending. Usually only whole objects are sorted by distance, not triangles.

      p.s. There is also thing called 'order-independent transparency' (google for that) however I don't really know if it's applicable for particle effects.
      Looking for a job!
      My LinkedIn Profile
    • Yeah, i was thinking about some special treatment for all the particle stuff too, but didnt find the right thing that sounds easy enough to implement by now ;)

      For the transparency sorting i realy think i will go for sorting triangles otherwise the chance is high to get some artifacts from overlapping transparencies... Just think of a planet with transparent rings that are all the way around the planet... those you cannot just sort in depth order... but if your break it down to triangles it will work most of the time...
    • Hi,
      it really depends on your scene you want to render. if you have for example a retro-style rendering with not that many polys you maybe can do per triangle sorting, but if you use objects with many polygons I think you can't do that per triangle (and keep in mind, you have to upload the sorted stuff per frame which is also not the fasted thing on earth ;) ). Not knowing anything about your stuff I would also opt to sort per object and slice big objects into smaller subobjects (maybe based on collision shapes or something like that to keep the polys in local groups. and when you preprocess the objects you can include a control value how fine the subobjects should be to experiment what is the best setting for your app).

      If you have really big transparent polys you maybe have to subdivide them to get proper transparency, again: it all depends on your scene...

      another small hint: try radixsort, never use quicksort for things like that (quicksort is really bad on already nearly sorted values!)
    • Only to clarify things: I have an understanding of why and how to sort alpha blended objects in theory, i am just looking for an optimal way.

      And i am not realy sure if on the fly partitioning of objects would be so much faster than triangle sorting. Oh and the ring thing was just an example for an alpha blended object that is in front and in the back of some other object at the same time.

      Prepartitioning of objects might be a solution for things like the planet rings, i could choose the partitions so theres always a clear destinction of "front" and "back"...

      I also know that there are several ways of solving this that dont need the objects or triangles or polys to be sorted but most of these methodes have problems with deferred shading in one or another way and tend to make the whole rendering process more complex than it needs to be.
    • Partitioning by objects is definitely much faster than sorting by triangles. Partitioning by object only changes the transform matrix to be sent to the GPU which you're already doing anyway. While partitioning by triangle requires you to possibly stalling your GPU by accessing your vertex buffer, changing each vertex property, then resubmitting them again. But then again, how would you even sort by triangles? Would you incorporate the world transform for each vertex? That would mean limiting your vertex buffer for just that one object.

      Unless i'm missing something here. Are you rendering your world using a bsp tree?

      EDIT: Also, if your renderer supports multi-stage/step rendering, you could set the material of your translucent object to be rendererd twice; first render the back with front face culling, then render front with back-face culling (with sorting).

      The post was edited 1 time, last by BrentChua ().

    • Lots and lots of questions.... :)

      I know that it is much faster to sort by object, but it has its drawbacks and pitfalls... Everytime something is not clearly only in front or in back of something else you risk artifacts... Sorting by triangle would give a lot more granularity to the sorting, but indeed, its time consuming and complex. The more i read into it i get the feeling that mostly the educational books advice for triangle-wise sorting and everyone else is going with object sorting and carefully watching the content to avoid the problem-cases.

      At the moment a lot is still undecided, i am reading a lot about space partitioning and i have not yet decided where to go, bsp trees are one option. I think i will go for a multi-graph approach, nut just one scenegraph.

      And for the rendering i am thinking about a mix of deferred rendering and forward rendering certain things and then do combine it.