Sunday, May 20, 2012

How to use Mia material with Maya's ambient light pt2.

This is the follow-up of the post, How to use Mia material with Maya's ambient light.

The following mel script is to create a lambert material and connect it to all the existing mia_material_x_passes materials at one shot.

// create a Lambert material named ambPicker
string $ambPicker = `shadingNode -asShader lambert -name ambPicker`;
setAttr ($ambPicker +".color") -type double3 1 1 1;
setAttr ($ambPicker +".diffuse") 0;
setAttr ($ambPicker +".miFrameBufferWriteOperation") 0;

// make a connection between the ambPicker and the mia materials
string $mia_material[] = `ls -type "mia_material_x_passes"`;
for ($member in $mia_material ){
    int $connectivity = `isConnected ($ambPicker +".outColor")($member +".ao_ambient")`;
    if ($connectivity){
        print ($member +" is already connected to ambPicker.\n");
    }
    else{
    connectAttr -force($ambPicker +".outColor")($member +".ao_ambient");
    }
    setAttr ($member +".ao_on") 1;
    setAttr ($member +".ao_samples") 16;
    setAttr ($member +".ao_distance") 30;
    setAttr ($member +".ao_dark") -type double3 0 0 0 ;
   
}

You can simply delete the ambPicker material when it's not needed.

No comments:

Post a Comment