GPU particles and targetStopDuration

So!

Actually everything works as expected but it is a bit complex to understand :slight_smile:

Some prerequesites:

  • GPU particles are not created. The system has a define pool and only iterate through them. Dead particles are recycled and new ones are built from the same structure. For instance the system creates a buffer of 100 particles at start and the GPU goes through all of them every frame. It updates every particles and then render the same buffer. At the beginning until we reach max capacity we ask the GPU to only process the first few ones while every particles in the buffer are emitted
  • This means that when a particle dies, it is simply repositioned at the source with a fresh set of values
  • When targetDuration is hit, the system stop recycling, meaning that the dead particles remain and become zombies

So on the examples provided by @roland:

This is why with GPU particles you need to add this code if you want to really terminate the system when targetDuration is hit:

ps.onStoppedObservable.addOnce(() => {
        ps.dispose();
    })

Mystery solved :wink:

2 Likes