Tuesday, 20 May 2014

Render time smoothing

Render Time Smoothing

1) This puts a zero level smooth on all selected objects in the scene

$allObjs = `ls -sl`;
if(size($allObjs)>=0)
{
     for ($thisObj in $allObjs)
          {
               polySmooth  -mth 0 -dv 0 -bnr 1 -c 1 -kb 1 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 1 -peh 0 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1 $thisObj; 
          }
}


2) select everything in the scene that has a polysmooth node on it

2A) Turn smooth on 
$allSmooths = `ls "*polySm*"`;
if(size($allSmooths)>0)
{
    for($thisSmooth in $allSmooths)
    {
        setAttr ($thisSmooth+".divisions") 1;      
    }  

}

2B) Turn smooth off
$allSmooths = `ls "*polySm*"`;
if(size($allSmooths)>0)
{
    for($thisSmooth in $allSmooths)
    {
        setAttr ($thisSmooth+".divisions") 0;      
    }  

}

or in a single line
$allSmooths = `ls "*polySm*"`;if(size($allSmooths)>0){for($thisSmooth in $allSmooths){setAttr ($thisSmooth+".divisions") 1;}}
$allSmooths = `ls "*polySm*"`;if(size($allSmooths)>0){for($thisSmooth in $allSmooths){setAttr ($thisSmooth+".divisions") 0;}}

and to add this to the pre-render MEL commands you can run the following lines

setAttr -type "string" defaultRenderGlobals.preMel "$allSmooths = `ls \"*polySm*\"`;if(size($allSmooths)>0){for($thisSmooth in $allSmooths){setAttr ($thisSmooth+\".divisions\") 1;}}";
setAttr -type "string" defaultRenderGlobals.postMel "$allSmooths = `ls \"*polySm*\"`;if(size($allSmooths)>0){for($thisSmooth in $allSmooths){setAttr ($thisSmooth+\".divisions\") 0;}}";

Copy the above two highlighted blocks of  MEL and make shelf buttons out of them so all you have to do is run the render set up (second block) once for your scene, and select lowres polygons and run the second one every time you add a new object that you want rendertime smoothed.


No comments:

Post a Comment