You can import a custom shader library in the following ways:
These methods are explained in more detail below.
To import a custom shader library
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.
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.)
To load or unload custom mental ray shaders
The Shader Manager opens and shows which declaration files are loaded.
You need to add your .mi file to the MI_CUSTOM_SHADER_PATH environment variable path (unless you use the Shader manager) to load any shader that is to be rendered mental ray for Maya.
You also need to add the shader library binaries to the MI_LIBRARY_PATH environment variable.
If you have shader library binaries in many directories, then you must use the maya.rayrc file in conjunction with the MI_CUSTOM_SHADER_PATH and MI_LIBRARY_PATH environment variables. See Edit the maya.rayrc file for more information.
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/Maya2014/mentalray/shaders/include/base.mi
set MI_CUSTOM_SHADER_PATH=C:/Program Files/Autodesk/Maya2014/mentalray/shaders/include/base.mi
For parsing all files in a directory, you could use (in which no file dialog will appear) the following:
The default value of MI_CUSTOM_SHADER_PATH is Maya2014/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 sure your shader is 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
This variable tells mental ray for Maya where to locate the shader library binaries.
For loading a single file, set MI_LIBRARY_PATH as follows:
setenv MI_LIBRARY_PATH /usr/local//autodesk/Maya2014/shaders/base.so
set MI_LIBRARY_PATH=C:/Program Files/Autodesk/Maya2014/mentalray/shaders/base.dll
For parsing all files in a directory, you could use (in which no file dialog will appear) the following:
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\lib to the path :
MI_LIBRARY_PATH = C:\myshader\lib
To make sure your binaries are loaded by default, you can either add the directory to the path, or put the file in the path.
Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License