GPU Particle System - Particles remain alive after stop()

Hello, just wondering why the active count for particles remains 50 (in this example) even after stopping the system?

Shouldn’t it stop the emission and the particles that remain would die out after expiring?

I noticed this in my project, somehow the particles that are supposed to expire become visible again and float in the air after I hit stop().

Is this some config issue? I’d like the particles to be completely removed after their life goes to zero.

Hello! Checking the code, it seems that stop doesn’t reset the _currentActiveCount ( Babylon.js/packages/dev/core/src/Particles/gpuParticleSystem.ts at master · BabylonJS/Babylon.js · GitHub), but it does set the _stopped attribute to true, which is passed to the GPU: Babylon.js/packages/dev/core/src/Particles/gpuParticleSystem.ts at master · BabylonJS/Babylon.js · GitHub and stops the spawn of new particles: Babylon.js/packages/dev/core/src/Shaders/gpuUpdateParticles.vertex.fx at master · BabylonJS/Babylon.js · GitHub. But the existing particles are going to expire naturally.

You could call dispose instead of stop to completely remove everything?

1 Like

The non GPU system works as expected and removes the particles after stopped.

I don’t know why the GPU system wouldn’t work the same way?

The particles are not removed, they stay floating around but are invisible. They consume draw calls. I somehow made them visible in my own project. Don’t know how to repro but they are never removed from the scene.

If you call dispose() it will certainly remove everything but how are you going to re-use it then?
Also it simply removes all the currently alive particles which makes the effect look bad.

In any case, I will be using the non-GPU one since it seems to work nicely.

This is expected:

GPU particles cannot be removed from the CPU (well we can but it is overly expensive). Hence the choice to simply skip the stopped ones

By the way, it does not generate additional draw calls as the GPU particles are all rendered in one draw call :wink:

1 Like