Los Angeles mental ray® User Group
 Home   About   Info   Summaries   Gallery   Forum   Resources   Contact   Jobs 


Resources Sections

General

Install/Setup

Options Settings

Performance Optimizations

mi Scene File

FG/AO/GI

Subsurface Scattering

Shiny Stuff

mrfm (Maya)

Shader Writing

Hair and Geometry Shaders

Maya 6 Extra Attributes

The mental ray for Maya plugin understands some extra attributes that are not explicitly connected to the UI in Maya 6. When created as dynamic attributes on the appropriate nodes, so as to appear in the UI as extra attributes, these undocumented attributes extend the controllability of features in mental ray. Please understand that because these attributes are "under the hood", they are unsupported and we cannot guarantee whether or not, or in what form, each may appear in future Maya releases.

The above links jump to sections in a table listing the associated attributes, types, and to which type of node they apply. With a brief description of its functionality, and possibly a link to Paolo Berto's more detailed tips on the subject, we also present a MEL command, (which can be executed directly, by clicking on it from within Maya 6's browser.)


Discuss on LAmrUG forum

Adding extra attributes to nodes

Maya presents a couple of ways to add extra attributes to nodes. You may either use a MEL addAttr command or add it manually through an Attribute Editor (AE) menu. To add from the menu, first select the node on which you want to create the attribute. Then, as the selected node is displayed, use the Add Attribute menu in the Attribute Editor pane.

There are two kinds of node attributes: global and scene element specific (local). While the local attributes usually reside on a shape, SG or light node, the global attributes reside on the nodes holding global data. Typically, you use the global attributes through the Render Globals menu, rather than selecting their nodes explicitly in the Attribute Editor (AE). However, for the purpose of creating attributes, you will need to select the nodes in the AE. One way to do this: type in the name of the particular node instance into the AE select box on the top of the AE window.

Maya has three types of global mentalray nodes and a top-level container node to prevent instances of these nodes from being optimized out of scenes. The top-level container node has only one instance named the same as its type, mentalrayItemsList; its inputs connect to all nodes carrying global mental ray information. Likewise, the mentalrayGlobals node also has only one instance named the same as its type. The remaining two node types, miDefaultFramebuffer and mentalrayOptions, can have multiple instances providing savable sets of attributes. Only one instance of each type connects as an input to mentalrayGlobals. The default instances are miDefaultFramebuffer and miDefaultOptions

Note the match between the options node names and the multiple choices of options at the top of the mental ray tab in Render Globals. When you switch defined sets of options or framebuffers, you are actually connecting a different instance of the options or framebuffer node to the mentalrayGlobals node instance. Those familiar with MEL can also see the setup for these in mayadir/scripts/others/mentalrayUI.mel.

To create extra attributes for any instance of mentalrayOptions, use the instance named miDefaultOptions and it will propagate to all instances of this type. None of the extra attributes presented on this page attach to a mentalrayFramebuffer node, so use the singular mentalrayGlobals node for the other globals.

In summary, when adding an extra attribute to the options or globals node, select either

  • miDefaultOptions or
  • mentalrayGlobals,
and add the attribute using the AE menu. Of course, you may also use a MEL command. For example,

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

When adding an extra attribute to a local scene specific node, select that specific node and add the attribute. For example, you might select a specific shape node to add a per-object attribute. Of course, you may also use a mel command. For example,

AttributeEditor;
select yourShape;
addAttr -ln miMinSamples -at long yourShape;


Discuss on LAmrUG forum



Custom Label support

AttributeTypeNode
miLabellongvarious

If you wish to take advantage of labels, you can put this attribute on certain entities, such as transform nodes (instances), shape nodes (objects), and lights. A label is an integer identification number for this entity which can be accessed and used by shaders.

It is also used by label framebuffers to help identify in an image what is first hit by the eye ray for that sample. If an instance and its object both have labels, Maya prefers the instance label.In Maya 6.5, the Custom Entities option to 'Pass Custom Labels' will change this behavior to prefer object labels over instance labels, when they both exist.

No convenient label framebuffer support yet.

MEL:addAttr -ln miLabel -at long various;


Custom Render region

AttributeTypeNode
regionRectX
regionRectY
regionRectWidth
regionRectHeight
longmentalrayGlobals

The Mayatomr command has a documented render region support option named -rr/regionRectangle (integer). Note that you must use the -rr option in conjunction with -vw, the render preview option.

It is also possible to control the render region with the above-named global attributes.

The Mayatomr command region arguments take precedence over the global attributes. In addition, the region is sticky, so you only need to do another region render, and it will retain the region you previously specified. To return to normal behavior when using the global attributes, you must delete them.

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


Custom Text Variables

NameCharacterUsage
Placeholder$$attribute

Ever wish for a variable while using custom text? You can now use attribute placeholders!

The dollar sign ($) placed in front of an attribute name will signal the custom text evaluator to replace the name with the attribute value. Obviously, this attribute name should be known to exist. All numeric attribute types and string types are recognized.

Be careful to understand how to get animating information through to the custom text node. Animation is not checked on the custom text node, but the connected Maya node. If you're using a dynamic attribute that has been key animated in a custom text node, be sure to force the animation on the related Maya node to get the export right.

Finally, frame number placeholder support has been extended to support padding using the at-sign (@) character. The number of these characters that you use indicates the amount of padding. For example,

NameCharacterUsage
MEL``command`

The back apostrophe (') enclosing a string signals the custom text evaluator to execute this string as a MEL command. Only MEL commands which return string values will work.

This has the same note as above regarding animating through the custom text node.

NameCharacterUsage
Frame number@@@@@

The frame number placeholder support has been extended to support padding using the at-sign (@) character. The number of these characters that you use indicates the amount of padding. For example, '@@@@' pads up to four characters with zeros.



Custom File Texture Frame Number

NameCharacterUsage
Frame number@@@@@

The at-sign (@) character for frame numbers are also supported for custom file texture nodes for both readable and writable (ie lightmap) textures.

It also supports image plane image file name when 'Use Frame Extension' has been enabled. Frame padding can be indicated using multiple at-sign (@) characters.

Note that only one such sequence is supported in the file name.



Custom Motion Vectors

AttributeTypeNode
exportCustomVectorsboolmentalrayGlobals

Support for shaders which generate their own motion vectors. In order to use these kind of custom shaders, a facility has been created to export 'zero' motion vectors, which will be filled in by the shaders that generate their own. An example could be a displacement shader.

This may be obvious, but this functionality requires that motion blur be enabled either through Maya (with DeriveFrom Maya), or under mental ray render quality.

A global attribute named 'Export Custom Vectors' controls this feature. By default, custom motion vectors are enabled.

Please note that this attribute is already defined in the Translation->Customization section. There should be no need to use the mel command.

MEL:addAttr -ln exportCustomVectors -at bool mentalrayGlobals;
AttributeTypeNode
miCustomMotionboolyourShape

In addition to the global attribute exportCustomMotion, only objects marked on their shape nodes with this attribute will be considered for custom motion.

MEL:addAttr -ln miCustomMotion -at bool yourShape;


Custom Colors Support

AttributeTypeNode
exportCustomColorsboolmentalrayGlobals

In Maya, RGB colors and alpha travel separate paths. In mental ray, the alpha is treated as a fourth component to color. This attribute provides support for custom mental ray shaders which depend on the alpha component of a 4-component color. Note that contour shaders fall in this category.

Once this global is enabled, Maya exports its 3-component colors as 4-component RGBA colors to all custom mental ray shaders. However, the alpha component added is always set to 1.0.

Please note that this attribute is already defined in the Translation->Customization section. There should be no need to use the mel command.

MEL:addAttr -ln exportCustomColors -at bool mentalrayGlobals;


Custom Tangents Support

AttributeTypeNode
miTangentsboolyourShape

This attribute supports per-object control of tangent vector (bump basis vector) calculation for polygon meshes and NURBS surfaces. It overrides the global 'Export ... Derivatives' options and marks or ignores the current shape accordingly for tangents computation.

This supports two common scenarios:

  1. Only a few objects (shape nodes) need to specifiy this. So you disable tangents globally, and enable them on the shape nodes needing them.
  2. Most objects (shape nodes) need to specifiy this. So you enable tangents globally, and disable them on the shape nodes not needing them.

The tangents are first order derivatives supplied as mental ray 'bump basis vectors'. They are required for maybase shader filtering and bump mapping purposes.

MEL:addAttr -ln miTangents -at bool yourShape;


Custom Derivatives Support

AttributeTypeNode
miDerivativeslongyourShape

First and/or second order derivatives for NURBS and subdiv surfaces can be made available to shaders. These derivatives are calculated by mental ray in the process of rendering. This attribute has the following values:
0 - no derivs
1- first order derivs
2- second order derivs
3- first and second order derivs

MEL:addAttr -ln miDerivatives -at long yourShape;


Custom Deformation Support

AttributeTypeNode
miDeformationboolyourShape

This attribute supports per-object control of deformation and motion vector calculation. It overrides the global 'Export Shape Deformation' option and marks the specified object for inclusion or exclusion from deformation motion blur depending on how the global option is set.

By using per-object rather than global deformation control, one could acclerate translation of animations and detection of motion blur dramatically.

MEL:addAttr -ln miDeformation -at bool yourShape;


Force Dynamic Projection

mi Scene File VariableValue
"maya_projection_dynamic"1
mi Scene File Command 
set "maya_projection_dynamic" "1"
set "maya_projection_dynamic"

One can evaluate the projection transformation once every sample point instead of once a frame. This feature is uniquely enabled by adding a variable to the mi scene file. From the Maya UI, you can add this to the scene export by using the custom scene text.

Enable dynamic evaluation of the incoming transformation matrix for every sample point instead of once per frame by setting this to 1 as shown on the first command line above. Disable by setting without a value, as shown on the second line above.



Force Displacement Bounds

AttributeTypeNode
maxDisplacedoublemiDefaultOptions

Typically the bounding box scale attribute on shape nodes is used to derive the maximum displacement bounds, known as 'max displace' in mi scene files. Instead of deriving it from the bounding box, you can directly set it.

This attribute creates a global default for the 'max displace' value on all objects.

MEL:addAttr -ln maxDisplace -at double miDefaultOptions;
AttributeTypeNode
miMaxDisplacedoubleyourShape

Or, use this shape node attribute to set it directly on a per-object basis. This overrides both the bounding box derived value as well as the global attribute.

MEL:addAttr -ln miMaxDisplace -at double yourShape;


Force Light's Emitted Photons

AttributeTypeNode
causticPhotonsEmit
globIllPhotonsEmit
longyourLight

The number of photons specified in a Maya light for caustics and global illumination specifies the number of photons to be 'stored'. If you want to have more exact physical simulations, you can specify the number of photons emitted. If created on directional, point and spot lights, Maya will export them along with the photons 'stored' number.

MEL:addAttr -ln causticPhotonsEmit -at long yourLight;
addAttr -ln globIllPhotonsEmit -at long yourLight;


Final Gather Options

AttributeTypeNode
finalGatherFreezeboolmiDefaultOptions

When using a finalgather file with 'rebuild off', mental ray will not reconstruct final gather points from scratch for each new scene rendering. However, it may append new final gather points to the file, for example, if the camera has moved, and there may be other points to add. Final gathering supports a new rebuild mode called 'freeze', which prevents mental ray from touching the finalgather file at all in subsequent renderings of the same scene.

This attribute can enable the freeze option, but only if rebuild is turned off.

In Maya 6.5, this has been brought out to the UI, in the Final Gather section of mental ray Render Globals. The Rebuild options are now: On, Off, Freeze

MEL:addAttr -ln finalGatherFreeze -at bool miDefaultOptions;
AttributeTypeNode
finalGatherViewboolmiDefaultOptions

Final gathering accuracy (min and max radius) can be specified in pixel units rather than in world space. In mental ray syntax, this is called "view" accuracy. It can be enabled from the UI by creating a dynamic attribute named 'finalGatherView' (boolean), on the mental ray options (miDefaultOptions) node and setting it to true.

In Maya 6.5, this has been brought out to the UI, in the Final Gather section of mental ray Render Globals, but it does not work yet.

MEL:addAttr -ln finalGatherView -at bool miDefaultOptions;


Force Transparent Shadows With Caustics

AttributeTypeNode
optimizePhotonShadowsboolmentalrayGlobals

Transparency evident in non-opaque shadows and colored shadows require appropriate shadow shaders, usually generated automatically by the plugin. When photon tracing has been enabled through global illumination or caustics, the shadow shaders are not used because one expects the emitted photons to illuminate the scene, passing through transparent and tinted materials appropriately. However, when you use caustics without global illumination, the resulting shadows are often unacceptably dark because some light interaction is missing. Furthermore, caustics are often used to add light patterns to the usual direct illumination solution.

This attribute can be used to control shadow shader generation globally for caustics/global illumination. Be careful; it has somewhat of a double negative usage, in that you turn it off to use the feature. If turned 'off', shadow shaders will always be generated, even if photon tracing has been enabled.

In Maya 6.5, this is controlled through the Direct Illumination Shadow Effects option in the Caustics/GI section of mental ray Render Globals (at the bottom).

MEL:addAttr -ln optimizePhotonShadows -at bool mentalrayGlobals;
AttributeTypeNode
mrExportShadowShaderboolyourShadingGroup(SG)

Additionally, shadow shader handling can be controled per material. This attribute on the shading group node will override the global attribute setting for this material, and always generate shadow shaders if enabled.

In Maya 6.5, this is now documented in the Maya Help manual.

MEL:addAttr -ln mrExportShadowShader -at bool yourShadingGroup(SG);


Force Object Samples

AttributeTypeNode
miMinSamples
miMaxSamples
longyourShape

In addition to global min and max sample settings, mental ray supports per-object sample settings as named above. These shape node attributes override the global settings from the Render Globals as well as the following attributes. Override means that the region over this object will pay attention to these instead of the globals, however, these settings must still be within the global range. Also, note that in 6.0.1, miMaxSamples works for mi export, but not in interactive rendering. miMinSamples works for both.

In Maya 6.5, these are now available on the shape node in the mental ray tab, however the bug issue with max xamples still exits.

MEL:addAttr -ln miMinSamples -at long yourShape;
addAttr -ln miMaxSamples -at long yourShape;
AttributeTypeNode
minObjectSamples
maxObjectSamples
longmiDefaultOptions

These are global defaults for all objects in a scene that don't specify their own sample values using the per-object shape node attributes. They also serve as the default for any area of the image not covered by an object. When using both per-object and default object samples, any region over the object will use the greater of the per-object min and the default object min, as well as the greater of the per-object max and the default object max.

*** Paolo's Per-Object Samples Tips

*** LAmrUG Per-Object Samples Tips

In Maya 6.5, these are now available in the mental ray Render Globals menu, in the Antialiasing Quality -> Samples Defaults section.

MEL:addAttr -ln minObjectSamples -at long miDefaultOptions;
addAttr -ln maxObjectSamples -at long miDefaultOptions;


Force Object Ray Offset

AttributeTypeNode
miRayOffsetdoubleyourShape

Set the per-object 'ray offset' value with this attribute.

MEL:addAttr -ln miRayOffset -at double yourShape;


Force Shadow Bsp

AttributeTypeNode
miBspShadowboolmiDefaultOptions

With this attribute, you can enable the shadow BSP, which may lead to a performance improvement for properly tuned scenes (low detail shadow stand-ins). Note the non-typical capitalization in the spelling, 'Bsp', in the attribute name.

In Maya 6.5, this is now incorporated in the Memory section of mental ray Render Globals. See the checkbox for Separate Shadow BSP.

MEL:addAttr -ln miBspShadow -at bool miDefaultOptions;


Force Photon Auto Volume Mode

AttributeTypeNode
photonAutoVolumeboolmiDefaultOptions

The 'mayabase' shaders depend on the 'auto volume' ray tracing mode for rendering volume effects. If 'photon' volume shaders are involved then the same mode needs to be enabled for photon tracing. This can be achieved by turning on this attribute.

MEL:addAttr -ln photonAutoVolume -at bool miDefaultOptions;


Force Displacement Animation

AttributeTypeNode
miDisplaceAnimationboolyourShape

Use this attribute to mark objects as carrying displacement that is animated. Although not necessary for accurate rendering, this hint to the translation engine avoids potentially expensive traversal of the DG to detect animated displacement. Once this attribute is on the shape node, it will not traverse, therefore, saving you time whether you want to indicate that there is displacement animation or that there is no displacement animation. Consequently, if you create it, you have to be careful to set it correctly.

MEL:addAttr -ln miDisplaceAnimation -at bool yourShape;


Disable Animation Detection

AttributeTypeNode
miAnimatedboolyourTransform

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 creating this attribute and turning it off. Once found on a transform node, the DAG traversal will prune the remaining subtree from animation detection.

In Maya 6.5, this is now documented in the Maya Help manual.

MEL:addAttr -ln miAnimated -at bool yourTransform;


Disable DG Cycle Detection

AttributeTypeNode
nodeCycleCheckboolmentalrayGlobals

The plug-in takes care of detenting cycles in node graphs upon translation by default. This can have a noticable 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 creating and using this attribute.

In Maya 6.5, this is now documented in the Maya Help manual.

MEL:addAttr -ln nodeCycleCheck -at bool mentalrayGlobals;


Force Triangle Export of Polygon Meshes

AttributeTypeNode
exportTrianglesboolmentalrayGlobals

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 can be enabled for all meshes in the scene with the creation of this global attribute.

MEL:addAttr -ln exportTriangles -at bool mentalrayGlobals;
AttributeTypeNode
miTrianglesboolyourShape

This shape node attribute will override the global setting on a per-object basis.

MEL:addAttr -ln miTriangles -at bool yourShape;


Force On-Demand Translation of Geometry using Placeholders

AttributeTypeNode
exportObjectsOnDemandboolmentalrayGlobals

For huge scenes that hit the memory limit during translation to mental ray (and usually can't be translated as a whole but only in pieces, layers, split objects or the like), the plug-in supports export of simple placeholder geometry (bounding boxes). The actual geometry is then translated only when requested from mental ray during rendering, thus reducing memory requirements and possible translation time, if the object is never accessed during rendering.

On the other hand, the render time could rise due to callback overhead and sequential execution of the translation, thus affecting parallel performance of mental ray.

The on-demand translation works only for integrated rendering, and is enabled by creating this render globals attribute. By itself, it will enable placeholder translation for all objects in the scene.

The placeholder mechanism is not supported for motion blur yet.

MEL:addAttr -ln exportObjectsOnDemand -at bool mentalrayGlobals;
AttributeTypeNode
placeholderSizelongmentalrayGlobals

For tuning purposes, this attribute can be set to a threshold value for the minimum number of points (for mesh, nurbs surface, subdiv surface) that should force the usage of the placeholder mechanism.

MEL:addAttr -ln placeholderSize -at long mentalrayGlobals;
AttributeTypeNode
miPlaceholderboolyourShape

Furthermore, a per-object attribute for the shape node will override the global setting.

In Maya 6.5, this is now documented in the Maya Help manual.

MEL:addAttr -ln miPlaceholder -at bool yourShape;

Discuss on LAmrUG forum


 © 2003-2006 Los Angeles mental ray® User Group, All Rights Reserved.
mental images and mental ray are registered trademarks of mental images GmbH, in the United States
and other countries. Other product names may be trademarks of their respective owners.


About Us| Contact Us