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.visilbility
actually affects performance, so while you’re in one room, I add a ceiling and setmesh.visibility = 0
to 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.visibility
on 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 = false
on previous room meshes when you leave the room -
scene.freezeActiveMeshes()
-
mesh.freezeWorldMatrix()
on inactive meshes -
mesh.material.freeze()
-
mesh.cullingStrategy = BOUNDINGSPHERE_ONLY
-
mesh.convertToUnIndexedMesh()
-
camera.maxZ = 200
huge 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 Material
and assign it to materials, instead of always callingnew Material
or 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!
Ta!