Optimize glb export drawcalls

Hi,

I notice that exporting a CAD file to GLB produces a lot of draw calls. While CAD assistant seems to handle the load, this is not the case for other viewers (e.g. windows 3D viewer). I tried optimizing the models with another library and this reduces the number of draw calls by roughly ten while keeping an equivalent amount of data (1161 =>139 draw calls for the files I have provided).
Is there a way to optimize the number of draw calls? More specifically, I am working on a custom converter that greatly resembles the code provided by this answer https://stackoverflow.com/a/62872824

I appreciate the assistance. Have a good day!

Attachments: 
Kirill Gavrilov's picture

1161 =>139 draw calls

Original model contains only 7 materials, while your version explodes them into 139 with duplicated grays. I guess there is some mistake in your code...


keeping an equivalent amount of data

Equivalent visualization data, I suppose, as original STEP defines 1163 faces and this information OCCT tries to keep on glTF export (current implementation).

A MdB's picture

Hi and thank you for your time. 

The optimization code is used for Unity3D so we keep one material per "element". It's something we may optimize in the future but I don't believe this is the issue. You can look at the time it takes to read both files (0.02s compared to 0.16s). 

I appreciate that OCCT keeps the faces but this results in a lot of drawcalls. This impact performances for most viewers. Is there a way to optimize it using OCCT/CAD Assistant?

Thanks again.

(using https://gltf-viewer.donmccurdy.com/)