makeSpecularPass.py

Pythonscript for maya that creates a specular pass from the selected objects. Make sure to include the lights you need in your selection.

##
## Make Specular pass
## - creates a new renderlayer with selected objects. Make sure to include desired lights
## - creates a layer override and turns off emit diffuse on lights in the renderlayer
## - creates a layer override and turns off raytracing for the scene
##

import maya.cmds as cmds

## Create new renderlayer with selected objects
cmds.createRenderLayer(name='specular_Rlayer', nr=1, mc=1)

## List all lights
lightSelection = cmds.ls( lights=True)

## Turn off emitDiffuse on lights
for c,cur in enumerate(lightSelection):
	cmds.editRenderLayerAdjustment( lightSelection[c] + '.emitDiffuse' )
	cmds.setAttr( lightSelection[c]+ '.emitDiffuse', 0)

## Turn off raytracing
cmds.editRenderLayerAdjustment('miDefaultOptions.rayTracing')
cmds.setAttr ('miDefaultOptions.rayTracing', 0)
I wish to do something Great and Wonderful, but I must start by doing the little things like they were Great and Wonderful”
~ Albert Einstein