|04 April 2013||#1|
Join Date: Nov 2009
Convert Material type
I have a scene with hundreds of mia_materials. I was requested to bring this scene into Unity, however Unity does not recognize these materials. What I need to do is for each mia_material in my scene, create a blinn, name it the same as its mia equivalent, copy the color values over, assign it to the same object the mia was assigned to, and delete the mia material. How can I do this? I am not a coder by any means but below is a script that is pointing in the right direction.
string $newMaterialType = "lambert";
string $nm = `createNode $newMaterialType`;
string $ms = `ls -type "phong"`;
string $pa = `listAttr -visible -settable -scalar $ms`;
string $nma = `listAttr -visible -settable -scalar $nm`;
string $ca = stringArrayRemove($nma, $pa);
$ca = stringArrayRemove($ca, $pa);
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`);
noise Noise NOISE NOISE
|04 April 2013||#2|
Join Date: Dec 2010
Try this one below. Your example also checks if the original shader and the new one share attributes with the same name - and if so it copys the values. This one below only copys the diffuse rgb value of the mia_material to the new blinns color slot.
|04 April 2013||#4|
Join Date: Sep 2003
Thread automatically closed
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
|Thread Closed share thread|