Friday, May 11, 2012

MEL: Maya file texture node initializing for Mental ray.

The default filter type in Maya's file texture node is set to Quadratic and this is not desireable for Menta ray since Mental ray uses Mipmap filter.
And the default filter value is set to 1.0 which is a little too high for most of the case.
So you need to manually tweak these settings for every single file texture node and that's tiresome.

Instead, I'd like to automate this process using a MEL script.
To make this possible, you need to execute two tasks.
One, select all the file texture nodes in the scene.
Two, for each of these selected file texture nodes, change attribute's values.

Here's the complete script.
This script switches the current Filter Type to Mipmap and set the Filter value to a modest value of 0.5.

/* select all the file texture nodes in the scene and put them in the string array*/
string $selected[] = `ls -type "file" -long`;
/* declare two strings for file node's filterType and filter */
string $filterType, $filter;
/* loop through all the file nodes */
for ($member in $selected) {
    /* get the current attributes */
    $filterType = `getAttr ($member+".filterType")`;
    $filter = `getAttr ($member+".filter")`;
    /* set new values for the attributes */
    setAttr ($member+".filterType") 1;
    setAttr ($member+".filter") .5;

No comments:

Post a Comment