Message 1 of 2
Script to Batch Convert Shaders to Renderman?
Not applicable
09-16-2017
01:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
l've imported an FBX file into Maya and of course all of the shaders are Phong, obviously Renderman doesn't support Phong. Normally I would just go into Hypershade and do it manually, but are well over 300 hundred texture and shader nodes. So I was curious to know if there's a script available that could easily convert the Phong shaders to PxrSurface shaders? I know such a script exists to convert Phong shaders to Mia materials for Mental Ray.
Here's the code, it works well, and I've tried editing it for Renderman's PxrSurface to no avial. I am a 100% novice in all forms of coding so any help would be much appreciated.
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`;
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+".outValue") ($sgr+".miMaterialShader");
connectAttr -force ($target+".outValue") ($sgr+".miPhotonShader");
connectAttr -force ($target+".outValue") ($sgr+".miShadowShader");
}
delete $original;
rename $target $original;
}
for ($item in`ls -et phong`)
convertPhongToMia($item);