mental ray for maya - dynamic attributes

Dynamic attributes are user created attributes that extend the functionality of the mental ray for Maya plug-in.

 

mi triangles

By default, mental ray for Maya NURBS surface tesselation is derived from Maya along with an "under the hood" approximation that attempts to emulate the NURBS surface tesselator from the Maya software renderer.

Two dynamic attributes (exportTriangles and miTriangles) use the triangulation of Maya and exploit a far more memory effective translation to mental ray for Maya. 

Enable this mode globally for all meshes in the scene via a dynamic attribute on render globals node 'exportTriangles' (bool), or on a per-shape basis via a dynamic attribute 'miTriangles' (bool).

The translation engine supports direct export of the triangular tessellation of polygon meshes done in Maya instead of the usual general mesh export. This allows to bypass the much more memory-consuming mesh representation in mental ray, but still supporting displacement, derivatives (for shader filtering), and deformation
motion blur (if topology doesn't change). This mode is enabled for all meshes in the scene with the dynamic
attribute 'exportTriangles' (boolean) created and turned 'on' on the mentalrayGlobals node. Furthermore, the dynamic attribute 'miTriangles' (boolean) is recognized on shape nodes, and will override the global setting on a pre-object basis.

addAttr -at bool -ln "exportTriangles" mentalrayGlobals;

addAttr -at bool -ln "miTriangle" shapeNode;


FG rebuild freeze

Final gathering supports a new 'rebuild' mode called 'freeze' (.mi syntax). It prevents final gathering from touching the cache (final gather file) at all in subsequent renderings of the same scene. This is more restrictive than 'rebuild off', which permits to append new final gather information to the cache. To enable the 'freeze' mode a new attribute needs to be created on the mental ray options node that is in effect (miDefaultOptions), named 'finalGatherFreeze' (boolean). It is respected if the final gather rebuild mode has been turned to 'off' in the final gather section of the render globals.

select miDefaultOptions;
addAttr -ln finalGatherFreeze -at bool  miDefaultOptions;

 

 

mi displace

In order to support mental ray's displacement algorithm a proper displacement bound value 'max displace' needs to be supplied for any object. This is automatically derived from Maya's displacement map settings' 'bounding box scale' attribute on shape nodes by default. However, this value can be set directly via a dynamic attribute 'miMaxDisplace' (float) created on the shape node, which is recognized by the plug-in and exported without any further checks. Furthermore, a global default 'max displace' value can be forced via a dynamic attribute 'maxDisplace' (float) created on the mental ray options node (miDefaultOptions).

addAttr -ln maxDisplace -at "float" miDefaultOptions;

addAttr -ln miMaxDisplace -at "float" shapeNode;

 

 



final gather diagnostic with mental ray for Maya 

setAttr miDefaultOptions.diagnoseFinalg 0;   

setAttr miDefaultOptions.diagnoseFinalg 1; 

green areas are initial raster space final gather sample points.

red areas are final gather sample points at render time.

 

per object anti aliasing

displayRenderGlobalsWindow;

select miDefaultOptions;

addAttr -ln minObjectSamples -at long miDefaultOptions;

addAttr -ln maxObjectSamples -at long miDefaultOptions;

select nurbsSphereShape1;

addAttr -ln miMinSamples -at long nurbsSphereShape1;

addAttr -ln miMaxSamples -at long nurbsSphereShape1;

 

Create a window

This is a handy attribute that allows for render region controls from inside Maya. This information is then respected by Maya's Render View Window as well as any command line rendering.

addAttr -ln regionRectX -at long mentalrayGlobals;
addAttr -ln regionRectY -at long mentalrayGlobals;
addAttr -ln regionRectWidth -at long mentalrayGlobals;
addAttr -ln regionRectHeight -at long mentalrayGlobals;

 


Final Gather View – for entire scene

Final gathering accuracy (min and max radius) can be specified in 'pixel' units rather than in world space, by providing 'view' accuracy. This can be controlled by creating a dynamic attribute on the mental ray options node (miDefaultOptions) with the name 'finalGatherView' (boolean).

displayRenderGlobalsWindow;
select miDefaultOptions;
addAttr -ln finalGatherView -at bool  miDefaultOptions;

 

mi rayoffset

Can be used for those scenes where raytrace self-shadowing artifacts appear as a result of rays that in turn intersect polygons that are also being sampled. This is very similar to Maya software's Raytrace Bias control.

addAttr -ln miRayOffset -at "float" arm_rest;

 

 

 

Force Shadow Bsp

addAttr -ln miBspShadow -at bool miDefaultOptions;

The shadow bsp may lead to a performance improvement for properly tuned scenes (low detail shadow stand-ins). It can be enabled with a new dynamic attribute 'miBspShadow' (boolean) created on the mental ray options node (miDefaultOptions).

 

Force Displacement Animation

addAttr -ln miDisplaceAnimation -at bool shapeNode;

To mark objects as carrying displacement that is animated the attribute 'miDisplaceAnimation' (boolean) is recognized on shape nodes. This is a hint to the translation engine and avoids potentially expensive traversal of the DG to detect animated displacement.

 

Disable Animation Detection

addAttr -ln miAnimated -at bool yourTransform;

Animation of scene objects and related shading nodes is automatically detected in the plug-in when translating subsequent frames. This can be time consuming if huge objects need to be compared or deep DAG graphs have to be traversed. As a hint to the translation engine, individual instances or whole DAG subtrees can be excluded from this procedure by adding a new dynamic attribute 'miAnimated' (boolean) and setting it to off. Once found on a transform node, the DAG traversal will prune the remaining subtree from animation detection
(not the node itself).

 

Disable DG Cycle Detection

addAttr -ln nodeCycleCheck -at bool mentalrayGlobals;

The plug-in takes care of detecting cycles in node graphs upon translation by default. This can have a noticeable performance impact when deep shading graphs are used in a scene, even if there is no cycle at all. The detection procedure can be turned off by adding a dynamic attribute 'nodeCycleCheck' (boolean) to the render globals node and set it to 'false'.

 

Force On-Demand Translation of Geometry using Placeholders 

mental ray custom text is used to specify geometry that will be substituted at render time.

The workflow consists of 

1. Get the bounding box information for the detailed geometry inside Maya.

getAttr bigGeo.boundingBoxMin;
getAttr bigGeo.boundingBoxMax;


2. Export the geometry as an .mi file

3. Edit the .mi file by adding the word "incremental" and also adding the bounding box information.


3. In a new scene create a dummy / placeholder geometry node.


4. Add a custom text node that describes the bounding box and location of the .mi file.


5. Export the scene file.


6. Edit the scene file - take the placeholder points out of the file.


7. Render the placeholder file.

 

addAttr -ln exportObjectsOnDemand -at bool mentalrayGlobals;

addAttr -ln placeholderSize -at long mentalrayGlobals;

addAttr -ln miPlaceholder -at bool yourShape;