ParticleSystem culling?

Hi everyone,

ParticleSystems keep rendering even if you look away: https://playground.babylonjs.com/#0K3AQ2#3646

Is it possible to enable culling for CPU particles?


Alternatively, what would be the best way to enable/disable a CPU ParticleSystem? (I mean disable when not seen, re-enable when seen again)

This looks like it is working: https://playground.babylonjs.com/#0K3AQ2#3647 (tl;dr: particleSystem.particles.length = 0) But it is not documented how to pause/resume+hide/show a particle system (maybe for a good reason idk). Will this have any side effects? Any caches left, cleanup skipped, etc…?

N.B. We can pause the system [1], but it will still be drawn.

Edit: there is a particleSystem.reset function which does essential that. So this should be alright then.

Edit2: In case it is not possbile with current Babylon: It is not actually too bad to do this yourself. There is Camera.isInFrustum(Mesh). So you need a probe mesh, link this (somehow) to the particle system, and finally use that probe onCameraViewChanged. Etc…

Best wishes
Joe

[1] Pause Particle System?

2 Likes

Current Babylon does not do it as particles can spread far away from source and the bounding box would be expensive to track.

I really love the idea though. Do not hesitate if something is missing to help you ease the integration in your app.

1 Like

Ohh, I did not think about that :open_mouth: