Message 1 of 2
Looking to write a script to convert vray shaders to redshift shaders
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So I've written this script to take all redshift shaders and change the reflection color to black.
{ string $m; string $ms[] = `ls -type "RedshiftMaterial"`; for ($m in $ms) { setAttr ($m + ".refl_color") -type double3 0 0 0; } }
This was just a test to see if I could write a script that would take all of one attribute from one type of shader and change all of them to a specific value at once. So far, so good.
Now I've started writing a script that will change all vray shaders to redshift shaders and copy all attributes over. I'm not a savy enough programmer to know if this is a ridiculously difficult task so let me know if it would require pages and pages of code. This is what I've got so far (see below). It takes a vray shader and converts it to a redshift shader, but the name is different and none of the attributes copy over. The attribute names are different on each shader. For instance VRayMtl.color is the same as rsMaterial.diffuse_color. So obviously there would have to be some sort of thing where each attribute would be mapped to a new attribute. I'm kind of stuck that this point though. Even if I had a script that would map a single attribute from a vray shader to the corresponding attribute on a redshift shader I could probably figure it out from there. Would someone be able to point me in the right direction for that?
Thanks!
{ string $newMaterialType = "RedshiftMaterial"; string $nm = `createNode $newMaterialType`; string $ms[] = `ls -type "VRayMtl"`; 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; } };