MayaMan has the ability to write out RenderMan shaders on-the-fly to emulate your Maya material hierarchies. We have built in support for most of Maya's native shading nodes, but with a bit of work you can extend this support for 3rd party Maya shaders too. This page will tell you how.
Any attributes listed under a node will be available to the RenderMan source code chunk for that node as 'cat2(_N_,PARAMNAME)', where PARAMNAME is the name of the parameter. See the example below for more details.
For each supported node you will find two macros in maya_magic_shaders.h which look like:
#define LAMBERT_SETUP(_N_)and
#define LAMBERT_SIM(_N_)In these macros you define your emulation code. The '_N_' parameter is used so that multiple nodes of the same time can be present in one RenderMan shader source file. MayaMan will automatically use a different number when calling each macro. The _SETUP macro is used to initialise local variables and other things that can occur at the top of a source file. The _SIM macro is called to actually do the work.
The _SIM macro is ultimately responsible for setting the 'outColor' and 'outAlpha' variables, which must be referred to by prepending the '_N_' variable passed to the macro.
simpleColor intensityYou would then add the following macros to maya_magic_shaders.h:
#define SIMPLECOLOR_SETUP(_N_) /* do nothing for setup in this case */ #define SIMPLECOLOR_SIM(_N_) \ color cat2(_N_,outColor) = color (1,0,0); \ cat2(_N_,outColor) *= cat2(_N_,intensity)MayaMan could then use this new information to support this shader, ensuring that the value set in Maya's Hypershade for the 'intensity' parameter is passed in correctly. Also, if this were a texture node rather than a material node, then MayaMan would ensure that the value set here for 'outColor' was passed on to any other nodes using that output. The cat2() function used throughout maya_magic_shaders.h is a simple macro that concatenates identifiers together.
There are many examples to be found in the maya_magic_shaders.h file, so please refer to it for more help if you are writing your own extensions.
TIP: You can see the shader source that is written out by MayaMan. The source file is written to the 'shaders' subdirectory under the RIB output directory set in the MayaMan Basic Options. However, this file will contain many macros. You can use the cpp.exe pre-processor command included with BMRT to view the fully expanded source with a command such as:
d:\bmrt2.6\bin\cpp -Ic:\animallogic\mayaman\shaders c:\temp\mayaman\shaders\mms_lambert1.sl > expanded.sl... this will write a fully expanded version into 'expanded.sl'. If you scroll to the bottom of that file you will see the bulk of the shader source code. View this to see if your node emulation code seems to be doing the correct thing after a MayaMan render.