// MotR motrMatteShadows V0.3 // Jeff Coe nov 2007 v0.3 // // Use in Maya2008 // // Usage: Please refer to Master Zap's tutorial for overview: http://mentalraytips.blogspot.com/2007/10/production-shader-examples.html // "motrMatteShadows 1;" will setup nodes and toggle mode to lookDev mode // "motrMatteShadows 2;" will reconnect nodes for renderPass output // toggle back and forth using 1 and 2 // proc msNodeCreator () { createNode transform -n motrMatteShadow_NODE; addAttr -dt "string" -multi -ln "matteShadowNodes" -sn "MSN" -nn "Matte Shadow Nodes"; addAttr -dt "string" -ln "matteShadowLambert" -sn "MSL" -nn "Matte Shadow Lambert"; addAttr -dt "string" -ln "matteShadeGroup" -sn "MSG" -nn "Matte Shade Group"; setAttr motrMatteShadow_NODE.MSN[1] -type "string" 0; setAttr motrMatteShadow_NODE.MSN[2] -type "string" 0; setAttr motrMatteShadow_NODE.MSN[3] -type "string" 0; setAttr motrMatteShadow_NODE.MSN[4] -type "string" 0; setAttr motrMatteShadow_NODE.MSN[5] -type "string" 0; setAttr motrMatteShadow_NODE.MSN[6] -type "string" 0; setAttr motrMatteShadow_NODE.MSN[7] -type "string" 0; setAttr motrMatteShadow_NODE.MSL -type "string" 0; setAttr motrMatteShadow_NODE.MSG -type "string" 0; } global proc motrMatteShadows ( float $option ) { if($option <= 1) { //camera setup if(`attributeExists "MSN" "motrMatteShadow_NODE"`){ string $attrA = `getAttr motrMatteShadow_NODE.MSN[5]`; string $attrB = `getAttr motrMatteShadow_NODE.MSN[1]`; if(`isConnected ($attrA+".outValue") ($attrB+".background")`){ disconnectAttr (`getAttr motrMatteShadow_NODE.MSN[5]`+".outValue") (`getAttr motrMatteShadow_NODE.MSN[1]`+".background"); } $attrA = `getAttr motrMatteShadow_NODE.MSN[5]`; $attrB = `getAttr motrMatteShadow_NODE.MSN[1]`; if(`isConnected ($attrA+".outValueA") ($attrB+".backgroundA")`){ disconnectAttr (`getAttr motrMatteShadow_NODE.MSN[5]`+".outValueA") (`getAttr motrMatteShadow_NODE.MSN[1]`+".backgroundA"); } $attrA = `getAttr motrMatteShadow_NODE.MSN[6]`; $attrB = `getAttr motrMatteShadow_NODE.MSN[4]`; if(`isConnected ($attrA+".outValue") ($attrB+".background")`){ disconnectAttr (`getAttr motrMatteShadow_NODE.MSN[6]`+".outValue") (`getAttr motrMatteShadow_NODE.MSN[4]`+".background"); } $attrA = `getAttr motrMatteShadow_NODE.MSN[6]`; $attrB = `getAttr motrMatteShadow_NODE.MSN[4]`; if(`isConnected ($attrA+".outValueA") ($attrB+".backgroundA")`){ disconnectAttr (`getAttr motrMatteShadow_NODE.MSN[6]`+".outValueA") (`getAttr motrMatteShadow_NODE.MSN[4]`+".backgroundA"); } $attrA = `getAttr motrMatteShadow_NODE.MSN[2]`; $attrB = `getAttr motrMatteShadow_NODE.MSN[6]`; if(`isConnected ($attrA+".outValue") ($attrB+".environment")`){ disconnectAttr (`getAttr motrMatteShadow_NODE.MSN[2]`+".outValue") (`getAttr motrMatteShadow_NODE.MSN[6]`+".environment"); } $attrA = `getAttr motrMatteShadow_NODE.MSN[2]`; $attrB = `getAttr motrMatteShadow_NODE.MSN[6]`; if(`isConnected ($attrA+".outValueA") ($attrB+".environmentA")`){ disconnectAttr (`getAttr motrMatteShadow_NODE.MSN[2]`+".outValueA") (`getAttr motrMatteShadow_NODE.MSN[6]`+".environmentA"); } $attrA = `getAttr motrMatteShadow_NODE.MSN[7]`; $attrB = `getAttr motrMatteShadow_NODE.MSN[6]`; if(`isConnected ($attrA+".outValue") ($attrB+".background")`){ disconnectAttr (`getAttr motrMatteShadow_NODE.MSN[7]`+".outValue") (`getAttr motrMatteShadow_NODE.MSN[6]`+".background"); } $attrA = `getAttr motrMatteShadow_NODE.MSN[7]`; $attrB = `getAttr motrMatteShadow_NODE.MSN[6]`; if(`isConnected ($attrA+".outValueA") ($attrB+".backgroundA")`){ disconnectAttr (`getAttr motrMatteShadow_NODE.MSN[7]`+".outValueA") (`getAttr motrMatteShadow_NODE.MSN[6]`+".backgroundA"); } $attrA = `getAttr motrMatteShadow_NODE.MSN[1]`; if(`isConnected ($attrA+".message") cameraShape1.miEnvironmentShader`){ disconnectAttr (`getAttr motrMatteShadow_NODE.MSN[1]`+".message") cameraShape1.miEnvironmentShader; } $attrA = `getAttr motrMatteShadow_NODE.MSN[2]`; $attrB = `getAttr motrMatteShadow_NODE.MSN[1]`; if(`isConnected ($attrA+".outValue") ($attrB+".background")`){ disconnectAttr (`getAttr motrMatteShadow_NODE.MSN[2]`+".outValue") (`getAttr motrMatteShadow_NODE.MSN[1]`+".background"); } $attrA = `getAttr motrMatteShadow_NODE.MSN[2]`; $attrB = `getAttr motrMatteShadow_NODE.MSN[1]`; if(`isConnected ($attrA+".outValueA") ($attrB+".backgroundA")`){ disconnectAttr (`getAttr motrMatteShadow_NODE.MSN[2]`+".outValueA") (`getAttr motrMatteShadow_NODE.MSN[1]`+".backgroundA"); } $attrA = `getAttr motrMatteShadow_NODE.MSN[3]`; $attrB = `getAttr motrMatteShadow_NODE.MSN[1]`; if(`isConnected ($attrA+".outValue") ($attrB+".environment")`){ disconnectAttr (`getAttr motrMatteShadow_NODE.MSN[3]`+".outValue") (`getAttr motrMatteShadow_NODE.MSN[1]`+".environment"); } $attrA = `getAttr motrMatteShadow_NODE.MSN[3]`; $attrB = `getAttr motrMatteShadow_NODE.MSN[1]`; if(`isConnected ($attrA+".outValueA") ($attrB+".environmentA")`){ disconnectAttr (`getAttr motrMatteShadow_NODE.MSN[3]`+".outValueA") (`getAttr motrMatteShadow_NODE.MSN[1]`+".environmentA"); } $attrA = `getAttr motrMatteShadow_NODE.MSN[4]`; $attrB = `getAttr motrMatteShadow_NODE.MSG`; if(`isConnected ($attrA+".message") ($attrB+".miMaterialShader")`){ disconnectAttr (`getAttr motrMatteShadow_NODE.MSN[4]`+".message") (`getAttr motrMatteShadow_NODE.MSG`+".miMaterialShader"); } $attrA = `getAttr motrMatteShadow_NODE.MSN[4]`; $attrB = `getAttr motrMatteShadow_NODE.MSG`; if(`isConnected ($attrA+".message") ($attrB+".miShadowShader")`){ disconnectAttr (`getAttr motrMatteShadow_NODE.MSN[4]`+".message") (`getAttr motrMatteShadow_NODE.MSG`+".miShadowShader"); } $attrA = `getAttr motrMatteShadow_NODE.MSN[4]`; $attrB = `getAttr motrMatteShadow_NODE.MSG`; if(`isConnected ($attrA+".message") ($attrB+".miPhotonShader")`){ disconnectAttr (`getAttr motrMatteShadow_NODE.MSN[4]`+".message") (`getAttr motrMatteShadow_NODE.MSG`+".miPhotonShader"); } $attrA = `getAttr motrMatteShadow_NODE.MSN[2]`; $attrB = `getAttr motrMatteShadow_NODE.MSN[4]`; if(`isConnected ($attrA+".outValue") ($attrB+".background")`){ disconnectAttr (`getAttr motrMatteShadow_NODE.MSN[2]`+".outValue") (`getAttr motrMatteShadow_NODE.MSN[4]`+".background"); } $attrA = `getAttr motrMatteShadow_NODE.MSN[2]`; $attrB = `getAttr motrMatteShadow_NODE.MSN[4]`; if(`isConnected ($attrA+".outValueA") ($attrB+".backgroundA")`){ disconnectAttr (`getAttr motrMatteShadow_NODE.MSN[2]`+".outValueA") (`getAttr motrMatteShadow_NODE.MSN[4]`+".backgroundA"); } } //Creates initial storage node and attrs if(`attributeExists "MSN" "motrMatteShadow_NODE"` == 0) { msNodeCreator(); } if(`getAttr motrMatteShadow_NODE.MSN[1]` == 0){ camera; setAttr motrMatteShadow_NODE.MSN[1] -type "string" `createNode mip_rayswitch_environment`; //$motrmipNodecount =1 } connectAttr -f (`getAttr motrMatteShadow_NODE.MSN[1]`+".message") cameraShape1.miEnvironmentShader; if(`getAttr motrMatteShadow_NODE.MSN[2]` == 0){ setAttr motrMatteShadow_NODE.MSN[2] -type "string" `createNode mip_cameramap`; //$motrmipNodecount =2 mentalrayTextureNodeCreate (`getAttr motrMatteShadow_NODE.MSN[2]`+".map"); } connectAttr -f (`getAttr motrMatteShadow_NODE.MSN[2]`+".outValue") (`getAttr motrMatteShadow_NODE.MSN[1]`+".background"); connectAttr -f (`getAttr motrMatteShadow_NODE.MSN[2]`+".outValueA") (`getAttr motrMatteShadow_NODE.MSN[1]`+".backgroundA"); if(`getAttr motrMatteShadow_NODE.MSN[3]` == 0){ setAttr motrMatteShadow_NODE.MSN[3] -type "string" `createNode mip_mirrorball`; //$motrmipNodecount =3 mentalrayTextureNodeCreate (`getAttr motrMatteShadow_NODE.MSN[3]`+".texture"); } connectAttr -f (`getAttr motrMatteShadow_NODE.MSN[3]`+".outValue") (`getAttr motrMatteShadow_NODE.MSN[1]`+".environment"); connectAttr -f (`getAttr motrMatteShadow_NODE.MSN[3]`+".outValueA") (`getAttr motrMatteShadow_NODE.MSN[1]`+".environmentA"); if(`getAttr motrMatteShadow_NODE.MSL` == 0){ setAttr motrMatteShadow_NODE.MSL -type "string" `shadingNode -asShader -n matteShadow_lambert lambert`; select motrMatteShadow_NODE.MSL; setAttr motrMatteShadow_NODE.MSG -type "string" `sets -renderable true -noSurfaceShader true -empty`; defaultNavigation -ce -d (`getAttr motrMatteShadow_NODE.MSG`+".surfaceShader") -source `getAttr motrMatteShadow_NODE.MSL`; } if(`getAttr motrMatteShadow_NODE.MSN[4]` == 0){ setAttr motrMatteShadow_NODE.MSN[4] -type "string" `createNode mip_matteshadow`; //$motrmipNodecount =4 } connectAttr -f (`getAttr motrMatteShadow_NODE.MSN[4]`+".message") (`getAttr motrMatteShadow_NODE.MSG`+".miMaterialShader"); connectAttr -f (`getAttr motrMatteShadow_NODE.MSN[4]`+".message") (`getAttr motrMatteShadow_NODE.MSG`+".miShadowShader"); connectAttr -f (`getAttr motrMatteShadow_NODE.MSN[4]`+".message") (`getAttr motrMatteShadow_NODE.MSG`+".miPhotonShader"); connectAttr -f (`getAttr motrMatteShadow_NODE.MSN[2]`+".outValue") (`getAttr motrMatteShadow_NODE.MSN[4]`+".background"); connectAttr -f (`getAttr motrMatteShadow_NODE.MSN[2]`+".outValueA") (`getAttr motrMatteShadow_NODE.MSN[4]`+".backgroundA"); } else if($option == 2) { // RenderReady Output // // Camera Environment Nodes // if(`getAttr motrMatteShadow_NODE.MSN[5]` == 0){ setAttr motrMatteShadow_NODE.MSN[5] -type "string" `createNode mib_color_alpha`; //$motrmipNodecount =5 } setAttr (`getAttr motrMatteShadow_NODE.MSN[5]`+".factor") 0; connectAttr -f (`getAttr motrMatteShadow_NODE.MSN[5]`+".outValue") (`getAttr motrMatteShadow_NODE.MSN[1]`+".background"); connectAttr -f (`getAttr motrMatteShadow_NODE.MSN[5]`+".outValueA") (`getAttr motrMatteShadow_NODE.MSN[1]`+".backgroundA"); // MatteShadow Material Nodes // if(`getAttr motrMatteShadow_NODE.MSN[6]` == 0){ setAttr motrMatteShadow_NODE.MSN[6] -type "string" `createNode mip_rayswitch_environment`; //$motrmipNodecount =6 } connectAttr -f (`getAttr motrMatteShadow_NODE.MSN[6]`+".outValue") (`getAttr motrMatteShadow_NODE.MSN[4]`+".background"); connectAttr -f (`getAttr motrMatteShadow_NODE.MSN[6]`+".outValueA") (`getAttr motrMatteShadow_NODE.MSN[4]`+".backgroundA"); connectAttr -f (`getAttr motrMatteShadow_NODE.MSN[2]`+".outValue") (`getAttr motrMatteShadow_NODE.MSN[6]`+".environment"); connectAttr -f (`getAttr motrMatteShadow_NODE.MSN[2]`+".outValueA") (`getAttr motrMatteShadow_NODE.MSN[6]`+".environmentA"); if(`getAttr motrMatteShadow_NODE.MSN[7]`== 0){ setAttr motrMatteShadow_NODE.MSN[7] -type "string" `createNode mib_color_alpha`; //$motrmipNodecount =7 } setAttr (`getAttr motrMatteShadow_NODE.MSN[7]`+".factor") 0; connectAttr -f (`getAttr motrMatteShadow_NODE.MSN[7]`+".outValue") (`getAttr motrMatteShadow_NODE.MSN[6]`+".background"); connectAttr -f (`getAttr motrMatteShadow_NODE.MSN[7]`+".outValueA") (`getAttr motrMatteShadow_NODE.MSN[6]`+".backgroundA"); } }