I have a scene which uses probably 30-50 of the same materials, and I’m trying to get the draw calls down as much as possible. For some reason even with 135 active meshes and 51 total materials, the scene still has 476 draw calls. I’m wondering what I could be doing wrong. Any ideas would be great. I’m importing the meshes as .babylon files (created in Blender), and then replacing their materials with global materials, and then instancing/cloning after they share the global materials.
From my limited understanding, generally a draw call would be for each material?
P.S. I wish I could create a PG but given the size of the project that’s not really feasible, just hoping for a better understanding!
You have 3 lights, so you (I think) can expect more than 1 drawcall per object. Same goes for shadows. If you have renderlists in your reflection probes or materials like water, those add up too. If you have materials that requireDepthPrepass those need an extra drawcall too.
I thought the same thing, and removing shadows reduced the calls from 476 to 387, but reducing the lights from 3 to 1 had no effect on draw calls.
Thanks for reporting, I wasn’t sure. How about submeshes, or meshes with multiple materials?
Also make sure you are not leaving instances or originals somewhere in the scene. Call setEnabled(false) on them (this is recursive I think).
Also, just in case, you may want to ensure you dispose the loaded materials if you are replacing them, or they will accumulate in the scene (check the inspector). But I think this would not increase your drawcalls per-se.
I replace all of the multimaterial submaterials with the global materials as well, do you know if you use separate multimaterials that share the same submaterials if it will require extra drawcalls? Seems like the engine would recognize they were the same material.
I disable all unused meshes & dispose all unused materials, I believe they would be included in the 135 active meshes & 51 total materials if I didn’t.
I don’t know. Maybe you can load one of those in the playground and check :?.
1 Like
The best method I found is, to remove all meshes from scene, then keep adding one by one while keeping an eye on draw calls, Those meshes which uses multiple draw calls I try to merge them as much possible, I would merge meshes which has same material, for others I would try to create texture atlas. There is so much you can do as addressed here:
3 Likes
There is one draw call per sub mesh, not per material. So if you have a single mesh with 12 sub meshes, you will get 12 draw calls.
1 Like