Hello, I have ran into performance problems like I always do when I add something new to my game (seems like that I am spending 70% time on optimizations and 30% on actual development - but it is probably my bad).
I have three specific points to discuss
- I have discovered one pretty powerful opimization option - scene.freezeActiveMeshes()
But it behaves weirdly in combination with particleEmitter - when scene is “frozen”, then particle emitter attached to some mesh doesn work. I am not sure whether it is a bug or not, but I dont see any relevant reason why particle emitter shall be somewhat dependand on it ? That mesh is visible and thus active, but particles doesnt appear or move.
If this would seem like a bug rather than feature, I will try to replicate it on playground.
Overall this scene.freezeActiveMeshes() gave me really nice FPS boost, it would be really bad to lose it all because that partifcle problem.
- Another nice optimization is merging meshes together
But supposedly we can only merge meshes of the same material and I have one question - is there any possibility to have something like “texture sprite” that would behave like one single material but provide more than 1 texture ?
For example I have “barell” it is cylinder with caps - cylinder has different material than caps thus it must be two different meshes (even if they are always stick together so perfect candidate for merging).
I asked because I have seen years ago with 2D library PIXI.js that there were feature that offers this possibility - use texture sheet and then final sprites could be merged into one but each with its own texture (taken from that sheet).
- Instances vs Light includeOnlyMeshes array
In my game there are many pointlights with rather small range in corridors - to handle it well fps-wise I am manually controlling array of enlighted meshes for every light (because most of my scene is static).
So far it works pretty well - ever light only lit to lets say 10 - 15 meshes instead of 200+ but I have problem with instances here. I cannot add / remove instance to/ from enlighted array - it only works with parent (and then all instances are either in or out of it). I can understand that it is how instances behave and have to live with it but cany someone explain why there is such limitation ? And is it something that cannot be changed ?
If instances could not be managed this way - than I would need to know whether is there some overhead by light at all instances ? When they are “the same mesh”, then maybe I can just put that parent into enlight list and do not worry. Something like “if at least 1 instance shall be lit, then just lit the parent of them”.
Thanx in advance for some tips and insight guys. Have to say that Babylon is really cool, but that performance problems are tough nut to crack (which I mostly blame WebGL itself for).