Open willeastcott opened 5 years ago
I have noticed it as well. It is related to rebuilding texture with parameters and reuploading it to GPU. Even when particle emitter is cloned, it still calls rebuild, although they will look and behave identical.
I believe if particle is cloned and looks identical, it should then clone parameters texture too. But if we clone emitter and it should look different based on randomisation curves, then it should call rebuild.
Or leave rebuild/randomisation to developer, and always clone identical without rebuilding. So more flexibility to developer.
It does indeed allocate a lot of stuff when created. It can be made faster, but the best optimization is still on the user side: create emitter pool in advance and reuse.
It does indeed allocate a lot of stuff when created. It can be made faster, but the best optimization is still on the user side: create emitter pool in advance and reuse.
I've created pool. but unfortunately it does not allocate on cloning, but on first render. So there seems to be no way to pre-warm it?
Maybe this one? https://github.com/playcanvas/engine/blob/master/src/scene/particle-system/particle-emitter.js#L1041
Nope. this will only setup particle emitter, so when it starts playing, it already has particles spawned.
To pre-warm engine for particle, it should be enabled as entity with component, so it creates Emitter, check here: https://github.com/playcanvas/engine/blob/master/src/framework/components/particle-system/component.js#L601 And it will call rebuild.
Would be great to either have a function to actually trigger all rebuilding and stuff, so it wouldn't stall JS thread when entity is enabled first time.
An investigation should be carried out to search for optimization opportunities.