Optimizing Scene Draw Calls and Performance Issues with GLB Scene

I’m encountering optimization problems after exporting a scene from Unity (as FBX) and converting it to GLB using Blender. Upon importing the scene, I noticed over 300 draw calls and my CPU usage stays around 90%. The scene consists of 58 regular meshes, with the rest being InstancedMeshes, according to the Babylon.js Inspector. Despite this, I can’t seem to reduce the draw calls to 58.

Is there anything specific I should check with InstancedMeshes to lower draw calls?

I also tried merging meshes that share the same material, which brought the draw calls down to about 30. However, this caused performance to worsen, both in terms of FPS and CPU usage, compared to the original scene.

Here’s a playground example of the scene: Babylon.js Playground

InstanceMeshed version:

MergedMeshes version:

This is weird: if you delete all InstancedMeshes, the draw calls go down. I kept one InstancedMesh for probing. But this one seems to be alright.

@Deltakosh any ideas?

61 draw calls, the same if you delete all instanced meshes as here delete all InstancedMeshes

I believe there was some problem during conversion or export. The solution is to process the file with GPU Instancing.
So, I upload the GLB to https://glb.babylonpress.org/, checked GPU Instancing box, then saved optimized file. That’s all :slight_smile:


The original file size when unDracoed is around 10 Mb, optimized without Draco 1.66 Mb. One may additionally apply Meshopt to reduce the file size to 0.58 Mb - Babylon.js Sandbox - View glTF, glb, obj and babylon files

3 Likes

The problem with your file is that almost all instances have a different matrix determinant than their source. This is a problem because it force babylon to change the winding order as the faces are going in the opposite direction so instancing cannot happen.

this happen when using negative scaling for the instance compared to the source (like source.scaling = 1,1,1 but instance is 1,-1,1

4 Likes

I see, thank you! I did not know anything about this winding order. Also that’d be great if we could add this information to the IntancedMesh docs in babylonjs site.

Thank you so much, that tooling is very useful!

1 Like


It is there:
Instances | Babylon.js Documentation (babylonjs.com)

(But I understand you, information overload is a thing)

3 Likes

RTFM is losing its meaning, there is too much information available and still not enough…

yeah, you see my problem. There is no good solution and I’m writing doc for Babylon since 10 years ;D

1 Like

I’m pretty sure I read that part, due to my lack of graphics programming I did not understand that part :smile:

2 Likes