Blog Archives
Maya 2015 – mental ray changes
It’s that time of year again to look at what’s changed in mental ray. While many things are available in mental ray some things may need a GUI to access. GTC showed a possible UI solution to use advanced preview features.
But first you might want to welcome mental ray’s official blog to the blogging world just posted previously:
“Inside mental ray”
NVIDIA has been hard at work on the plug-in with Autodesk support. You’ll likely notice plenty of changes in this version of Maya and this should be nothing compared to the development that’s coming. These UI examples along with demonstration were shown publicly at GTC.
Things to note in 2015:
- The Layering Library is now included with Maya 2015. These shaders should become your daily driver for all your tasks. These will continue to evolve. Tutorials to follow here as well since these have been updated quite a bit since discussed here previously. These shaders are based on the Material Definition Language.
- Ambient Occlusion on the GPU is integrated into the Maya framebuffer system.
- Global Illumination on the GPU is included but not exposed. This feature is in progress. Look for a tutorial coming soon!
- Improved “brute force” final gather that converges more quickly, especially when using fewer rays and Unified Sampling
- Ptex is now handled natively in the Maya file node. Simply open or attach a Ptex file. (Bump not supported since it relies on UVs. Use normal maps instead.)
- Tiled Texture workflow (known as udim or tiled UVs) is now supported natively in the Maya file nodes with options for Mudbox, Zbrush, and Mari conventions. Make sure to use texture formats that support Texture Caching for the best performance!
- The render settings UI gets another small facelift by defocusing rarely used controls. Work here is ongoing.
- The Environment Lighting mode (Native IBL) is now integrated into the Maya IBL system
- Improvements to Progressive Rendering and stability in Maya. Note that this feature is more complete in 3ds Max 2015 than Maya right now.
- mental ray now uses Open SubDiv from Pixar.
- Improvements to built in object lights including fixes.
- Vastly improved Light Importance Sampling (Light IS) that now handles all light types from point sources to object/mesh lights both textured and not textured (not yet exposed in the UI). Scenes with many lights now render much faster (in some cases less than a third of the original time) and with less noise. A simple “Quality” control is provided for overall control.
- The render viewport has updated controls for color space and viewing.
- Shader ball updates are improved and more interactive.
- Fast frame preview for non-progressive renders
mental ray also supports OCIO. This should make it easier for artists to use linear color workflow in the future.
What does the further future hold? As Maya catches up to existing features in mental ray, you can expect development to move forward more quickly with features reaching Maya at the same time as mental ray.
Using Mayatomr: Normal Displacement
Normal displacement is displacement relative to the surface normal. Heres a quick tutorial for using normal displacement with Mayatomr.
Start with
- Base mesh (created by down-res’ing a high-res reference mesh)
- Normal displacement map (exported with values that match the base mesh to the reference mesh)
Step-by-step
Open Maya; import base mesh; apply material shader. Typically your base mesh will have a low poly count:
From the material’s shadingEngine, attach a displacement shader.
shadingEngine > Shading Group Attributes > Dispacement mat. [map button]
Select the “File” node from prompt and load the correct displacement map. Note: Maya automatically creates a displacementShader between the shading group and the file node. Because normal displacement only requires a scalar (greyscale) value, the file node connects to the displacementShader via it’s alpha channel. “Alpha Is Luminance” has also been enabled so that the alpha is the average of the RGB channels. Set the file node’s Filter Type to Off.
file > File Attributes > Filter Type = Off
This is important because you do not want Maya to try and interpolated displacement samples. If you render now, you’ll get an interesting looking result.
The reason the image looks like this is because the displacement map is only 8-bit. Mental ray expects negative values to be inward displacement, positive values to be outward displacement, and zero to be neutral displacement. Because 8-bit images only map to positive values (0.0 to 1.0), the sculpting application has exported a displacement map where 0.5 corresponds to neutral. Offsetting the alpha by that amount (subtracting) will adjust for difference.
file > Color Balance > Alpha Offset = -0.5
You will most likely want to leave Alpha Offset at 0.0 for 32-bit/floating-point displacement maps (depending on how it was exported).
The mesh still does not match. Here’s why:
- The base mesh still has hard normals causing the displacement to open up seams as it pushes the surface outward.
- As soon as you attach a displacement shader, Mayatomr “helps” users by applying a length-distance-angle approximation to the polygon surface. This is not ideal.
We can fix both these problems by turning the mesh into a Catmull-Clark subdivision surface (ccmesh). Using the approximation editor, apply a parametric subdivision to the surface. By default, applying this approximation triggers Mayatomr to export the object as a ccmesh.
Window > Rendering Editors > mental ray > Approximation Editor
mental ray Approximation Editor > Subdivisions (Polygons and Subd. Surfaces) > Create
mentalraySubdivApprox > Subdivision Surface Quality > Approx Method = Parametric
The seams have closed up, however the mesh has lost all detail. The shadows look particularly bad because of the low triangle count. Increasing the number of subdivisions will bring back detail. To match the reference mesh, set N Subdivisions = N(reference) – N(base), in this case 5 – 1 = 4.
Lower N Subdivisions result in a loss of detail.
Larger N Subdivisions may cause visual artifacts as you exceeded the resolution of the displacement map (displacement map pixels become visible).
Unfortunately, normal displacement is inherently limited in the geometry it can describe. For modern workflows (and the my next blog post!) use vector displacement.
Using Framebuffers with the Layering Library (MILA)
You can take a brief look at the main structure of the MILA shaders inside Maya in the first post explaining their usage: The Layering Library (MILA)
One of the most important things to remember about MILA is how the framebuffer passes work.
The builtin framebuffers use the modern framebuffer mechanism in mentalray that uses a named framebuffer and type.
Your main framebuffers are additive; this means in compositing you simply add or plus the passes together to create your beauty. This avoids other operations that might cause problems like multiplication. Multiplying in compositing causes problems with edges and makes it impossible to recreate the beauty render. It also complicates compositing objects onto one another or plates.
Your main passes are (First given as a Light Path Expression (LPE)):
- L<RD>E or direct_diffuse
- L.+<RD>E or indirect_diffuse
- L<RG>E or direct_glossy
- L.+<RG>E or indirect_glossy
- L<RS>E or direct_specular
- L.+<RS>E or indirect_specular
- L.+<TD>E or diffuse_transmission
- L.+<TG>E or glossy_transmission
- L.+<TS>E or specular_transmission
- LTVTE and/or front_scatter and back_scatter
- emission (in LPE, emission is actually a light)
Direct effects are usually the result of the light source.
Indirect effects are usually the result of light from other objects.
Why include LPE? LPE makes specifying passes the same for all rendering solutions. This idea unifies the conventions used for getting the same data regardless of renderer used.
You also have the option to add custom shaders on top of this in the material root node. Keep in mind that what is added here may increase render time since they are run separately from the material and we typically reserve them for inexpensive utility passes like noise, fresnel, and ID mattes.

The Root node, the mila_material This includes the ability to create and attach custom framebuffers for output
Getting these framebuffer passes from Maya requires a bit of a workaround using a legacy user pass system rediscovered by Brenton. I find it to be easier than using Custom Color with the exception you have to keep track of the names of your passes and spell them correctly to match up. MILA also makes it a universal solution since all shaders are set to automatically write to these buffers without more work. This is part of the idea behind LPE: the light path stored is always the same for the LPE chosen regardless of renderer. Making this automatic is an easy decision in this case.
For the passes built into MILA you simply need to have the framebuffers ready with the correct name and MILA will write to them automatically. Keep in mind that Maya’s current system overwrites data written to their default passes like “diffuse” so you cannot use those or the same names if they are used in the scene.
Fist: Select the miDefaultOptions node
select miDefaultOptions;
Second create a framebuffer:
AEmrUserBuffersAppend miDefaultOptions.frameBufferList;
The above command creates a user framebuffer seen as default below.
You have two selections above: Data Type and whether or not to interpolate (filter) the result.
You typically want to interpolate results for color framebuffers like direct diffuse, ID mattes, fresnel passes, etc. You do NOT want to interpolate data buffers like z-depth, normals, world points, etc.
You can see the typical data types that should not be interpolated at the bottom of the list. These data types are not interpolated by mental ray because it is mathematically incorrect for compositing. They also require high precision so you will notice they default to Floating Point 32-bit data.
I have not used the LPE for direct diffuse because Maya does not allow angled brackets and other symbols in text fields for names at this point. After creating and naming your passes, you can then add them to the camera Output Shaders as the last step to render them.
When you create an entry you will see a Output Pass that looks like the default one below.
Since we have already created passes, you can select the “Use User Buffer” option, then in the dropdown “user Buffer” menu, select the pass you want. Below is the direct_diffuse example:
I then select the following options:
- File Mode: I want to write to the rendered file
- Image Format: OpenEXR, I have already specified 16-half float and EXR as my rendering format in the main Render Settings editor.
- File Name Postfix: I leave this blank. This way all of the passes are written to the same EXR and packed together as layers.
You can follow this same method when adding user passes to the mila_material root. Be sure and name them the same as the pass you will create and then reference in the camera Output Shader
Keep in mind that the usual Maya Default passes for data will still work with MILA and you can select those as well instead of adding those default passes here. It’s useful here if you need different or additional data per shader. ID Mattes are very useful in this case. And in fact, this shader can detect and use the user_data shaders for you to assign ID groups and other data to objects. This means you can render complex scenes with fewer shaders and still organize the passes logically. This will be a future explanation since this introduces a new workflow/pipeline for getting information from Maya while avoiding the Render Layers system when possible.
In the example file below you’ll see I am driving some parameters of the shader with attached object data. This has a few benefits. One such benefit is the data follows the object rather than the shader and you can change the result of the shader by manipulating the object user_data. I also have a single sphere in one ID matte group but also included with another group of ID mattes, giving me different ways to handle the object in post.
You can find an example workflow in this Maya File [removed since MILA updates broke it, need to make a new one]. The scene has the default framebuffers and a couple ID mattes set up. You can play with the materials and quality to get other buffers to show a result (for example, emission is empty because I am not using that effect.) I also have single-layer materials. Try mixing and matching and seeing the resulting framebuffers. Be sure and attach your own HDRI to the Maya IBL Image.
(Maya 2013 SP2)
Additional layering/mixing is left to user experimentation.
The Layering Library (MILA) UI: BETA SHADERS
*These materials have been released for Maya 2015. The below post applies to the Beta shaders. There have been changes to the materials and SIGNIFICANT changes to how they are presented/integrated inside Maya 2015. Please see the newer posts on these.*
Shaders were previously announced for future beta here and have been released today.
Below are the UIs and brief descriptions of the various parts of the Layering Library known as MILA. More complex examples and Phenomenon© will become later posts. But this should get you started on the basics. The next post will show how to create framebuffers in Maya using the legacy user framebuffer mechanism. Since framebuffers are simply named and built-in, it makes for easy rendering without making connections in Maya.
This library is currently designed as a flexible replacement for (at a minimum) the fast_sss, metalllic paint, car paint, and mia_material shaders. (You should have hopefully abandoned Lambert, Blinn, Phong, etc quite some time ago in mental ray. . .)
This begins the bridge to more modern flexible rendering by following the nVidia Material Definition Language. You may find this a little familiar if you have used the iray layered material.
The image below is rendered from the Unified Sampling post with MILA: glossy reflection, scattering, and diffuse reflection. The lighting is Environment Lighting Mode and final gathering. Depth of Field and image rendered brute force with Unified Sampling.
The shaders introduce several important things:
- Built-in framebuffers handled by the root node.
- Better importance sampling
- Improved glossy reflection with a default linear curve
- Scattering node that no longer uses a pre-process or lightmapping phase and is multi-threaded
- Default physical correctness and energy conservation (without the emission node) regardless of layering/mixing
- Shared light loops that improve performance when layering shaders
- Framebuffers that provide a mathematically correct workflow in compositing by outputting additive passes
- Framebuffers that introduce you to the Light Path Expression grammar and concepts
- Correct lighting scale without need for 1/pi multiplication with modern lighting like the user_ibl_env and the Native IBL
- etc.
Why use MILA? Beyond their forward looking design there are some more logical reasons to use these shaders.
These shaders free the developer and artist in a few different ways.
For developers using the MILA API, you can create your own components to share in the framework. This means you can create and update a component at a time. By building phenomenon from the networks, your updates and additions can be made immediately available without coding and compiling multiple monolithic shaders. Debugging individual pieces can also be easier and faster before creating a phenomenon.
For artists it introduces better performance, more flexibility, and a workflow designed for future shading and lighting. While all the components may seem tedious to begin setting up in Maya, these can be Phenomenized easily. This means shaders can be used and shared as Phenomenon over and over again with a simplified UI. For example: opaque objects do not require shaders with controls like “refraction” or “translucency”. You can greatly reduce the control set and expose what you need, even setting your own defaults for specific materials to re-use later. (Some useful Phenomenon come with the package)
Caveats in Maya for the Beta:
- These are not integrated shaders by Autodesk as yet, these are as-is
- Maya does not automatically connect Shadow and Photon shaders to the mila_material node
- Components make their own unnecessary Shading Group at creation. They are easily removed by using “Delete Unused Shaders” from the Hypershade menu
- Some convenient global features like per-component samples rely on String Options (found in the miDefaultOptions and explained here)
- The automatic creation of the UI from the node factory (.mi files) may have errors, these need to be discovered during the Beta
- Shader updates may break previous scenes saved with MILA shaders
- Use area lights for lighting!
Some of the above problems can be solved through UI creation with mel. As part of the Beta, you can collaborate on useful AEtemplate and presets for the nodes.
The main components of the node follow a familiar pattern for those of you used to either the DGS material or iray.
Diffuse Reflection and Transmission
Glossy Reflection and Transmission
Specular Reflection and Transmission
(Scattering is handled separately as well as emission)
Below is an example from the documents on a possible layering scenario at two levels. Keep in mind that layering and mix nodes can also be plugged into one another. This makes layering easier when you need to combine effects or re-use networks you have already built as part of another network.
As I explain some components I assume a familiarity with the mia_material as some of those settings and concepts are repeated here. So instead I will touch on things that have changed or are new.
The mila_material node: This is the root node of the network.
- Visibility: this is like the “cutout opacity” of the mia_material
The top shader connection is meant for a layer or mix node explained below.
This contains the built-in framebuffers and a way to expose them at render time by showing them in the primary buffer using the “Show Framebuffer” integer. In Maya this can be enumerated in the .mi file to make the UI more intuitive.
The additional “Extra” framebuffers can be specified here to run other shaders and utilities when the shader is executed. An example would be an Extra Color for a label or ID pass used in compositing.
The mila_layer node: Used to layer components, other layer nodes, and mix nodes together.
Below is the default empty node with the familiar “Thin Walled” parameter from the mia_material
The below example has a single top layer added. Each new layer added is beneath the previous layer when it is rendered. (Top – down design)
- Shader: for adding a component such as mila_glossy_reflection, layer, or mix node
- On/Off: turn this layer on or off (participate in rendering)
- Weight: simple scalar value to decide how much weight or energy absorption this layer has
- Weight Tint: as above but using a color value, this can tint the result returned by the shader component
- Use Directional Weight: with the feature off, the resulting component has no fresnel or directional falloff curve. The effect is applied evenly over the surface.
- Fresnel Mode: this mode uses Ior to control the curve used for the component effect, this is familiar from the mia_material “use fresnel” switch
- Custom Mode: this is used to apply a Schlick curve that can be manually changed on the shader, this is familair from the mia_material (opportunity to hide/expose the control based on a mel selection of Directional Weight Mode)
- Bump: per component bump applications, for now in Maya you need to use the Connection Editor since drag and drop or regular connection from the menu fails to work. Maya expects a shader for a bump node and not a vector so it gets confused.
The mila_mix node: Used to simply mix components together. Rather than think of a top -> down approach as in layering, think of simply mixing two paints together. Red and Blue make Purple for example.
Below is the default empty node with the same “Thin Walled” option as well as a way to change the energy conservation to a clamp mode.
The below mila_mix example has two components added to the node.
- Shader: accepts a component, other mix, or layer node
- On/Off: turn this layer on or off (participate in rendering)
- Weight: simple scalar value to decide how much weight or energy absorption this layer has
- Weight Tint: as above but using a color value, this can tint the result returned by the shader component
- Bump: per component bump applications, for now in Maya you need to use the Connection Editor since drag and drop or regular connection from the menu fails to work. Maya expects a shader for a bump node and not a vector so it gets confused.
The mila_diffuse_reflection node: this is the Lambertian (or Oren-Nayer using roughness) node that is very similar to the mia_material.
There is an added feature, the Rgb Bump vector. This is used to quickly simulate a sub-surface scattering effect when a bump is applied to a diffuse surface. This is not useful without a bump effect applied to the shader in the layer or mix node. This allows colors to be applied to a bump in varying degrees and therefor simulating an inexpensive and shallow scattering effect.
The mila_diffuse_transmission node: this is a simple node used for translucency effects.
There is an indirect multiplier node for controlling indirect interactions such as final gathering
The mila_glossy_reflection node: this is the glossy (blurry or rough) reflection node. This node has received quite a bit of attention and should get a lot of testing to further improve it through feedback.
Things to notice that are different than the mia_material:
- Roughness: this is the amount of blur for the reflection. 0.0 is a mirror-like reflection while 1.0 is diffuse reflection. This is a visually linear curve and the direct reflections now match the indirect reflections, unlike the reflection and specular (direct reflection) response of the mia_material that was originally preferred by artists. Lower ray counts for brute force no longer result in a darker reflection like mia_material. Energy is conserved correctly.
- Samples: this parameter means the same things as the mia_material but you’ll notice that now 0 samples means ‘take the samples amount from the global string option’ “mila glossy samples” instead of mirror. This is a convenient setting that exists across the shaders so you have one location for setting samples. This is important to simplify rendering and using Unified Sampling. Individual shaders can still be tuned individually if necessary.
- Visible Area Highlight: an inexpensive application of multiple importance sampling. -1 is the recommended default and allows the shader to choose whether to sample lights indirectly (reflection ray) or a light directly (light sampling). 0.0 is indirect reflection only. 1.0 is direct reflection only. Amounts in-between are mixtures of the schemes. As the roughness increases, so does the possible contribution of direct light sampling. If your area light has insufficient samples or Unified Quality isn’t high enough, these areas will exhibit grain. Using the framebuffers will help you decide where the noise is coming from (indirect or direct glossy reflection).
- Roughness Exponent: allows the user to change the curve of the glossy parameter from visually linear to something else that might be useful. You may find the amount of 1.5 to be most useful but some testing will help determine the best default for final release.
Important to note: this shader actually performs best with an area light. Spot, point, and directional lights all have zero area to sample and are less intuitive to use when mimicking traditional lighting from the real world. Take a look at the Area Lights 101 post for more ways to simplify and speed up your renders. In the examples here I am using a disc area light with no decay. From the point of interest I aligned it with the sun in the HDR which is also a Native IBL that is emitting light on “automatic” mode.
The mila_glossy_transmission node: this is the glossy (blurry or rough) refraction node. The parameters are similar to above but include ior to refract (bend) rays passing through the object.
The mila_specular_reflection node: This node is simply a mirror reflection. It shoots a single ray and can be colored.
Important to note here: this shader is indirect reflection only. This will not generate a highlight for invisible or infinitely small (point) lights. If the light itself must be visible, you must use something that is visible to reflection with an actual size or area such as the user_ibl_rectangle or an area light.
The mila_specular_transmission node: Same as above but refracts rays through the object. There is no option to blur the result.
The mila_scatter node: this is the multi-threaded (no lightmap) sub-surface shader. These parameters mean essentially the same thing as the SSS2 shader found in the current documents and Maya 2013. If you are familiar with the new SSS2, then this shader should be simple to control

The Scattering or SSS node with tinted orange scatter. White is also acceptable/preferred tint to start with.
- Resolution: this is a control that sets the amount of detail the shader will capture in screen space. 2 is the default and means half resolution. 1 is same resolution as render and 0 is double the resolution. Higher numbers decrease the resolution accordingly.
The mila_transparency node: this is simple colored transparency.
This can be layered to create cutout-like effects and transparency in simple cases where ior is not required. But you may find the “thin walled” option in the layering node to be more appropriate.
The mila_emission node: this is similar to the “additional color” of the mia_material or incandescence in other materials. It’s simple to use but does not emit light as an object light. Final gather will sample the object as an emitter.
The mila_get_roughness node: This utility is so you can use maps painted for the mia_material glossiness inside the mila_glossy nodes without major modification.
The mila_get_normal node: this is used to get and alter the normal for bump maps.
This is not needed in Maya. You can manually connect a Maya bump node to the layer or mix node with the connection editor. This node is needed in 3ds Max.

An adapter for bump mapping, not required in Maya, the native bump node works with the help of the connection editor
NEXT: How to create framebuffers for MILA inside Maya.