Tutorial about how to use various maya environment variable



Links for fast jump:
Environment variable (Windows)
,
Important environment variables
,
Maya.env Maya environment file
,
mental ray shaders declaration / Maya,
mental ray shaders declaration / mental ray

Setting environment variables under Windows:

If you're working under Windows, you have a pretty easy way to set and delete environment variables. Just go to “Start -> Settings -> Control Panel” and start the “System” icon. Click on the “Advanced” tab. There should be a button named environment variable.
The window has two sections. The upper one is for user variables, the lower one affects the whole system. If you wanna be flexible, you should create all your Maya variables in the user section. The first thing you should set up, is a “temp” variable for temporary files. This is automatically done by windows in the global section, do it once more in for the user. How? Simply click on the “New” button, enter “TEMP” under name and enter a path to something like “c:\temp” under value. Do the same again but this time name the variable “TMP”. You should also change the global variable. Why we have done this? Because Maya (but not only Maya) produces a big amount of temporary files. These files should be deleted from time to time. Now you know where... the default place of this temporary directories is a little bit harder to find. You now know how to create an environment variable under windows.


Important environment variables

There are other ways use environment variables in Maya. First we'll have a look which one is important, than we'll see how to set them up using a text file.

Variable Value What does it affect?
LM_LICENSE_FILE path with name
eg.: "c:\flexlm\license.dat"
points Maya to a specific license file
MAYA_SCRIPT_PATH path* this is where script paths should be entered
MAYA_PLUG_IN_PATH path* this is where plugins paths should be entered
XBMLANGPATH path* this is where icons paths should be entered
MI_CUSTOM_SHADER_PATH path* this is where mr shader paths should be entered
MAYA_MODULE_PATH path sometimes plugins come as one “package” which is called module in Maya, use an directory where an text file exist, that points Maya to the right directory
MAYA_PRESET_PATH path you wanna create your own collection of presets? Point Maya to a directory where you collect presets
MAYA_MRFM_SHOW_CUSTOM_SHADERS 1 this one was need in Maya 6.0 and lower to access mental ray custom shaders
MAYA_SLOW_DRAWPIXELS 1 this one was needed for NVidia Graphics cards so they don't produce failures when using Painteffects and Imageplanes
TMPDIR (Unix/Win ) or TEMP (Win) path points Maya to an specific directory for temporary render cache (otherwise TEMP will be used!, set both under Windows)
MAYA_HELP_URL URL this one could be used to point Maya to use another address for accessing the Maya help server. For example if you're working in an network you could set up an workstation/server to run the Maya help server. Now you don't need to install and run the Maya Help system on all your workstations
MAYA_OVERRIDE_UI path with script name points Maya to use another MEL script than “initialLayout
.mel”, this could be a custom interface
WINEDITOR path with program name overrides the expression editor with one you like
MAYA_WEBBROWSER (Unix) or WEBBROWSER path with name wanna use an alternate browser? enter the path...

-> path*: you can use more than one path
eg.: MAYA_MODULE_PATH = c:\skripts\modul1;c:\skripts\modul2;



Maya.env - Maya environment file

Maya is able to use a text file called “maya.env” for environment settings. This file is located in your Maya preference folder. This folder is placed in your users files folder / maya / mayaX.Y.
You can use different environment settings for different Maya versions. So how to set your values? Pretty much the same than before but this time just write it into this file. Open the file with an text editor (e.g.: notepad).
The syntax is pretty easy: environment_variable = value
An example:

MAYA_MRFM_SHOW_CUSTOM_SHADERS = 1

Most of the time the main directories you will set are for collections of scripts and plugins. This is done pretty easy. I would collect them in one directory structure. For example a directory called “MayaResource” on any drive (E in my case). Now you can create subfolders for example Scripts, shaders, plugin, icons. Now you place your scripts for example in sub-folders like develop (for own development), miscInternet (for various scripts) and so on... The structure:

  1. E:\MayaResource\plugins
  2. E:\MayaResource\plugins\FBXPlugin601_Maya65_Windows
  3. E:\MayaResource\plugins\Dev-Kit-plug-ins
  4. E:\MayaResource\scripts
  5. E:\MayaResource\scripts\develop
  6. E:\MayaResource\scripts\miscInternet
  7. E:\MayaResource\icons
  8. E:\MayaResource\shaders
  9. E:\MayaResource\shaders\gg_mray_shaders\include
  10. E:\MayaResource\shaders\alias\includ

Because you add all your plugins to sub-folders, you wouldn't need to add (1). Only (2) and (3). This would be the following line:

MAYA_PLUG_IN_PATH = E:\MayaResource\plugins\FBXPlugin601_Maya65_Windows; E:\MayaResource\plugins\Dev-Kit-plug-ins;

For only two directories it's quit readable, but if you use more plugins this would produce quit long lines. The solution for this are variables. You can for example but the first part which is the same for every plugin into an variable and just add the rest. Here's an example:

CUSTOM_P = E:\MayaResource\plugins
MAYA_PLUG_IN_PATH = %CUSTOM_P%\FBXPlugin601_Maya65_Windows; %CUSTOM_P%\Dev-Kit-plug-ins;

Most of the time plugins also have MEL script files. You would need to add this to the MAYA_SCRIPT_PATH variable. This would look like this:

MAYA_SCRIPT_PATH = %CUSTOM_P%\FBXPlugin601_Maya65_Windows;

together with the lines before:

CUSTOM_P = E:\MayaResource\plugins
MAYA_PLUG_IN_PATH = %CUSTOM_P%\FBXPlugin601_Maya65_Windows; %CUSTOM_P%\Dev-Kit-plug-ins;
MAYA_SCRIPT_PATH = %CUSTOM_P%\FBXPlugin601_Maya65_Windows;

You should create a variable for your scripts too...

CUSTOM_S = E:\MayaResource\scripts

and the Maya variable

MAYA_SCRIPT_PATH = %CUSTOM_S%\develop; %CUSTOM_S%\miscInternet; %CUSTOM_P%\FBXPlugin601_Maya65_Windows;


mental ray shaders declaration / Maya

mental ray shaders have to be declared two times. One time for Maya and one time for mental ray. This is something a little bit let's say strange but you have to do that. For the Maya part it's quit easy. You just need to set the MI_CUSTOM_SHADER_PATH variable. Than Maya searches through these directories and creates and entry in your hypershade.
For example:

CUSTOM_MRS = E:\MayaResource\shaders
MI_CUSTOM_SHADER_PATH = %CUSTOM_MRS%\misc\include;%CUSTOM_MRS%\gg_mray_shaders\include;

As you see, you have to always use the the directory where your *.mi files are located. These should be a the include directory. Why? Because Maya uses the shader declaration to create all the entries you need to access from hypershade. The shader library (*.dll Windows and *.so for Unix) isn't need for this. They will be used in your mental ray configuration file.
So one thing you should know about MI_CUSTOM_SHADER_PATH variable. Maya has an bug, if you use more than 6 paths, Maya will not start. This is a really bad bug, especially if you don't know that. Maya wouldn't say anything about what the problem is, so be aware of that.


mental ray shaders declaration / mental ray

mental ray for Maya has an seperate configuration file where you have to add every shader declaration file and every library. You can find this file in your Maya directory / mentalray / maya.rayrc
Open this file and you'll see that there is already something in it. It would be easy to just copy all your custom shaders into the default directories, but what if you reinstall Maya? And because we already declared our environment variable we will update the configuration files. If you don't add all your custom shaders here, you would see all shaders in hypershade and you could create your networks, but mental ray wouldn't render.
Your “maya.rayrc” should look something similar to this:

  1. registry "{MAYABASE}" value "c:/aw/maya/mentalray" end registry
  2. registry "{SYSTEM}" value "windows" end registry
  3. registry "{DSO}" value "dll" end registry
  4. $lookup "{MAYABASE}"
  5. $lookup "{SYSTEM}"
  6. $lookup "{DSO}"
  7. registry "{MRMAYA_START}"
  8. link "{MAYABASE}/lib/base.{DSO}"
  9. # ... deleted
  10. mi "{MAYABASE}/include/mayabase.mi"
  11. # ... deleted
  12. echo "mental ray for Maya - startup done"
  13. end registry
  14. $lookup "{MRMAYA_START}"

I deleted some lines to save a little space. Line (1) declares someting similar to the variables we used in maya.env to shorten the path lines. Line (2) to (3) declacres system specific settings. Line (4) to (6) activate the settings done in the previous lines. Line (7) to (13) set name and path to all shader libraries and declaration files. Line (14) activates everything done before.
Now how we will configure our custom shaders? We'll create an own block. This is done we an registry block.
There for we add our directory with an own variable.

registry "{PDDIR}" value "E:\MayaResource\shaders" end registry
$lookup "{PDDIR}"

The registry line should be added after line 1, the second line should be added after line 6. Now we wanna install the quit common dirtmap shader. We create a directory called “misc” in the shader directory. The Block would look like this:

registry "{INTERNET_SHADER}"
link "{PDDIR}/misc/lib/Dirtmap.{DSO}"
mi "{PDDIR}/misc/include/Dirtmap.mi"
echo "Public Domain internet shaders startup"
end registry

Add this after line 13. Add the next line after line 14 right at the end. This is a must-have if you wanna load the new block.

$lookup "{INTERNET_SHADER}"

If you start Maya now you'll not find the shader. You would now have to add this path to your previous created environment variable. This would look like the following in an maya.env:

CUSTOM_MRS = E:\MayaResource\shaders
MI_CUSTOM_SHADER_PATH = %CUSTOM_MRS%\misc\include;

This should be all information you need for a flexible Maya setup.

If you have more questions, just use your email editor dreamfactory@gmx.net...

go up