Renderman + Masks

New video up on generating masks (mattes) in Renderman for Maya.

Here’s a quick script to connect up a single PxrMatteID node to many PxrMaterial nodes.

import pymel.core as pym
mynodes = pym.ls (sl=True, fl=True, dag=False, ni=True)

mybxdfs = []
myhairs = []
mymatteid = []

for x in mynodes:
    if isinstance(x , (pym.nodetypes.PxrSurface, pym.nodetypes.PxrLayerSurface)):
        mybxdfs.append(x)
    if isinstance(x , ( pym.nodetypes.PxrMarschnerHair)):
        myhairs.append(x)
    if isinstance(x , (pym.nodetypes.PxrMatteID)):
        mymatteid.append(x)

if len(mymatteid) == 1:
    for b in mybxdfs:
        mymatteid[0].resultAOV.connect(b.utilityPattern[0], force=True)
    for h in myhairs:
        mymatteid[0].resultAOV.connect(h.inputAOV, force=True)        
elif len(mymatteid) != 1:
    print 'too many PxrMatteID nodes selected, just try one'

Enjoy

Leave a Reply

Your email address will not be published. Required fields are marked *