Closest I’ve come to this is using ‘Detach by ID’ script. I’d combine the entire scene into a single mesh and then run this script to datach by ‘material name’ - I believe it includes the material name in the new object’s name when everything is broken up.
Ultimately they should be collapsed to one object, if they have the same mat
After some trial and error, essentially what Im looking for is something to explode everything by material, and then collapse everything by material, so I end up with one object per material.
Using it for texture baking and export.
Found this script which replaces the shell material with the baked standard material, but I cant work out why it gives it the name of the baked material rather than the shell material?
If go in the listener and do
m=$.material
m.name
Then i get the name of the Shell material, not the baked material, so not sure why this script does something different.
for o in geometry do
(
if classof o.material == Shell_Material then
(
m = o.material
newmat = StandardMaterial name: m.name
newMat = m.bakedMaterial
o.material = newMat
)
)
You shouldn’t need a script to replace the shell material with the baked material. In the Render to Texture window, at the bottom you can select ‘keep baked materials’ and click clear shell materials.
Ah, gotcha. Yeah that would be convenient if the mesh names could match the material’s applied! I think for myself I just used the mesh names to find the attached shaders I’d need to tweak.