Rollover image to view Object ID pass (Utility shader set to 'obj')
The AOV Write shader in combination with the Utility shader is a useful combination for writing out an Object ID pass. This simple setup will allow you to use an ID pass in compositing software to identify certain objects by their color. We will also isolate certain objects and give them specific id's with which to group by color.
|A simplified example scene that also demonstrates this AOV Write workflow can be found here.|
- Start off by creating a Standard Surface shader that you want to use as the beauty shader. Create > Arnold > Surface > standard_surface in the Material Manager. Assign it to the geometry that you want to create an Object ID render.
- Open the Arnold Shader Network Editor of the material. You should see the Standard Surface shader connected to the Arnold Beauty port as in the following image.
- Now we need to create an aov_write_rgb shader (you must connect an aov_write node to each material that requires an AOV). We will use this shader to write out our 'Object ID' pass. From the search bar on the left, type 'aov_write_rgb'. Drag this shader onto the main work area in the center. Disconnect the Standard Surface shader from the Arnold Beauty port (click the yellow line to disconnect).
- Connect the AOV Write RGB shader's output to the Arnold Beauty port. You can do this by clicking and holding the circle next to Output and dragging the yellow line onto the Arnold Beauty circle.
- Select the AOV Write RGB shader and type 'ObjectID', into the aov_name. This is the name of the Object ID render pass that we want to create.
ObjectID added to aov_name of 'aov_write_rgb' shader
- Next, create a Utility shader. Change the Shade mode to flat because we only want flat shaded color for our Object ID pass. Change the Color mode to obj. Object mode will use the name of the objects in the scene to compute the color.
- Connect the Utility shader to the AOV input attribute of the AOV Write RGB shader. The output of the utility shader will be directed to our custom AOV by connecting it to the aov_input parameter.
- Connect the output of the Standard Surface shader to the Passthrough attribute of the AOV Write RGB shader. The reason its connected to the 'passthrough' is that we want to see the output of the Standard Surface shader in the beauty render.
Final shader network
- In the previous setup, we defined data to be written to our custom AOV. However, we have not added our AOV to the scene yet. Now we need to create a custom AOV to write out our Object ID. Open the Render Settings window and go to the AOVs tab.
Click on the Add custom AOV... button at the bottom of the window and the Arnold Add Custom AOV dialog will appear. Add the same name that we used in the AOV Write RGB shader earlier (ObjectID). If the names don't match it will not work.
Add a custom AOV and rename it 'ObjectID' (the same name used for the 'aov_write_rgb' shader)
- Click OK. Our newly created custom AOV appears in the Active AOVs list on the right.
Now when we open the IPR window, we can see our newly created ObjectID AOV can be found under Display! The AOV Write RGB shader collects the ObjectID attribute from the geometry and passes it to the ObjectID AOV.
Utility shader's 'Object' mode uses the name of the shapes to compute the color
At the moment the roof geometry has multiple colors based on the individual objects that the roof is comprised of. However, we may want to have only one color for the whole of the roof. What can we do? Well, we can add an Arnold tag to the roof geometry and give it an id number.
- First, ensure that the Utility shader's color mode is set to ID.
- Select the geometry that you wish to add a specific ID. In this case, we are selecting the roof geometry null. Right-click the geometry and select C4DtoA Tags> Arnold Parameters. This has added an Arnold tag to the geometry null group.
Roof null geometry has Arnold Tag with 'id 1' added to User options
- Select the Arnold tag and in the User options text field type 'id 1' (ensure you include a space between the id and 1).
- Re-render the scene. You should notice that the roof has been isolated with its own 'id' and now the geometry group is rendered with one unique color.
We can also use the Object ID Color Mode to define individual id's to object's inside a group. For example, currently, all of the windows are grouped together and so render with the same id color. If we want to change the color of one of the window objects, we can repeat the above process but apply it to the first window using a different id number (id 2).
Arnold Tag parameter added to first window with 'id 2' added to User options
Another (easier) method to define object masks is to use the Arnold Object Mask tag. See this tutorial for more details.