/* Author : Walter Behrnes Other People: I would like to thank Michael Bahurinsky for doing the grunt work this script revolves around. He made the shader for me to follow as a template in creating the mel. Contact: waldo_27@hotmail.com Script Name: createtoon Version: 1.0 Description: Create the toon shader on aliaswavefronts website Directions: Save this script into your scripts folder type createtoon( "*shadername" ) into the commandline this will create two nodes in your hypershade... apply *shadername"toon" to your surface *shadername needs to be different if you are using this srcipt multiple time in one scene */ ////////////////////////////////////////////////////////////// // Please do not edit above this line // Edit at your own risk below this line ////////////////////////////////////////////////////////////// global proc createtoon(string $name) { //check to see if name already in use if( `objExists $name`) { error ("toonshader name " + $name +" already exists"); } //createShader shadingNode -asShader blinn -n $name; //createSurfaceShader string $toon = ($name + "toon"); shadingNode -asShader surfaceShader -n $toon; eval ("sets -renderable true -noSurfaceShader true -empty -name " +$toon+"SG"); eval ("connectAttr -f " +$toon+".outColor " +$toon+"SG.surfaceShader"); //create Utilities string $myutility[] = {"Texture ", "Utility ", "Utility ", "Utility "}; string $myutilityname[] = {"ramp", "clamp", "condition", "samplerInfo"}; int $sizeU = size($myutility); string $connected; string $connectedname; for ($i = 0; $i < $sizeU; $i++) { $connected = $myutility[$i]+$myutilityname[$i]; $connectedname = $myutilityname[$i] +$name; eval ("shadingNode -as"+$connected+" -n "+$connectedname); } //link everything together eval ("connectAttr -f " +$name+".outColor "+$myutilityname[1]+""+$name+".input"); eval ("setAttr "+$myutilityname[1]+""+$name+".maxR 1"); eval ("connectAttr -f "+$myutilityname[1]+""+$name+".outputR "+$myutilityname[0]+""+$name+".vCoord"); eval ("connectAttr -force "+$myutilityname[0]+""+$name+".outColor "+$myutilityname[2]+""+$name+".colorIfFalse"); eval ("connectAttr -f "+$myutilityname[3]+""+$name+".facingRatio "+$myutilityname[2]+""+$name+".firstTerm"); //add attributes eval ("addAttr -k 1 -ln LineThickness -at double -min 0 -max 1 -dv .2 "+$toon); eval ("addAttr -k 1 -ln LineR -at double -min 0 -max 1 -dv .2 "+$toon); eval ("addAttr -k 1 -ln LineG -at double -min 0 -max 1 -dv .2 "+$toon); eval ("addAttr -k 1 -ln LineB -at double -min 0 -max 1 -dv .2 "+$toon); //link a few more things eval ("setAttr "+$myutilityname[2]+""+$name+".operation 4"); string $connecto = ($myutilityname[2]+$name); eval ("connectAttr -f "+$toon+".LineThickness "+$connecto+".secondTerm"); eval ("connectAttr -f "+$toon+".LineR "+$connecto+".colorIfTrueR"); eval ("connectAttr -f "+$toon+".LineG "+$connecto+".colorIfTrueG"); eval ("connectAttr -f "+$toon+".LineB "+$connecto+".colorIfTrueB"); eval ("connectAttr -f "+$connecto+".outColor "+$toon+".outColor"); }