I have a mesh with a multimaterial with 12 submaterials (all physical material, the mesh has 12 material IDs).
All submaterials use the same textures (they are referenced by instance), but some settings are different between materials.
First I exported the mesh with a single physical material, the file was about 2MB.
But when I export the mesh as glb with the mulitmaterial with 12 submaterials (still using the same instanced textures), the file size is about doubled.
One would think that only different material settings (not textures) would not make a big difference in file size.
Am I doing something wrong here? Maybe you have tips & tricks to optimize this type of export? File size is very important for my project.
(I already checked the ‘try to optimize vertices’, and I’m not sure if I can use the Draco compression on the end platform).
Adding @Drigax who knows the glb exporter quite well.
The .glb in the multi material scenario probably has, for some reason, a duplicate of the textures… That would be nice to check if that is so, and also provide a repro scene that when exported leads to a much bigger file in the multi material scenario.
Thank you Evgeni!
I have prepared a 3DS Max 2019 scene with two meshes, one with a single physical material, the other with a multimaterial.
Both meshes are using the same materials and the same textures. The only difference is that the multi_material mesh uses a multimaterial with 12 submaterials, but it’s the same material that the single version uses, only copied 12 times.
(By the way, I tried to instance reference the images in each submaterial, but that didn’t change the output size. The exporter already recognizes when the same image is used I guess.)
I’ve installed the latest exporter plugin, the single material exports ~1.6MB and the multimaterial ~3.2MB.
This is the scene: multimaterial.zip (3.4 MB)
Ok, didn’t understand it was a glb export from Max.
So, adding @Guillaume_Pelletier who may know if it’s a problem with the exporter that would duplicate the textures .
We might missed something with this multi-material use case. Let me have a closer look on it.
Had a closer look, problem occur at Babylon to Gltf conversion where the image is duplicated (for some reason).
.Babylon file are OK
.GLB are much bigger thant it might be.
I will see if i can make a quick fix, otherwise i will publish an issue.
@FernandoConti Thanks for the info, i’ll keep you posted.
Thank you so much @Guillaume_Pelletier ! A quick fix would really save my project
Ok, Finally this seems not to be the Material in cause, but the mesh buffer wich is repeated several time (one for each material). Internally, mesh and vertices are defined as unique within a material,.
Technically into your file you are creating several material (with the same texture and bitmap as base) and bind it to the multimaterial. Then the exporter is creating the SAME as you defined in Max. If you attach only one static material to each of the sub material then you might have a smaller file.
We do NOT provide such optimization which implies graph traversing to retreive bitmap and all properties to guess if a material is an equivalent to another one. This could be a feature in the next version, but actually you better to downsize your material graph.