Your Ad Here

Load shaders

To import a custom shader library

  1. Copy the declaration file to the include directory of your mental ray for Maya installation.
  2. Copy the library file into the lib directory of your mental ray for Maya installation.
  3. Modify the configuration file maya.rayrc in the plug-ins directory of your Maya installation. Add statements to include the declaration file and to link with the library file.

Note
Editing the maya.rayrc file is optional. By default, mental ray for Maya looks for shader libraries in the default install directory:
...\Autodesk\Maya8.5\mentalray
If your shader libraries are not located in the default directory, you must use the maya.rayrc file so that Maya can see your shaders. See, Edit the maya.rayrc file.

mental ray for Maya is able to load and render with your custom shader library. Placing the declaration file in the include directory also uses mental ray for Maya to parse the file and create new Maya node types that correspond to the shaders declared in the library.

With the mental ray Shader Manager

The Shader Manager lets you interactively load and unload mental ray shader libraries and work with them during a Maya session. (You do not need to shut down first, and you do not need to set the environment variable MI_CUSTOM_SHADER_PATH.)

You can select from a list of.mi library files that contain the mental ray shader declarations. The shaders contained in the selected.mi library files automatically appear in Hypershade, just like the Maya and mental ray for Maya base shader nodes. mental ray for Maya base shaders are now fully integrated into Hypershade and Create Render Node panel.

(You do not need to set the environment variable MAYA_MRFM_SHOW_CUSTOM_SHADERS to show custom shaders in Hypershade.)

Note
Though you can dynamically load/unload shaders in render time, those shaders that are used should be specified in the maya.rayrc file.
The maya.rayrc file requires both .mi and, or .so of the desired libraries to be included.

To load or unload custom mental ray shaders

  1. Select Window > Rendering Editors > mental ray > Shader Manager.

The Shader Manager opens and shows which declaration files are loaded.

  1. Click to load or unload a declaration file, auto load the file, or get information on the file. For descriptions of the buttons and options in the mental ray Shader Manager window, see Window > Rendering Editors > mental ray > Shader Manager.

With the MI_CUSTOM_SHADER_PATH environment variable

You need to add your .mi file to this environment variable path (unless you use the Shader manager) to load any shader that is to be rendered mental ray for Maya.

This variable tells mental ray for maya a directory where .mi files are located. Every .mi file located in MI_CUSTOM_SHADER_PATH will be parsed on plug-in load.

This environment variable should be set prior to loading the plug-in. mental ray for Maya interprets this variable in different ways. If it is not empty but does not point to an existing file or directory, a file dialog opens up as the mental ray for Maya plug-in is (auto-)loaded. A .mi file should be selected that contains mental ray shader/phenomenon declarations which the Factory should create Maya node types for. The file dialog comes up again in a loop to allow more than one .mi file to be loaded. It stops when the Cancel button has been pressed.

If the Factory should load all required files automatically, then a file or a directory containing .mi files should be given in the environment variable. For loading a single file, set MI_CUSTOM_SHADER_PATH as follows:

setenv MI_CUSTOM_SHADER_PATH /usr/local//autodesk/Maya8.5/include/base.mi

set MI_CUSTOM_SHADER_PATH=C:/Program Files/Autodesk/Maya8.5/mentalray/include/base.mi

For parsing all files in a directory, you could use (in which no file dialog will appear) the following:

setenv MI_CUSTOM_SHADER_PATH /usr/local/mi/rayinc31

set MI_CUSTOM_SHADER_PATH=c:/usr/local/mi/rayinc31

The default value of MI_CUSTOM_SHADER_PATH is Maya8.5/mentalray/include.

You can modify Maya.env to add your own directory to the path. For example, the following line in Maya.env will append C:\myshader\include to the path :

MI_CUSTOM_SHADER_PATH = C:\myshader\include

To make your shader be loaded by default, you can either add the directory to the path, or put the file in the path.

While mental ray plug-in is loaded, base.mi, contour.mi and physics.mi are parsed, nodes for each shader declared in the .mi files will be created. See the Script Editor for nodes being created.

Same for your shader. If the .mi file is in MI_CUSTOM_SHADER_PATH, you should be able to find your shader name in the Script Editor. For example, my Script Editor has following lines (if optionVar miFactoryVerbosity is set to 4 or higher. ( myshader1 and myshader2 are declared in myshader.mi )

      // generating nodes ... 
      // parsing C:/myshader/include/myshader.mi 
      // myshader1 
      // myshader2 

 

Return to Autodesk Index


Your Ad Here