FramebufferOutput Mental Ray shader
The FramebufferOutput shader creates framebuffer definitions to allow rendering of multiple passes with a single render within Maya or standalone MR. Enabling user framebuffers was already possible in Maya 6 and 6.5 by adding custom text to a camera but it required the standalone version of Mental Ray and did not work at all with the Mental Ray for Maya plugin. With Maya 7 a simple solution for defining user framebuffers appeared (as file ouput passes on the camera nodes) but it is not really realiable and lacks a few important settings.
Mode: Controls the rendering of all framebuffers.
Custom render directory: The directory where the images will be rendered. By default the path of the primary rendered image is used and it is compatible with all command line settings of maya and MR standalone too.
The full image name is assembled from these components:
These framebuffers are used automatically by Mental Ray, using them does not require any additional computation.
- Depth: Z-depth
Interpolate: Averaging color information. When disabled each pixel stores the value for the frontmost object and not the weighted average.
Add new: Creates a new framebuffer using the parameters set below. Maya 6.0 (MR3.3) can only use 8 user framebuffers but newer versions (Maya 6.5, MR3.4 and above) support unlimited number of buffers.
Edit selected: Modifies the currently selected framebuffer line with the settings set using the menus. Values are only updated when the user presses this edit button or the enter on the numerical keyboard when modifying the image name.
Delete selected: Removes the selected framebuffer from the list. Delete can also be done by pressing the delete key on the keyboard.
File format: The file format the buffer uses. Most of the file formats can only store a limited type of channels.
Image name: The name of the rendered image.
User framebuffers: The list of all framebuffer settings.
Enable / disable selected: The selected framebuffer can be disabled. This means that the framebuffer is not rendered although it remains in the list. Disabled framebuffers have a comment mark "#" at the beginning of the line to show the disabled state.
- Copy DSO file into "alias/maya/mentalray/lib" (DLL for Windows
/ SO for linux and OSX)
- Modify "alias/maya/mentalray/maya.rayrc" with the two following lines, both of them comes after the standard link and mi lines:
To get FramebufferOutput working create an object, select its transform node and open the mental ray options to turn on the "Enable Geometry Shader" attribute. Click on the checker icon to attach a shader and select FramebufferOutput from the "Geometry" shader section of the "Create Render Node" dialog. (As an alternate method you can drag or connect the shader directly in the hyperShade.)
The creation of this setup can be easily done by copying the script called sz_CreateFramebufferOutput.mel to a maya script directory and using the command: sz_CreateFramebufferOutput; This command hooks up the shader to a hidden polygonal cube where you can easily change the settings.
- By default Maya uses the first (0) user framebuffer to store shader glow values, even when there is no glow enabled in the scene. In Maya 6.0 it can not be turned off, in Maya 6.5 and above you can turn off the RenderGlobals/MentalRay/Translation/Export Post Effects switch to disable it and make the framebuffer usable.
- The object that has the FramebufferOutput shader must be visible for the geometry shader to work but you can turn off the LOD visibility parameter of the object's transform node to hide it in the viewport. (Thats what the sz_CreateFramebufferOutput script does.) Hiding the object by turning off the normal visibility is like disabling the framebuffer output since this way the shader is not exported at all.
- Multiple FramebufferOutput shaders can be created and used and by showing/hiding you can easily switch between them.
- The geometry shader can be exported and imported to quickly transfer render pass setups from scene to scene. (Of course you still need to manually setup the writing to framebuffers with the shaders.)
Quite some time ago when I just finished the writing of the prototype of this shader I found a similar shader by ctrl.studio called "ctrl_buffers". Since the design of the shaders (both GUI and code) looks quite different and I needed some specific functionality I though that it does make sense to complete it. Take a look at ctrl_buffers and use the one you prefer!