FramebufferWriter Mental Ray shader

 

The FramebufferWriter material shader writes the connected shaders' data into separate user framebuffers. This lets you render any number of different shaders on a geometry and store the result in different images that can be used for compositing purposes.


Shader parameters:

Render Color: The shader that is to be displayed in the primary framebuffer (rendered image).
Write Framebuffers: When disabled the shader does not sample or write anything except the primary framebuffer.
Display Custom Buffer: When enabled the render does not display the shader connected to the Render Color instead it shows the data written to the specified framebuffer. This can be used to quickly check the content of a buffer.
Display Buffer Number: The number of the user framebuffer that is displayed when "Display Custom Buffer" is on.

 

Framebuffers

New connection: By middle-mouse dragging a shader here you can easily create a new buffer connection. (Requires pressing the Refresh button to update the UI after a connection is made.) You can simply create connections using the connection editor too, by connecting a shader's output into an empty framebuffers[n].fbColor slot.
FB Color: A connected shader that is to be stored in the specified buffer. Right click on the color lets you disconnect or select the connected shader.
FB Number: The buffer where the image will be stored. Valid numbers are from 0, -1 is for the uninitialized/removed state when the shader works as if the buffer was disabled.
FB Enabled: You can disable the calculation of a single buffer. If you don't need a buffer for the time being disabling it can speed up the calculation a lot for complex shaders. Don't forget that a connected and enabled shader is sampled even if the framebuffer itself does not exist.

Sort framebuffers by FB number: Reorders the already connected framebuffers to match the order of the FB numbers set. The order of the connection does not matter at all, this function is only for aesthetic reasons.

Refresh: Rebuilds the UI to display the new framebuffer connections.

Download:

FramebufferWriter1.1.zip


Istallation:

- Copy DSO file into "alias/maya/mentalray/lib" (DLL for Windows / SO for linux and OSX)
- Copy MI file into "alias/maya/mentalray/include"
- Copy the Icon file into a standard maya icon directory.
- Copy the MEL file into a standard maya mel script directory.

- Modify "alias/maya/mentalray/maya.rayrc" with the two following lines, both of them comes
after the standard link and mi lines:

link "{MAYABASE}/lib/FramebufferWriter.{DSO}"
mi "{MAYABASE}/include/FramebufferWriter.mi"


Usage:

Attach a FramebufferWriter material to the geometry whose information you'd like to put into separate framebuffers. It is likely that you'll need a FramebufferWriter shader for every material in your scene. Connect your existing material to the Render Color of the shader and the extra shaders to the buffer slots and set the FB numbers. Finally enable the buffers either by using custom text or by a FramebufferWriter/ctrl_buffers shader. (The data is only saved into an image if the buffer is initialized.)