Hi, I followed all the steps from scene optimization and somehow I ended with a lower fps than before I don’t know what I’m doing wrong.
I can’t share it with you, but I’ll try to give you a little context.
It is a huge scene completly loaded as gltf, only with static meshes, and most of them are instancedMeshes(trees, bushes, buildings). As player you can move through it using a firstPersonCamera which is an UniversalCamera from babylon. You can move using keyboard keys or on click on the ground. This is it.
Before to apply the optimizations, it had a fps range between 55 and 70 and the drawcalls, actived meshes and absolute fps varied a lot.
After optimizations the scene looks more stable, the fps vary less, like between 55 and 65 aprox, and only fps and absolute fps are changing, but their values are a litle bit smaller than before
What I did for optimization
* mesh.freezeWorldMatrix();
if (mesh.material) {
mesh.material.freeze();
mesh.isPickable = false;
mesh.enablePointerMoveEvents = false;
mesh.doNotSyncBoundingInfo = true;
}
* this.engine = new Engine( canvasContainer, true, { preserveDrawingBuffer: true, stencil: true, }, false );
this.engine.renderEvenInBackground = false;
this.engine.enableOfflineSupport = false;
this.engine.disableManifestCheck = true;
this.engine.disablePerformanceMonitorInBackground = true;
this.engine.doNotHandleContextLost = true;
* this.scene.skipFrustumClipping = true;
this.scene.preventDefaultOnPointerDown = false;
this.scene.preventDefaultOnPointerUp = false;
// this.scene.autoClear = false; // I can't because is open scene
// this.scene.autoClearDepthAndStencil = false; // I can't because is open scene
this.scene.clearColor = new Color4(0, 0, 0, 0);
// this.scene.skipPointerMovePicking = true; // I can't because there is a circle which follow the mouse cursor
this.scene.setRenderingOrder(0, null, null, RenderingGroup.PainterSortCompare );
Yes, exactly the same scene and camera.
I think it is somehow expected because with optmization everything is freezed and the bounding Info is not refreshed so the camera take all the meshes from scene, because of this drawcalls and activeMeshes not change while moving, …maybe I’m wrong
later edit: actually there are 2 meshes and 2 materials more with optimizatitons, I’ll check from where they come. But I don’t think they have such a big influence
There are 136 more draw calls on the first scene so that definitely makes a big difference.
Since you said most of the meshes are static, you could freeze the world matrix of those. You can also try the performance priority modes instead of trying to change individual features: Optimizing Your Scene | Babylon.js Documentation
Hi, yes, this was the reason of so many draw calls. It was a missunderstanding from my side
If I set this to false it is working as expected, and “my fps” are back
Thanks!
Do you have any suggestions besides the above I already tried?