Hi Joojaa
Thanks for that script
I have a small problem though and my knowledge on scripting is bad.
I have changed your script a little bit so that it converts to mia_material_x instead (for adding bump maps(im not sure how to do a standard bump on the normal mia_material))
My problem is that the material after I run the script, is connected to both shading groups. The objects that has the new material still has the old material's shading group attached to it for the viewport. If I render it is fine, but it is green in the viewport. If I drag and drop the newly created shading group that was done in the script on the object, then everything seems fine.
Is there a way to remove the old shading group and have the newly created one assigned?
I also attached a screenshot if it may help
Here is the changed mel script:
//----------------------------------------------
proc connectAndSet(string $original,string $target){
$conn=connectionInfo -sfd $original
;
if ($conn!=""){
connectAttr -force $conn $target;
} else {
connectAttr -force $original $target;
disconnectAttr $original $target;
}
}
proc convertPhongToMia(string $original){
$target=mrCreateCustomNode -asShader "" mia\_material\_x
;
connectAndSet($original+".color",$target+".diffuse");
//... any other mapping you need comes here...
// a bit weak test should work for simple materials,
// not used in special context
$sg=connectionInfo -dfs ($original+".outColor")
;
if ($sg[0]!=""){
$sgr=match "[^.]*" ((string)$sg[0])
;
connectAttr -force ($target+".message") ($sgr+".miMaterialShader");
connectAttr -force ($target+".message") ($sgr+".miPhotonShader");
connectAttr -force ($target+".message") ($sgr+".miShadowShader");
}
delete $original;
rename $target $original;
}
for ($item inls -et phong
)
convertPhongToMia($item);
//------------------------------------------------------------------------------------
many thx in advance
Phil