Hey! Me again :x
This time with a real “bother”, sort of…
I have been working on my game - in which the world is split into rooms - for the good of the last 7 months, but I’ve only recently added more than 2 rooms, and realised that I can barely get 30 fps. It was a mess, I had 700 meshes, barely any optimisation, .createBox everywhere etc.
Since then I’ve been working my head and ears off, sweating blood, just to get that sweet drip of 60 fps… And I did, but there are still parts where the fps drop, also - draw calls (more below).
So far my optimizations included:
MERGE EVERYTHING, well sort of, I only merge meshes in each room. Why not merge everything? Read next point.
mesh.visilbilityactually affects performance, so while you’re in one room, I add a ceiling and set
mesh.visibility = 0to all other rooms. Big performance boost, but rayCasts still detect these meshes (in case you shoot a bullet to next room).
Okay, but setting
mesh.visibilityon a massive mesh made from 200+ other meshes, every time you switch to next room, has to have an impact… It did, until I applied -
scene.blockMaterialDirtyMechanism = true;.
mesh.checkCollisions = falseon previous room meshes when you leave the room
mesh.freezeWorldMatrix()on inactive meshes
mesh.cullingStrategy = BOUNDINGSPHERE_ONLY
camera.maxZ = 200huge boost this one
So after all this, I am down to 150 meshes with 5 rooms. Character meshes are not merged because most of them animate somehow, same for doors.
Even though, the performance is great, I feel in my guts that there’s still something missing.
By my guts I mean I ran
instrumentation.drawCallsCounter and after a bit of walking and 10minutes of standing still the
count property was at 40000 and the current was at 440.
How can I further reduce the draw calls?
- I read about material sharing, does that simply mean saving
new Materialand assign it to materials, instead of always calling
new Materialor is there a deeper meaning?
-I know about anitalias and hardware scaling, those are more of a high level settings.
I should note that the machine I am testing this on is a AMD8320, 8GB RAM and 660GTX (1440p resolution) so pretty old, but should be sufficient for what I am making.
ANY input or point into a direction is highly appreciated and I thank you in advance!