Which, i guess, would leave the multimats full of holes ? The trick is that I would like to optimize a scene’s materials for realtime visualization, so splitting materials over and over each time a new slot becomes unused seems inappropriate…
A developer at our company proposed the following :
- He already wrote a script that attaches several meshes together (and thus cumulates the former objects’ materials) and that can detach each mesh independantly (reassigning names) to their former state. (“Wtf ? How did you do that” Did I kindly asked him)
- On the attached big mesh, run CSOM to clean the unused slots
- Detach the objects to their former states.
- The “new” former objects would then share the same multimaterial.
The thing is that I felt this method is a little bit risky… The slightest offset in the vertex order in the array and the whole thing collapses, I fear. Besides that, the script becomes increasingly memory consuming due to the attach loop parsing dozens of complex meshes.
I don’t understand why the clean multimaterial suffers from memory overflow. There are only 120~ materials (not all multimaterials) in the scene and it is running on Max9, quad Core, 4 GB ram. Plus it is probably hard coded in C++.
EDIT : I just tried to launch the CSOM script on a bunch of objects.
The resulst is screwed up because before the script : 900~ mats in the scene, 991 maps, after the script, 1600~ mats, 985 maps. So i removed 6 unused maps and created over 700 materials :hmm: