|
Feedback
Posted: Feb 17, 2009
Category:
Important: The Ninja model was taken from CG Society Free 3D models. Please visit this link for more details.
http://features.cgsociety.org/story_custom.php?story_id=580 When outputting to render passes for compositing, it can be very useful to have the ability to select your render components by types. In this example, we are going to explore how to output render passes per material and per object.
The term âMaterial IDâ is commonly used when the render passes output the render per material. For instance selecting all surfaces that are "metal" type.
In this scene we are using 5 shaders. The objective is to have 5 different color variables for easy selection/masking in the compositing phase.
Maya 2009 has built-in render pass capabilities. This pass is called âDiffuse Material Colorâ. However, if you are using multiple objects that share the same diffuse color
or one of your shaders has a texture node attached to the color, this approach *IS* not ideal. Thus, the need to use a custom color buffer for creating Material ID pass.
Image Description: We start by adding a custom color as a render pass, and assign it to the active render layer.
Image Description: Open the Hypershade and create multiple âwriteToColorBufferâ nodes that match the same number of shaders you have in the scene.
Image Description: In the Hypershade, middle-mouse drag the shader on top of the writeToColorBuffer node and choose âEvaluation Pass Throughâ. Repeat the above step for each shading network such each element in the scene "contributes" to the custom color frame buffer. This approach can also be done on "per face" shading network, where we can use colorCustom Pass to extract a particular set of faces to ease selection and masking.
Image Description: In the Attribute Editor for each of the writeToColorBuffer nodes, choose "customColor" as the Custom Color Pass. For each material give a unique color value thus making the material different even if they share the same color value or have a texture assigned to them.
Image Description: This is the result of a material ID pass using custom color pass.Obnj
The same concept applies to the object ID (aka label ID). That is, the need to be able to select part of the rendered image based on pre-defined âlabelsâ. Currently, Maya
doe not have a direct solution for this pass, however it can be done by using multiple techniques.
Select all the objects that you wish to include in the pass, and execute the following MEL script:
Image Description: This will add a new attribute (called âMI Labelâ) for all the objects in the Extra Attributes section.
In this example, we have 11 different objects in the scene. Once we create a different âMI Labelâ for each object, we will assign a different ID value, thus making each
object unique during render time.
Image Description: Select the render camera and under the mental ray section > Output Shaders, select the Create button. This will create a mentalrayOutputPass.
Image Description: Change the Frame Buffer Type to âLabel (Integer) 1x32 Bitâ. Note: you can change the image format and the name of the pass according to your needs. It would be important to provide a File Name Postfix (suffix) to ensure proper naming of rendered elements on disk.
Image Description: The result will be a separate rendered file in the format selected in the Image Format field. in this case we use imf_disp to view the file, since it will automatically color each labels to better visualize the result.
In this approach we will use a custom depth pass to determine our object ID in the scene. We will assign a custom "depth" value for each objects (HDR values) which can then be
used as selection mask during compositing.
Image Description: Beauty Render
Image Description: We will start by adding a âCustom Depthâ pass in our associated passes, and then associate this pass to the active render layer
Image Description: In the Hypershade, we will add multiple âwriteToDepthBufferâ nodes. These nodes can be found under the Miscellaneous section of the mental ray nodes.
Image Description: We will connect the â.outColorâ attribute of the Shader to the writeToDepthBufferâs â.evaluationPassThroughâ attribute.
Image Description: In the Attribute Editor of the writeToDepthBuffer, change Custom Depth Pass to the custom depth pass node that we added in the Render Settings. For each writeToDepthBuffer node we will give a different value for each Depth.
Image Description: Once we render the result will be like this. Each depth value can be considered as "ID" in this case. It is important to use a file format that can support HDR, like IFF and openEXR.
This workflow allows to re-texture surfaces during compositing stage.
Image Description: In this example, this geometry has multiple UV shells (11 in total) and all located in the 0-1 region.
Image Description: We will start by creating a Custom Color Pass (same as above) and then assign it to the active render layer.
Image Description: Then add a âwriteToColorBufferâ node in the Hypershade
Image Description: In the Hypershade, middle-mouse drag the shader on top of the writeToColorBuffer node and choose âEvaluation Pass Throughâ. Again, in Hypershade, under the mental ray Nodes > Textures section, create a mib_texture_vector node. Then add it to the Color value of the writeToColorBuffer node.
Image Description: In the Attriubte Editor for each of the writeToColor nodes, choose âCustom Colorâ as our Custom Color Pass. For the Color input, it will be driven by another shader which "extract" UVs
Image Description: In the mib_texture_vector node, change the âProjectâ to âuvâ. By default the shader will extract the first UV (0), if you have many UVs, you need to increase the "select" attribute to 1, or 2, etc.
Image Description: Now when you perform a render, you will get a color variation based on the UV shells of your mesh.
|
|||||||||||||||||||||