ParticleSystem and alphaIndex


I’ve been playing around with ParticleSystem and transparency in babylon and found some weird behavior.
It is stated in the docs (Transparency and How Meshes Are Rendered - Babylon.js Documentation) that ParticleSystem is rendered after all the alpha-blended meshes. But in reality if I render a semi-transparent mesh (with visibility 0.99 for example), I notice that it covers my particles independent of what alphaIndex I set to it.

Here is the condensed example based on the other one I found in the playground:

You can see that sphere covers the particle system even if particles are in front of it.
I understand that making particles respect sphere surface may be tricky because of the zbuffer stuff, but for my purposes it would suffice to render the scene the other way - i.e. to have particles rendered on top of the sphere (including the ones that are inside).

Is it possible? I am currently looking at SPS which seems to be promising, but is there any way to do that with the simple ParticleSystem?

Thank you in advance!

Hi and welcome aboard!

Use the renderingGroupId property to render the particle system after the meshes:

The doc is wrong in this regard, I’m going to update it.

Hi, thanks!

I’ve been thinking about using renderingGroupId. But I also want to render some other opaque meshes on top of the particle system, so I wanted to keep objects on the same layers to use the depth buffer.

Then I realized I can use scene.setRenderingAutoClearDepthStencil(2, false); in order to preserve depth buffer between layers. So I implemented my idea in the new playground version and it works just as I need it to:

Thank you for the help

Thank you for this solution. Solved my problem, but raises another question. Has this doc been fixed? I’m only asking because I did the exercise just now of searching through the complete section of ‘particles’ in the new/post-4.2 docs but, couldn’t find this information in this section. Actually, to get a clear understanding of how particles interact with (mesh) alpha blending, you would need to goto

I think there could be a more obvious/visible link to this information in the section ‘particles’ (or in the search, or search with expression…it would have saved me a bit of time, not a lot, but a bit;). A simple suggestion. Have a great day :face_with_monocle:

Yes, the doc in question has been updated, it is Transparent Rendering | Babylon.js Documentation

Contributions are always welcome if you feel some docs could be improved :wink:

1 Like