Lots of Meshes, Lots of Physics Impostors, LOTS of lag fix


For ILMBIN lots of cubes are to be expected, however at around a 25x25 square of cubes lags a LOT.
When you load the page it has a 16x16 square. Change the variable “sizeofplatform” at line 176 to, well, change the size of the platform.

Any help nice. I made the change to use instances instead of individual cubes. It added around 5 fps.

If your blocks won’t move I suggest to use instances AND call scene.freezeActiveMeshes() when all the blocks are ready

1 Like

will scene.freezeActiveMeshes() allow me to place a block, and then move it?

Just tried it and it won’t work because this project is using my physics controlled camera. The player is a mesh.

Depending on how you want to architecture it but you could have two scenes with the second one set with autoClear=false and autoClearDepthAndStencil = false

Then you can have your optimized ground on scene 1 and everything else on scene 2

You can unfreezeActiveMeshes to move a mesh and then freeze the scene back when needed

1 Like

So basically:

scene 1:
every block

scene 2:
autoClear = false; and autoClearDepthAndStencil = false; and the player


1 Like

A 10x10x10 cube. 12 fps lol :laughing:

check with freezeActiveMeshes :slight_smile:

New Discovery!

Going back to the playground linked in my last reply, I get 12 fps with a 10x10x10 cube. I comment out lines 181-189. This removes the 1000 physics impostors for all the cubes in the cube. I get 40 fps when looking around, 50 when still. and 60 when looking away. Finding a solution to add and remove physics impostors might work. Only the cubes nearest the player should have physics impostors.

Oh, and the 10x10x10 cube with freezeActiveMeshes didn’t help much. I added two functions, freeze and unfreeze. freeze was called when not moving the camera and when not pressing a key(moving around). unfreeze was called when moving and looking around. I noticed the cubes disappearing and reappearing, and I don’t think that it would be a good long term solution.

This kinda works ;/

1 Like

The freeze should definitely largely improve the perf but only when objects are not physics. They must be static

This works pretty ok. around 10 fps

1 Like