Obi Official Forum
Render order with particle systems (VFX or shuriken) - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Fluid (https://obi.virtualmethodstudio.com/forum/forum-3.html)
+--- Thread: Render order with particle systems (VFX or shuriken) (/thread-2899.html)



Render order with particle systems (VFX or shuriken) - benank - 29-04-2021

Hi there,

I've been trying to add a particle system (testing both VFX Graph and shuriken) alongside Obi Fluid, but the fluid always appears on top in the game display (scene and game view). I'm assuming that this is because the particle system doesn't write to the Z Buffer. I enabled Z Buffer writing for the VFX Graph and it did work properly, but the VFX Graph had transparency issues with itself (transparent boxes overlapping other particles that causes it to look really bad).

Do you have any ideas on how I could use a particle system near an Obi Fluid and have them interact properly? Aka the render order, z buffer, water displacement shader on the particles, etc. I would like to be able to see particles in front of the fluid, but also be able to see the particles displaced visually by the fluid if looking through it on the other side.


RE: Render order with particle systems (VFX or shuriken) - josemendez - 29-04-2021

(29-04-2021, 05:38 AM)benank Wrote: Hi there,

I've been trying to add a particle system (testing both VFX Graph and shuriken) alongside Obi Fluid, but the fluid always appears on top in the game display (scene and game view). I'm assuming that this is because the particle system doesn't write to the Z Buffer. I enabled Z Buffer writing for the VFX Graph and it did work properly, but the VFX Graph had transparency issues with itself (transparent boxes overlapping other particles that causes it to look really bad).

Do you have any ideas on how I could use a particle system near an Obi Fluid and have them interact properly? Aka the render order, z buffer, water displacement shader on the particles, etc. I would like to be able to see particles in front of the fluid, but also be able to see the particles displaced visually by the fluid if looking through it on the other side.

In 3D graphics in general, transparent objects *must* be sorted from back to front for proper rendering.  This is known as the painter's algorithm.

The zbuffer is not enough in this situation. If you render a transparent object (writing it to the z buffer) and then you render a second object behind it, the pixels of the second object that are obscured by the first one won't be rendered, because the first one wrote to the zbuffer. The end result is that you won't be able to see the second object trough the first one, even though you should be able to. The correct solution is to render the object at the back first, then the one at the front.

When rendering transparent particle systems, this forces to sort all particles from back to front for correct rendering. Things will still break if particles intersect with each other though, as in that case you'd need to sort individual polygons from different particles, or even individual fragments if polygons intersect too. This is probably what happens with the overlapping transparent boxes you mention.

This means that when rendering multiple different particle systems you're out of luck. Obi does not know about VFX graph and vice-versa, so they can't sort all particles properly. Obi will sort its own particles, VFX graph will (probably?) sort his, but they won't be sorted in relation to each other. So some VFX particles might be rendered on top, or Obi particles will. You can't really control this.

You could use render queues to force VFX particles always on top, or Obi fluid particles always on top (which I believe is what should happen by default), but they won't be sorted according to camera perspective, and individual particles won't be sorted with respect to each other.


This is a problem that has plagued 3D rasterized graphics since the very beginning, and is still largely unsolved in practice. There's a class of order-independent transparency (OIT) algorithms that solve this, but they often require specific hardware support or resort to depth peeling which is quite costly: https://en.wikipedia.org/wiki/Order-independent_transparency

Then there's stochastic transparency, which doesn't look as good as alpha blending and it has its own set of limitations.
https://research.nvidia.com/sites/default/files/pubs/2011-08_Stochastic-Transparency/StochTransp-slides.pdf

Neither can be applied in this case, so my opinion is that what you want just can't be done.


RE: Render order with particle systems (VFX or shuriken) - benank - 29-04-2021

Thank you so much for the fast and detailed response! It looks like I won't be able to use Obi Fluid after all and will have to stick to shaders and VFX graph to simulate fluid-like effects, but without any of the actual simulation, only visually.