Is there any way (Mel/Python...) to convert a AiStandardSurface material to a Lambert/Phong/Blinn and still mantain material color properties?
I've used this script:
//change all phong Materials to aiStandard Material // If you need to change another Material, simple change `ls -type "phong"` { string $newMaterialType = "aiStandard"; string $nm = `createNode $newMaterialType`; string $ms[] = `ls -type "blinn"`; string $pa[] = `listAttr -visible -settable -scalar $ms`; string $nma[] = `listAttr -visible -settable -scalar $nm`; string $ca[] = stringArrayRemove($nma, $pa); $ca = stringArrayRemove($ca, $pa); delete $nm; string $a; string $m; float $v; string $cl[]; for ($m in $ms) { $nm = `createNode $newMaterialType`; $cl = `listConnections -destination true -plugs true -source false -type shadingEngine $m`; connectAttr -f ($nm + ".outColor") ($cl); for ($a in $ca) { $v = `getAttr ($m + "." + $a)`; catchQuiet(`setAttr ($nm + "." + $a) $v`); } delete $m; } }
to convert a blinn to arnold, and it does work, so i tried the other way:
//change all phong Materials to aiStandard Material // If you need to change another Material, simple change `ls -type "phong"` { string $newMaterialType = "blinn"; string $nm = `createNode $newMaterialType`; string $ms[] = `ls -type "aiStandard"`; string $pa[] = `listAttr -visible -settable -scalar $ms`; string $nma[] = `listAttr -visible -settable -scalar $nm`; string $ca[] = stringArrayRemove($nma, $pa); $ca = stringArrayRemove($ca, $pa); delete $nm; string $a; string $m; float $v; string $cl[]; for ($m in $ms) { $nm = `createNode $newMaterialType`; $cl = `listConnections -destination true -plugs true -source false -type shadingEngine $m`; connectAttr -f ($nm + ".outColor") ($cl); for ($a in $ca) { $v = `getAttr ($m + "." + $a)`; catchQuiet(`setAttr ($nm + "." + $a) $v`); } delete $m; } }
I've also tried "aiStandardSurface" instead of "aiStandard"
But this doesnt work...
i get this error:
// Error: line 18: The destination attribute '' cannot be found. //
Just curious as to why you would want to do this?
Because i have a lot of objects with arnold materials (The project im working on was supposed to be a short) but now they also want a very simple unity project to show the models(Most of them can be flat colors without textures, they just need to see the model itself) and if i export an fbx with arnold materials, it does export the materials but when i do import them in unnity, the flat color is grey, instead of the ones the aiStandardSurface has
Just in case anyone was wondering how.
This is how a friend (Github: @PRZurro) managed to convert just the BaseColor of a aiStandardSurfaceLegacy Shader to the Color of Legacy Shader
string $newMaterialType = "blinn"; string $newMaterial = `createNode $newMaterialType`; string $oldMaterials[] = `ls -type "aiStandardSurface"`; string $oldMaterialsAttr[] = `listAttr -visible -settable -scalar $oldMaterials`; string $newMaterialAttr[] = `listAttr -visible -settable -scalar $newMaterial`; string $ca[] = stringArrayRemove($newMaterialAttr, $oldMaterialsAttr); $ca = stringArrayRemove($ca, $oldMaterialsAttr); delete $newMaterial; string $a; string $b; string $m; float $v; string $cl[]; for ($m in $oldMaterials) { $newMaterial = `createNode $newMaterialType`; $cl = `listConnections -destination true -plugs true -source false -type shadingEngine $m`; connectAttr -f ($newMaterial + ".outColor") ($cl); for ($a in $ca) { $v = `getAttr ($m + "." + $a)`; catchQuiet(`setAttr ($newMaterial + "." + $a) $v`); } float $colorR = `getAttr($m + ".baseColorR")` ; catchQuiet(`setAttr ($newMaterial + ".colorR") $colorR`); float $colorG = `getAttr($m + ".baseColorG")` ; catchQuiet(`setAttr ($newMaterial + ".colorG") $colorG`); float $colorB = `getAttr($m + ".baseColorB")` ; catchQuiet(`setAttr ($newMaterial + ".colorB") $colorB`); delete $m; }