![]()
Load shaders
To import a custom shader library
- Copy the declaration file to the
includedirectory of your mental ray for Maya installation.- Copy the library file into the
libdirectory of your mental ray for Maya installation.- Modify the configuration file
maya.rayrcin the plug-ins directory of your Maya installation. Add statements to include the declaration file and to link with the library file.
Note
Editing themaya.rayrcfile is optional. By default, mental ray for Maya looks for shader libraries in the default install directory:...\Autodesk\Maya8.5\mentalrayIf your shader libraries are not located in the default directory, you must use themaya.rayrcfile 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
.milibrary files that contain the mental ray shader declarations. The shaders contained in the selected.milibrary 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_SHADERSto show custom shaders in Hypershade.)
To load or unload custom mental ray shaders
- Select Window > Rendering Editors > mental ray > Shader Manager.
The Shader Manager opens and shows which declaration files are loaded.
- 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
.mifile 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
.mifiles 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:
- Linux®
setenv MI_CUSTOM_SHADER_PATH /usr/local//autodesk/Maya8.5/include/base.mi
- Windows
set MI_CUSTOM_SHADER_PATH=C:/Program Files/Autodesk/Maya8.5/mentalray/include/base.miFor parsing all files in a directory, you could use (in which no file dialog will appear) the following:
- Unix®
setenv MI_CUSTOM_SHADER_PATH /usr/local/mi/rayinc31
- Windows
set MI_CUSTOM_SHADER_PATH=c:/usr/local/mi/rayinc31The 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\includeTo 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
.mifiles will be created. See the Script Editor for nodes being created.Same for your shader. If the
.mifile 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 )