The Maya scene file for this example - teapots_RISShaders.ma - is included with the RMS Tutorials bundle.
The shadow and reflection collectors are AOVs via Light Path Expressions.
The shadow collector LPE (lpe.shadowcollector) gathers the amount of occlusion/shadow for direct lighting only and at camera hits only. Note that it is possible to write a custom LPE that would include shadows for non-direct lighting.
The reflection collector LPE (lpe.reflectioncollector) captures all indirect specular reflections, for any number of bounces. It will not include any direct illumination (only indirect illumination from specular reflections).
How To Render Alpha AOV
In order to use the shadow and reflection AOVs in the comp, we need an alpha AOV for the objects that cast the shadow and reflection onto the receiving object (e.g. the ground plane). In PRMan 19, the PxrMatteID pattern, along with MatteID AOVs, can be used to generate the objects' alpha.
Unlike the traditional alpha channel (Oi) available in previous versions of PRMan, using the PxrMatteID pattern is more flexible and allows assigning different colors to different objects in the scene. It is then possible to use compositing software to extract an alpha channel for one or more groups of objects in the scene using the AOV generated by the PxrMatteID pattern. The MatteID AOV also matches the motion blur accurately.
Since PxrMatteID has to be connected to each bxdf shader that contributes to MatteID, it is recommended to plan ahead of time to simplify your workflow for generating the alpha AOVs. If you only need to use it as an alpha for shadow collector, it may be simpler to create a separate render pass where there are only a few shaders (with your original displacement shader connected) with a few MatteID AOVs. A lot of AOVs makes it harder to manage.
How To Create A Shadow/Reflection Collector In Maya
- Select the object you want to collect shadow or reflection, e.g. the ground plane.
- Select the object's Material in the Maya Attribute Editor.
- In the Attribute Editor, select menu Attributes/Renderman/Add Collector Attr. This will create and set the LPE Group collector to be "collector" under the Extra RenderMan Attributes for the selected Material.
- To set up AOVs for the LPE, in the RenderMan Globals, from your Final pass's Output/LPE tabs, select color lpe:reflectioncollector and color lpe:shadowcollector from the LPE list, then right-click and select Create Outputs from Channels. This will create output channels for lpe:shadowcollector and lpe:reflectioncollector.
Interactively, you will see the additional AOVs under the beauty render in "it".
For a batch render, the additional AOVs will be written to the files on disk:
Say we have a render of the teapots on a CG ground plane.
To keep this example simple, we have a standin of the background plate using a constant color we created in Nuke:
We want to transfer the reflection and shadow from the CG render to the new background, so we rendered out the shadow and reflection collector AOVs:
The alpha of the teapots use PxrMatteID and MatteID01 AOV for the comp. In this example, we assign the MatteID01 to red with the intention of extracting the red channel as an alpha.
Here's the result, with the teapots on a new ground:
The above comp example is done in Nuke. Here is a snapshot of the network:
The script - rmsTeapots_ShadowReflectionComp.nk - and images are included in the compExample directory of the tutorials bundle.