How to mix Particles Z position with sprites?

I want to display particles mixed up with sprites (some in front, some behind).
Naturally, I gave particles the same predicate as sprites, but then something strange started to happen: some particle systems are displayed entirely on top of the sprites and some behind. It’s completely unclear what affects what. And what to do about it?

Ok, please, can you just tell me how exactly the particles get into the sprite batch? Having that knowledge would solve all the problems.

2 Likes

The particle component registers each emitter as a render list entry (source)

And, each component type registers it’s own render list entries, which means they will not be part of each others batches.

I guess for interleaving sprites with any particles on screen, I’d use depth testing :thinking: Perhaps @jhonny.goransson has a better idea.

Hi!

I am not 100% sure this will be useful, but some time ago, I achieved what you are trying to do and I can more-or-less remember how.

My technique involved having two particle FX emitters in the game object, one behind the GOs and one in front of them, and playing both of them at the same time. You need to change the predicate (or possibly the material? I can’t remember what worked now), and then look into emitter space, and the z-layer of the particle FXs.

I don’t think I went any deeper than that in order to get everything working.

Good luck.

Aha!
But since the sprite batch is still split by Z, the emitter with its particles ends up somewhere in the middle there. I see.
So I shouldn’t count on particles and sprites interleaving. Sad but not fatal.

1 Like

Not in the current way it’s done at least.

It would be nice to (in the future), to be able to share vertex buffers across component types and collections. A first (tiny) step towards that is we want custom vertex format support for our components.

2 Likes