Multiple ParticleSystems and createEffectForParticles

I’m using createEffectForParticles to provide a custom fragment shader to render particles.

I’m also creating multiple ParticleSystems.

Should I only call createEffectForParticles one time, and reuse the Effect across all ParticleSystems that need it? Or is it more efficient to create an effect for each ParticleSystem.

To be fully shareadble they would need almost the same conditions resulting in the same #define

I would suggest to try it and see if that works ?

Yeah, it works to share the same effect for my case. Creating new instances of the effect for each ParticleSystem also works. Perf wise it sounds like a bit of a wash? More dependent on the actual use-case.

In terms of using the same effect for multiple systems, take care where uniforms are set. I was originally using the Effect’s onBind to set uniforms, but the bind only happens for the first ParticleSystem using the effect and not the other two. So I ended up using ParticleSystem onBeforeDrawParticleObservable to set the effect uniforms instead.