Massively Multiplayer
Seamless Open-World
Real Time Strategy

Twitter   Facebook   Google+   YouTube   E-Mail   RSS
The One Man MMO Project: Avoiding Particle Sorting
By Robert Basler on 2014-12-21 11:46:14
Homepage: email:one at onemanmmo dot com

As I've added more and more particle effects to The Imperial Realm::Miranda I've started to see problems with drawing order. The most obvious problem is sometimes when the camera moves during explosions and the smoke alternates in front of and behind the flowers on the terrain. It's not so pretty. The large bulk of my particles are transparent (have cut out bits) but I have a few that are truly translucent (partially see-through bits) which really complicates things.

I spent most of Thursday afternoon researching particle sorting alternatives, there is Weighted, Blended Order-Independent Transparency (OIT) (and another) and one with some beautiful ascii drawings and last, the solution I adopted from

My particles are simulated on the GPU and rendered with a geometry shader so any sorting solution would need to be on the GPU. Particle sorting on the GPU is possible with a bitonic sort, but that's a challenging feature to implement. The real killer for that idea is that I have a number of different materials for my particles. If I'm going to the trouble to sort my particles, I want them all to be sorted, not just within individual particle systems. That means they all need to use the same ber-material. Add to that that each particle system is currently managed as a separate vertex array (within one larger VBO) sorting would require some significant re-engineering.

Looking at that stackoverflow link that suggested avoiding the problem, I remembered reading something in the Unity documentation about manually specifying the render order of objects. Given that the most blatant problem is flowers rendering on top of explosion smoke, I ripped out the old "transparent" material pass flag (which only actually caused all transparent objects to be rendered last,) and put in a "renderorder" attribute. Now flowers render before smoke, and problem solved.

New Comment

Cookie Warning

We were unable to retrieve our session cookie from your web browser. If pressing F5 once to reload this page does not get rid of this message, please read this to learn more.

You will not be able to post until you resolve this problem.

Comment (You can use HTML, but please double-check web link URLs and HTML tags!)
Your Name
Homepage (optional, don't include http://)
Email (optional, but automatically spam protected so please do)
What is 5 multiplied by 1? (What's this?)

Admin Log In

[The Imperial Realm :: Miranda] [Blog] [Gallery] [About]
Terms Of Use & Privacy Policy