In Maya 2016 we are introducing basic support for loading and rendering MDL materials with mental ray. In this post we want to take a closer look at how these materials can be used in Maya. For a general introduction to MDL in mental ray, check out this post.
Before starting to use MDL materials in Maya, we recommend to update the library that is used by mental ray to process MDL. Please download this archive, extract it to a temporary directory, choose the file suitable for your platform and replace the libmdl.dll (libmdl.so on Linux, libmdl.dylib on Mac) in the bin directory of your mentalrayForMaya2016 installation with the new version. On a Windows system, this is typically in C:\Program Files\Autodesk\mentalrayForMaya2016\bin (see image below), on a Unix system it is /usr/autodesk/mentalrayForMaya2016/bin and on MacOS /Applications/Autodesk/mentalrayForMaya2016/bin.
The MDL Node
In Maya, MDL materials are represented by a new surface shader node called mdl_material, which is located in the mental ray surface material section of the “Create Material” window or “Hypershade”.
When you assign an mdl_material to an object, you will see that it contains two drop down lists: One for choosing an MDL module and another one for choosing an MDL material:
An MDL module is a file which can contain one or more MDL materials and has a “.mdl” extension. By default, mental ray for Maya 2016 ships only one module, that contains the default_material, a light grey diffuse. Because of that, both drop down lists contain just one entry.
To populate the lists you will need more materials. In the next section, we will see how to get some.
Adding MDL materials
As already announced in the MDL introduction post, example materials can be downloaded here.
1) Unzip the archive to a temporary directory.
By default, mental ray for Maya uses one root directory for placing MDL modules, the directory shaders/mdl within your mentalrayForMaya2016 installation.
2) Copy the folder mdl_examples_for_maya_3dsmax into the MDL root directory as shown below:
If you do not have write permissions in the Program Files directory or would generally prefer another location, you can define additional MDL root directories by specifying the MI_MDL_PATH. To do so, open the Maya.env file, which can be found in the Maya 2016 user directory:
Add the line
MI_MDL_PATH=<Path to MDL files>
If you, for example, make an MDL root directory called “mdl” in your Maya/2016 user directory, as shown in the screenshot above, your MI_MDL_PATH path needs to look like
More than one path can be specified, separated by a “;”.
A note on packages
In most cases, MDL modules are organized into packages, just like our example package. On disk, a package corresponds to a directory. The name of the package is the name of the directory. Packages can be nested to organize complex libraries. Within a package, modules can reference each other and contained resources (like textures) relative to each other or the package root directory. Because of this, it is important to always retain the package structure. Never just copy single mdl files or subdirectories out of a package into your MDL root directory, always use the full package, including the root folder.
Rendering MDL materials with mental ray for Maya
Now that our example package has been put into place, start Maya. Create an object and assign a mdl_material to it. The MDL Module drop down list should look like this:
When you choose a module, the material drop down list will be populated with the materials contained in the selected module, and the first material will automatically be selected. The “MDL Material Parameters” section shows the parameters of that material, which you can modify to your liking.
Other MDL materials, focused on requirements from the automotive industry are available for download in the Advanced Rendering Forum.
MDL materials are closed entities. They cannot be used in a shading network. Even though Maya allows connections to traditional shader and utility nodes, mental ray will ignore these connections. However, MDL materials can be used alongside with traditional materials and shaders.
In its initial state, the mdl_material node does not come with a swatch render, has no viewport representation and is also not supposed to work with IPR. These limitations will be removed in future releases.