// RenderStats V 1.3 // author: Daniel Stern // info: This tool automaticaly sets Stats for rendering and shader usage // usage: Make any selection and start the script (setRenderStats) global proc createDepthShader(float $locMinDepth, float $locMaxDepth) { // Creates a Depthshader with mininmal and maximal depth set to the in values if(`objExists dsDepthShader`) { print("Depth-Shader already exists\n"); return; } shadingNode -n dsDepthShader-asShader surfaceShader; sets -renderable true -noSurfaceShader true -empty -name dsDepthShaderSG; connectAttr -f dsDepthShader.outColor dsDepthShaderSG.surfaceShader; shadingNode -n dsMultiplyDivide_1 -asUtility multiplyDivide; shadingNode -n dsPlusMinusAverage -asUtility plusMinusAverage; shadingNode -n dsMultiplyDivide_2 -asUtility multiplyDivide; shadingNode -n dsSetRange -asUtility setRange; shadingNode -n dsSamplerInfo -asUtility samplerInfo; connectAttr -f dsSamplerInfo.pointCamera dsMultiplyDivide_1.input1; updateBinMembershipAfterConnection dsSamplerInfo; connectAttr -f dsSamplerInfo.pointCamera dsMultiplyDivide_1.input2; updateBinMembershipAfterConnection dsSamplerInfo; connectAttr -force dsMultiplyDivide_1.outputX dsPlusMinusAverage.input1D[0]; updateBinMembershipAfterConnection dsMultiplyDivide_1; connectAttr -force dsMultiplyDivide_1.outputY dsPlusMinusAverage.input1D[1]; updateBinMembershipAfterConnection dsMultiplyDivide_1; connectAttr -force dsMultiplyDivide_1.outputZ dsPlusMinusAverage.input1D[2]; updateBinMembershipAfterConnection dsMultiplyDivide_1; connectAttr -force dsPlusMinusAverage.output1D dsMultiplyDivide_2.input1X; updateBinMembershipAfterConnection dsPlusMinusAverage; setAttr dsMultiplyDivide_2.operation 3; setAttr "dsMultiplyDivide_2.input2X" 0.5; connectAttr -f dsMultiplyDivide_2.outputX dsSetRange.valueX; updateBinMembershipAfterConnection dsMultiplyDivide_2; connectAttr -f dsSetRange.outValueX dsDepthShader.outColorR; updateBinMembershipAfterConnection dsSetRange; connectAttr -f dsSetRange.outValueX dsDepthShader.outColorG; updateBinMembershipAfterConnection dsSetRange; connectAttr -f dsSetRange.outValueX dsDepthShader.outColorB; updateBinMembershipAfterConnection dsSetRange; addAttr -ln MinDepth -at double -min 0 -dv 0 dsDepthShader; setAttr -e -keyable true dsDepthShader.MinDepth; addAttr -ln MaxDepth -at double -min 0 -dv 1000 dsDepthShader; setAttr -e -keyable true dsDepthShader.MaxDepth; connectAttr -f dsDepthShader.MinDepth dsSetRange.oldMinX; updateBinMembershipAfterConnection dsDepthShader; connectAttr -f dsDepthShader.MaxDepth dsSetRange.oldMaxX; updateBinMembershipAfterConnection dsDepthShader; select -r dsSetRange ; showEditor dsSetRange; setAttr "dsSetRange.maxX" 1; setAttr "dsDepthShader.MinDepth" $locMinDepth; setAttr "dsDepthShader.MaxDepth" $locMaxDepth; } global proc createDirtShader() { if(`objExists dsDirtShader`) { print("Dirt-Shader already exists\n"); return; } shadingNode -asShader surfaceShader -n dsDirtShader; sets -renderable true -noSurfaceShader true -empty -name dsDirtShaderSG; connectAttr -f dsDirtShader.outColor dsDirtShaderSG.surfaceShader; string $dirtName; $dirtName=`mrCreateCustomNode -asUtility "" Dirtmap`; setAttr ($dirtName+".Samples") 32; setAttr ($dirtName+".FarClip") 100; connectAttr -f ($dirtName+".outValue") dsDirtShader.outColor; } global proc createMatteSdwShader() { if(`objExists dsMatteSdwShader`) { print("Matte-Shader with Shadows already exists\n"); return; } shadingNode -n dsMatteSdwShader -asShader useBackground; sets -renderable true -noSurfaceShader true -empty -name dsMatteSdwShaderSG; connectAttr -f dsMatteSdwShader.outColor dsMatteSdwShaderSG.surfaceShader; setAttr "dsMatteSdwShader.specularColor" -type double3 0 0 0 ; setAttr "dsMatteSdwShader.reflectivity" 0; setAttr "dsMatteSdwShader.reflectionLimit" 0; } global proc createBlackShader() { if(`objExists dsBlackShader`) { print("Black-Shader already exists\n"); return; } shadingNode -n dsBlackShader -asShader surfaceShader; sets -renderable true -noSurfaceShader true -empty -name dsBlackShaderSG; connectAttr -f dsBlackShader.outColor dsBlackShaderSG.surfaceShader; } global proc createWhiteShader() { if(`objExists dsWhiteShader`) { print("White-Shader already exists\n"); return; } shadingNode -n dsWhiteShader -asShader surfaceShader; sets -renderable true -noSurfaceShader true -empty -name dsWhiteShaderSG; connectAttr -f dsWhiteShader.outColor dsWhiteShaderSG.surfaceShader; setAttr "dsWhiteShader.outColor" -type double3 1 1 1 ; } global proc createMatteNoSdwShader() { if(`objExists dsMatteNoSdwShader`) { print("Matte-Shader w/o Shadows already exists\n"); return; } shadingNode -n dsMatteNoSdwShader -asShader useBackground; sets -renderable true -noSurfaceShader true -empty -name dsMatteNoSdwShaderSG; connectAttr -f dsMatteNoSdwShader.outColor dsMatteNoSdwShaderSG.surfaceShader; setAttr "dsMatteNoSdwShader.specularColor" -type double3 0 0 0 ; setAttr "dsMatteNoSdwShader.reflectivity" 0; setAttr "dsMatteNoSdwShader.reflectionLimit" 0; setAttr "dsMatteNoSdwShader.shadowMask" 0; } global proc createRefShader() { if(`objExists dsRefShader`) { print("Reflection-Shader already exists\n"); return; } shadingNode -n dsRefShader -asShader phong; sets -renderable true -noSurfaceShader true -empty -name dsRefShaderSG; connectAttr -f dsRefShader.outColor dsRefShaderSG.surfaceShader; setAttr "dsRefShader.color" -type double3 0 0 0 ; setAttr "dsRefShader.cosinePower" 1000; setAttr "dsRefShader.specularColor" -type double3 1 1 1 ; setAttr "dsRefShader.reflectivity" 1; } global proc createRefractShader(float $index) { shadingNode -n dsRefractShader -asShader lambert; sets -renderable true -noSurfaceShader true -empty -name dsRefractShaderSG; connectAttr -f dsRefractShader.outColor dsRefractShaderSG.surfaceShader; setAttr "dsRefractShader.color" -type double3 0 0 0 ; setAttr "dsRefractShader.transparency" -type double3 1 1 1 ; setAttr "dsRefractShader.refractions" 1; setAttr "dsRefractShader.refractionLimit" 12; eval("setAttr \"dsRefractShader.refractiveIndex\" "+$index); } global proc setRenderStats() { global string $sRSWindow; global int $pV=1; global int $rS=1; global int $cS=1; global int $viRfl=1; global int $viRfr=1; global int $shdrType=0; global float $refrIndex=1.1; $sRSWindow = `window -title "* . SetRenderStats" -iconName "*.RS" -rtf 1 -wh 10 10`; columnLayout -adjustableColumn true; frameLayout -label "Render Stats" -borderStyle "etchedIn" -collapsable true; columnLayout -adjustableColumn true; checkBox -label "Primary Visibility" -v $pV -align "center" -cc "$pV=#1;print $pV;" chkPV; checkBox -label "Receive Shadows" -v $rS -align "center" -cc "$rS=#1;print $rS;" chkRS; checkBox -label "Cast Shadows" -v $cS -align "center" -cc "$cS=#1;print $cS;" chkCS; checkBox -label "Visible in Reflections" -v $viRfl -align "center" -cc "$viRfl=#1;print $viRfl;" chkRFL; checkBox -label "Visible in Refrections" -v $viRfr -align "center" -cc "$viRfr=#1;print $viRfr;" chkRFR; rowLayout -numberOfColumns 4 -columnWidth4 80 80 80 80; button -label "All On" -w 80 -al "center" -command ("$pV=$rS=$cS=$viRfl=$viRfr=1; checkBox -e -v $pV chkPV; checkBox -e -v $rS chkRS; checkBox -e -v $cS chkCS; checkBox -e -v $viRfl chkRFL; checkBox -e -v $viRfr chkRFR;"); button -label "Shadows" -w 80 -al "center" -command ("$pV=$rS=$viRfl=$viRfr=0;$cS=1; checkBox -e -v $pV chkPV; checkBox -e -v $rS chkRS; checkBox -e -v $cS chkCS; checkBox -e -v $viRfl chkRFL; checkBox -e -v $viRfr chkRFR;"); button -label "Raytrace" -w 80 -al "center" -command ("$pV=0;$rS=$viRfl=$viRfr=$cS=1; checkBox -e -v $pV chkPV; checkBox -e -v $rS chkRS; checkBox -e -v $cS chkCS; checkBox -e -v $viRfl chkRFL; checkBox -e -v $viRfr chkRFR;"); button -label "All Off" -w 80 -al "center" -command ("$pV=$rS=$cS=$viRfl=$viRfr=0; checkBox -e -v $pV chkPV; checkBox -e -v $rS chkRS; checkBox -e -v $cS chkCS; checkBox -e -v $viRfl chkRFL; checkBox -e -v $viRfr chkRFR;"); setParent ..; setParent ..; setParent ..; frameLayout -label "Shader" -borderStyle "etchedIn" -collapsable true; columnLayout -adjustableColumn true; radioCollection; radioButton -label "Default" -sl -onc "$shdrType=0" rbDef; radioButton -label "Depth" -onc "$shdrType=1"; radioButton -label "Matte No Sdw" -onc "$shdrType=2"; radioButton -label "Matte Sdw" -onc "$shdrType=3"; radioButton -label "Black" -onc "$shdrType=4"; radioButton -label "White" -onc "$shdrType=5"; radioButton -label "Dirt" -onc "$shdrType=8"; radioButton -label "Reflection" -onc "$shdrType=6"; radioButton -label "Refraction" -onc "$shdrType=7"; floatSliderGrp -label "Index" -field true -minValue 0.0 -maxValue 2.0 -fieldMinValue 0.0 -fieldMaxValue 2.0 -value $refrIndex -cc "$refrIndex=#1"; setParent ..; // radioCollection -edit -select $defShd $shaderRC; setParent ..; setParent ..; button -label "Assign Settings" -command ("setRSSettings();$shdrType=0;radioButton -e -sl rbDef"); showWindow $sRSWindow; } global proc setRSSettings() { global int $pV; global int $rS; global int $cS; global int $viRfl; global int $viRfr; global int $shdrType; global float $refrIndex; print $shdrType; string $obj; string $allObjects[]; select -hi; $allObjects = `ls -sl -g`; print("setAttr \""+$obj+".primaryVisibility\" "+$pV); print("\n"); print("setAttr \""+$obj+".castsShadows\" "+$cS); print("\n"); print("setAttr \""+$obj+".receiveShadows\" "+$rS); print("\n"); print("setAttr \""+$obj+".visibleInReflections\" "+$viRfl); print("\n"); print("setAttr \""+$obj+".visibleInRefractions\" "+$viRfr); print("\n"); string $shd2Use; if($shdrType==1) // Depth { if(!`objExists dsDepthShader`) { createDepthShader(0,1000); } $shd2Use="dsDepthShaderSG"; } if($shdrType==2) // Matte No Sdw { if(!`objExists dsMatteNoSdwShader`) { createMatteNoSdwShader(); } $shd2Use="dsMatteNoSdwShaderSG"; } if($shdrType==3) // Matte Sdw { if(!`objExists dsMatteSdwShader`) { createMatteSdwShader(); } $shd2Use="dsMatteSdwShaderSG"; } if($shdrType==4) // Black { if(!`objExists dsBlackShaderSG`) { createBlackShader(); } $shd2Use="dsBlackShaderSG"; } if($shdrType==5) // White { if(!`objExists dsWhiteShader`) { createWhiteShader(); } $shd2Use="dsWhiteShaderSG"; } if($shdrType==6) // Ref { if(!`objExists dsRefShader`) { createRefShader(); } $shd2Use="dsRefShaderSG"; } if($shdrType==7) // Refract { if(!`objExists dsRefractShader`) { createRefractShader($refrIndex); } $shd2Use="dsRefractShaderSG"; } if($shdrType==8) // Dirt { if(!`objExists dsDirtShader`) { createDirtShader(); } $shd2Use="dsDirtShaderSG"; } for ( $obj in $allObjects ) { eval("setAttr \""+$obj+".primaryVisibility\" "+$pV); eval("setAttr \""+$obj+".castsShadows\" "+$cS); eval("setAttr \""+$obj+".receiveShadows\" "+$rS); eval("setAttr \""+$obj+".visibleInReflections\" "+$viRfl); eval("setAttr \""+$obj+".visibleInRefractions\" "+$viRfr); if($shdrType!=0) { sets -e -forceElement $shd2Use $obj; } } } setRenderStats();