Shaders¶
- Arnoldstandardsurface
AiStandardSurfaceAiStandardSurface.nodetypeAiStandardSurface.suffixAiStandardSurface.outColorAttrAiStandardSurface.diffuseWeightAttrAiStandardSurface.diffuseColorAttrAiStandardSurface.diffuseRoughnessAttrAiStandardSurface.metalnessAttrAiStandardSurface.specularWeightAttrAiStandardSurface.specularColorAttrAiStandardSurface.specularRoughnessAttrAiStandardSurface.specularIorAttrAiStandardSurface.coatWeightAttrAiStandardSurface.coatcolorAttrAiStandardSurface.coatRoughnessAttrAiStandardSurface.coatIorAttrAiStandardSurface.emissionAttrAiStandardSurface.emissionWeightAttrAiStandardSurface.normalAttrAiStandardSurface.bumpAttrAiStandardSurface.knownShader()AiStandardSurface.renderer()AiStandardSurface.createShader()AiStandardSurface.setDiffuseWeight()AiStandardSurface.diffuseWeight()AiStandardSurface.setDiffuse()AiStandardSurface.diffuse()AiStandardSurface.setDiffuseRoughness()AiStandardSurface.diffuseRoughness()AiStandardSurface.setMetalness()AiStandardSurface.metalness()AiStandardSurface.setSpecWeight()AiStandardSurface.specWeight()AiStandardSurface.setSpecColor()AiStandardSurface.specColor()AiStandardSurface.setSpecRoughness()AiStandardSurface.specRoughness()AiStandardSurface.setSpecIOR()AiStandardSurface.specIOR()AiStandardSurface.setCoatWeight()AiStandardSurface.coatWeight()AiStandardSurface.setCoatColor()AiStandardSurface.coatColor()AiStandardSurface.setCoatRoughness()AiStandardSurface.coatRoughness()AiStandardSurface.setCoatIOR()AiStandardSurface.coatIOR()AiStandardSurface.setEmission()AiStandardSurface.emission()AiStandardSurface.setEmissionWeight()AiStandardSurface.emissionWeight()
- Mayablinn
BlinnBlinn.nodetypeBlinn.suffixBlinn.outColorAttrBlinn.diffuseWeightAttrBlinn.diffuseColorAttrBlinn.diffuseRoughnessAttrBlinn.metalnessAttrBlinn.specularWeightAttrBlinn.specularColorAttrBlinn.specularRoughnessAttrBlinn.specularIorAttrBlinn.coatWeightAttrBlinn.coatcolorAttrBlinn.coatRoughnessAttrBlinn.coatIorAttrBlinn.emissionAttrBlinn.emissionWeightAttrBlinn.normalAttrBlinn.bumpAttrBlinn.knownShader()Blinn.renderer()Blinn.createShader()Blinn.setDiffuseWeight()Blinn.diffuseWeight()Blinn.setDiffuse()Blinn.diffuse()Blinn.setSpecColor()Blinn.specColor()Blinn.setSpecRoughness()Blinn.specRoughness()Blinn.setSpecWeight()Blinn.specWeight()Blinn.setEmission()Blinn.emission()
- Mayalambert
LambertLambert.nodetypeLambert.suffixLambert.outColorAttrLambert.diffuseWeightAttrLambert.diffuseColorAttrLambert.diffuseRoughnessAttrLambert.metalnessAttrLambert.specularWeightAttrLambert.specularColorAttrLambert.specularRoughnessAttrLambert.specularIorAttrLambert.coatWeightAttrLambert.coatcolorAttrLambert.coatRoughnessAttrLambert.coatIorAttrLambert.emissionAttrLambert.emissionWeightAttrLambert.normalAttrLambert.bumpAttrLambert.knownShader()Lambert.renderer()Lambert.createShader()Lambert.setDiffuseWeight()Lambert.diffuseWeight()Lambert.setDiffuse()Lambert.diffuse()Lambert.specColor()Lambert.setEmission()Lambert.emission()
- Mayaphong
PhongPhong.nodetypePhong.suffixPhong.outColorAttrPhong.diffuseWeightAttrPhong.diffuseColorAttrPhong.diffuseRoughnessAttrPhong.metalnessAttrPhong.specularWeightAttrPhong.specularColorAttrPhong.specularRoughnessAttrPhong.specularIorAttrPhong.coatWeightAttrPhong.coatcolorAttrPhong.coatRoughnessAttrPhong.coatIorAttrPhong.emissionAttrPhong.emissionWeightAttrPhong.normalAttrPhong.bumpAttrPhong.knownShader()Phong.renderer()Phong.createShader()Phong.setDiffuseWeight()Phong.diffuseWeight()Phong.setDiffuse()Phong.diffuse()Phong.setSpecColor()Phong.specColor()Phong.setSpecRoughness()Phong.specRoughness()Phong.setEmission()Phong.emission()
- Mayaphonge
PhongEPhongE.nodetypePhongE.suffixPhongE.outColorAttrPhongE.diffuseWeightAttrPhongE.diffuseColorAttrPhongE.diffuseRoughnessAttrPhongE.metalnessAttrPhongE.specularWeightAttrPhongE.specularColorAttrPhongE.specularRoughnessAttrPhongE.specularIorAttrPhongE.coatWeightAttrPhongE.coatcolorAttrPhongE.coatRoughnessAttrPhongE.coatIorAttrPhongE.emissionAttrPhongE.emissionWeightAttrPhongE.normalAttrPhongE.bumpAttrPhongE.knownShader()PhongE.renderer()PhongE.createShader()PhongE.setDiffuseWeight()PhongE.diffuseWeight()PhongE.setDiffuse()PhongE.diffuse()PhongE.setSpecColor()PhongE.specColor()PhongE.setSpecRoughness()PhongE.specRoughness()PhongE.setEmission()PhongE.emission()
- Mayastandardsurface
StandardSurfaceStandardSurface.nodetypeStandardSurface.suffixStandardSurface.outColorAttrStandardSurface.diffuseWeightAttrStandardSurface.diffuseColorAttrStandardSurface.diffuseRoughnessAttrStandardSurface.metalnessAttrStandardSurface.specularWeightAttrStandardSurface.specularColorAttrStandardSurface.specularRoughnessAttrStandardSurface.specularIorAttrStandardSurface.coatWeightAttrStandardSurface.coatcolorAttrStandardSurface.coatRoughnessAttrStandardSurface.coatIorAttrStandardSurface.emissionAttrStandardSurface.emissionWeightAttrStandardSurface.normalAttrStandardSurface.bumpAttrStandardSurface.knownShader()StandardSurface.renderer()StandardSurface.setFromDict()StandardSurface.createShader()StandardSurface.setDiffuseWeight()StandardSurface.diffuseWeight()StandardSurface.setDiffuse()StandardSurface.diffuse()StandardSurface.setDiffuseRoughness()StandardSurface.diffuseRoughness()StandardSurface.setMetalness()StandardSurface.metalness()StandardSurface.setSpecWeight()StandardSurface.specWeight()StandardSurface.setSpecColor()StandardSurface.specColor()StandardSurface.setSpecRoughness()StandardSurface.specRoughness()StandardSurface.setSpecIOR()StandardSurface.specIOR()StandardSurface.setCoatWeight()StandardSurface.coatWeight()StandardSurface.setCoatColor()StandardSurface.coatColor()StandardSurface.setCoatRoughness()StandardSurface.coatRoughness()StandardSurface.setCoatIOR()StandardSurface.coatIOR()StandardSurface.setEmission()StandardSurface.emission()StandardSurface.setEmissionWeight()StandardSurface.emissionWeight()
- Redshiftredshiftmaterial
RedshiftMaterialRedshiftMaterial.nodetypeRedshiftMaterial.suffixRedshiftMaterial.outColorAttrRedshiftMaterial.diffuseWeightAttrRedshiftMaterial.diffuseColorAttrRedshiftMaterial.diffuseRoughnessAttrRedshiftMaterial.metalnessAttrRedshiftMaterial.specularWeightAttrRedshiftMaterial.specularColorAttrRedshiftMaterial.specularRoughnessAttrRedshiftMaterial.specularIorAttrRedshiftMaterial.coatWeightAttrRedshiftMaterial.coatcolorAttrRedshiftMaterial.coatRoughnessAttrRedshiftMaterial.coatIorAttrRedshiftMaterial.emissionAttrRedshiftMaterial.emissionWeightAttrRedshiftMaterial.normalAttrRedshiftMaterial.bumpAttrRedshiftMaterial.knownShader()RedshiftMaterial.renderer()RedshiftMaterial.createShader()RedshiftMaterial.setDiffuseWeight()RedshiftMaterial.diffuseWeight()RedshiftMaterial.setDiffuse()RedshiftMaterial.diffuse()RedshiftMaterial.setDiffuseRoughness()RedshiftMaterial.diffuseRoughness()RedshiftMaterial.setMetalness()RedshiftMaterial.metalness()RedshiftMaterial.setSpecWeight()RedshiftMaterial.specWeight()RedshiftMaterial.setSpecColor()RedshiftMaterial.specColor()RedshiftMaterial.setSpecRoughness()RedshiftMaterial.specRoughness()RedshiftMaterial.setSpecIOR()RedshiftMaterial.specIOR()RedshiftMaterial.setCoatWeight()RedshiftMaterial.coatWeight()RedshiftMaterial.setCoatColor()RedshiftMaterial.coatColor()RedshiftMaterial.setCoatRoughness()RedshiftMaterial.coatRoughness()RedshiftMaterial.setCoatIOR()RedshiftMaterial.coatIOR()RedshiftMaterial.setEmission()RedshiftMaterial.emission()RedshiftMaterial.setEmissionWeight()RedshiftMaterial.emissionWeight()
- Rendermanpxrlayersurface
PxrLayerMetalnessPxrLayerMetalness.diffuseWeightAttrPxrLayerMetalness.diffuseColorAttrPxrLayerMetalness.diffuseRoughnessAttrPxrLayerMetalness.metalnessAttrPxrLayerMetalness.specularWeightAttrPxrLayerMetalness.specularColorAttrPxrLayerMetalness.specularRoughnessAttrPxrLayerMetalness.specularIorAttrPxrLayerMetalness.coatWeightAttrPxrLayerMetalness.coatcolorAttrPxrLayerMetalness.coatRoughnessAttrPxrLayerMetalness.coatIorAttrPxrLayerMetalness.emissionAttrPxrLayerMetalness.emissionWeightAttrPxrLayerMetalness.knownShader()PxrLayerMetalness.renderer()PxrLayerMetalness.createShader()PxrLayerMetalness.deleteShader()PxrLayerMetalness.assign()PxrLayerMetalness.assignSelected()PxrLayerMetalness.setFromDict()PxrLayerMetalness.shaderValues()PxrLayerMetalness.setShaderName()PxrLayerMetalness.shaderName()PxrLayerMetalness.setDiffuse()PxrLayerMetalness.diffuse()PxrLayerMetalness.setDiffuseWeight()PxrLayerMetalness.diffuseWeight()PxrLayerMetalness.setMetalness()PxrLayerMetalness.metalness()PxrLayerMetalness.setSpecWeight()PxrLayerMetalness.specWeight()PxrLayerMetalness.setSpecColor()PxrLayerMetalness.specColor()PxrLayerMetalness.setSpecRoughness()PxrLayerMetalness.specRoughness()PxrLayerMetalness.setSpecIOR()PxrLayerMetalness.specIOR()PxrLayerMetalness.setCoatColor()PxrLayerMetalness.coatColor()PxrLayerMetalness.setCoatWeight()PxrLayerMetalness.coatWeight()PxrLayerMetalness.setCoatRoughness()PxrLayerMetalness.coatRoughness()PxrLayerMetalness.setCoatIOR()PxrLayerMetalness.coatIOR()
- Rendermanpxrsurface
PxrSurfacePxrSurface.nodetypePxrSurface.suffixPxrSurface.outColorAttrPxrSurface.diffuseWeightAttrPxrSurface.diffuseColorAttrPxrSurface.diffuseRoughnessAttrPxrSurface.metalnessAttrPxrSurface.specularWeightAttrPxrSurface.specularColorAttrPxrSurface.specularRoughnessAttrPxrSurface.specularIorAttrPxrSurface.coatWeightAttrPxrSurface.coatcolorAttrPxrSurface.coatRoughnessAttrPxrSurface.coatIorAttrPxrSurface.emissionAttrPxrSurface.emissionWeightAttrPxrSurface.normalAttrPxrSurface.bumpAttrPxrSurface.knownShader()PxrSurface.renderer()PxrSurface.createShader()PxrSurface.setDiffuse()PxrSurface.diffuse()PxrSurface.setDiffuseRoughness()PxrSurface.diffuseRoughness()PxrSurface.setSpecColor()PxrSurface.specColor()PxrSurface.setSpecRoughness()PxrSurface.specRoughness()PxrSurface.setSpecIOR()PxrSurface.specIOR()PxrSurface.setCoatColor()PxrSurface.coatColor()PxrSurface.setCoatRoughness()PxrSurface.coatRoughness()PxrSurface.setCoatIOR()PxrSurface.coatIOR()PxrSurface.setEmission()PxrSurface.emission()PxrSurface.setEmissionWeight()PxrSurface.emissionWeight()
- Shaderbase
ShaderBaseShaderBase.nodetypeShaderBase.suffixShaderBase.outColorAttrShaderBase.diffuseWeightAttrShaderBase.diffuseColorAttrShaderBase.diffuseRoughnessAttrShaderBase.metalnessAttrShaderBase.specularWeightAttrShaderBase.specularColorAttrShaderBase.specularRoughnessAttrShaderBase.specularIorAttrShaderBase.coatWeightAttrShaderBase.coatcolorAttrShaderBase.coatRoughnessAttrShaderBase.coatIorAttrShaderBase.emissionAttrShaderBase.emissionWeightAttrShaderBase.normalAttrShaderBase.bumpAttrShaderBase.exists()ShaderBase.shaderType()ShaderBase.knownShader()ShaderBase.renderer()ShaderBase.attributeNames()ShaderBase.unsupportedAttributes()ShaderBase.supportedAttributes()ShaderBase.setDefaults()ShaderBase.applyCurrentSettings()ShaderBase.pullShaderSettings()ShaderBase.assignedGeo()ShaderBase.setAttrColor()ShaderBase.setAttrScalar()ShaderBase.getAttrColor()ShaderBase.getAttrScalar()ShaderBase.attrSettable()ShaderBase.attrDisconnectTexture()ShaderBase.createShader()ShaderBase.deleteShader()ShaderBase.assign()ShaderBase.assignSelected()ShaderBase.selectShader()ShaderBase.setFromDict()ShaderBase.shaderValues()ShaderBase.convertDictSrgb()ShaderBase.convertDictLinear()ShaderBase.convertDictRendering()ShaderBase.convertDictDisplay()ShaderBase.addSuffix()ShaderBase.removeSuffix()ShaderBase.setShaderName()ShaderBase.shaderName()ShaderBase.shaderNameNoSuffix()ShaderBase.srgbColor()ShaderBase.displayColor()ShaderBase.setDiffuse()ShaderBase.setDiffuseSrgb()ShaderBase.setDiffuseDisplay()ShaderBase.diffuse()ShaderBase.diffuseSrgb()ShaderBase.diffuseDisplay()ShaderBase.setDiffuseWeight()ShaderBase.diffuseWeight()ShaderBase.setDiffuseRoughness()ShaderBase.diffuseRoughness()ShaderBase.setMetalness()ShaderBase.metalness()ShaderBase.setSpecWeight()ShaderBase.specWeight()ShaderBase.setSpecColor()ShaderBase.setSpecColorSrgb()ShaderBase.setSpecColorDisplay()ShaderBase.specColor()ShaderBase.specColorSrgb()ShaderBase.specColorDisplay()ShaderBase.setSpecRoughness()ShaderBase.specRoughness()ShaderBase.setSpecIOR()ShaderBase.specIOR()ShaderBase.setCoatColor()ShaderBase.setCoatColorSrgb()ShaderBase.setCoatColorDisplay()ShaderBase.coatColor()ShaderBase.coatColorSrgb()ShaderBase.coatColorDisplay()ShaderBase.setCoatWeight()ShaderBase.coatWeight()ShaderBase.setCoatRoughness()ShaderBase.coatRoughness()ShaderBase.setCoatIOR()ShaderBase.coatIOR()ShaderBase.setEmission()ShaderBase.setEmissionSrgb()ShaderBase.setEmissionDisplay()ShaderBase.emission()ShaderBase.emissionSrgb()ShaderBase.emissionDisplay()ShaderBase.setEmissionWeight()ShaderBase.emissionWeight()ShaderBase.outNodeAttr()ShaderBase.outAttrColor()ShaderBase.inNodeAttr()ShaderBase.inAttrDiffuseWeight()ShaderBase.inAttrDiffuseColor()ShaderBase.inAttrDiffuseRoughness()ShaderBase.inAttrMetalness()ShaderBase.inAttrSpecularWeight()ShaderBase.inAttrSpecularColor()ShaderBase.inAttrSpecularRoughness()ShaderBase.inAttrSpecularIorAttr()ShaderBase.inAttrCoatWeight()ShaderBase.inAttrCoatcolor()ShaderBase.inAttrCoatRoughness()ShaderBase.inAttrCoatIor()ShaderBase.inAttrEmission()ShaderBase.inAttrEmissionWeight()ShaderBase.inAttrNormal()ShaderBase.inAttrBump()ShaderBase.connectedAttrs()ShaderBase.connectedAttrList()ShaderBase.connectAttrs()ShaderBase.setDiffuseTexture()ShaderBase.setSpecColorTexture()ShaderBase.setCoatColorTexture()ShaderBase.setEmissionColorTexture()ShaderBase.setDiffuseWeightTexture()ShaderBase.setDiffuseRoughnessTexture()ShaderBase.setMetalnessTexture()ShaderBase.setSpecWeightTexture()ShaderBase.setSpecRoughnessTexture()ShaderBase.setSpecIORTexture()ShaderBase.setCoatWeightTexture()ShaderBase.setCoatRoughTexture()ShaderBase.setCoatIORTexture()ShaderBase.setEmissionWeightTexture()
- Vraymtl
VRayMtlVRayMtl.nodetypeVRayMtl.suffixVRayMtl.outColorAttrVRayMtl.diffuseWeightAttrVRayMtl.diffuseColorAttrVRayMtl.diffuseRoughnessAttrVRayMtl.metalnessAttrVRayMtl.specularWeightAttrVRayMtl.specularColorAttrVRayMtl.specularRoughnessAttrVRayMtl.specularIorAttrVRayMtl.coatWeightAttrVRayMtl.coatcolorAttrVRayMtl.coatRoughnessAttrVRayMtl.coatIorAttrVRayMtl.emissionAttrVRayMtl.emissionWeightAttrVRayMtl.normalAttrVRayMtl.bumpAttrVRayMtl.knownShader()VRayMtl.renderer()VRayMtl.createShader()VRayMtl.setDiffuseWeight()VRayMtl.diffuseWeight()VRayMtl.setDiffuse()VRayMtl.diffuse()VRayMtl.setDiffuseRoughness()VRayMtl.diffuseRoughness()VRayMtl.setMetalness()VRayMtl.metalness()VRayMtl.setSpecWeight()VRayMtl.specWeight()VRayMtl.setSpecColor()VRayMtl.specColor()VRayMtl.setSpecRoughness()VRayMtl.specRoughness()VRayMtl.setSpecIOR()VRayMtl.specIOR()VRayMtl.setCoatWeight()VRayMtl.coatWeight()VRayMtl.setCoatColor()VRayMtl.coatColor()VRayMtl.setCoatRoughness()VRayMtl.coatRoughness()VRayMtl.setCoatIOR()VRayMtl.coatIOR()VRayMtl.setEmission()VRayMtl.emission()
- Convertshaderscene
- Standalone_runconvert
- multiRendererConnectTest
Arnoldaovs¶
Arnold AOV related
- getAllAovNodes()¶
- checkAovNameExists(name)¶
checks for the existence of all aov nodes .name, if a match is found then True, if not False
- Parameters:
name (str) – name of the AOV
- Return exists:
does the name exist on any of the aiAOV nodes?
- Rtype exists:
bool
- createAOV(aovName)¶
Creates a custom AOV with the name given keeps it unique by doing checks, the aovName is not the node name
- Parameters:
aovName
- Returns:
- Return type:
- getAllAOVsAndNames()¶
- createAiWriteColor(nodeName='aiWriteColor', imageNumber=0, matteColor=(0, 0, 0), message=True)¶
Creates a aiWriteColor Node in Maya, to be used in a RGBA Mattes (AOVs)
- createRGBMatteAOV(nodeList, matteColor, imageNumber)¶
Creates RGB mattes to shading groups associated with an nodeList, usually meshes, shaders or shading groups 1. Creates the AOV image node if it doesn’t already exist 2. Creates a aiWriteColor node and assigns the attributes correctly to match the AOV name 3. Connects between the shader and the shading group
- createRGBMatteAOVSelected(matteColor, imageNumber)¶
Creates RGB mattes to shading groups associated with a selection, usually meshes, shaders or shading groups 1. Creates the AOV image node if it doesn’t already exist 2. Creates a aiWriteColor node and assigns the attributes correctly to match the AOV name 3. Connects between the shader and the shading group
- aiMaskSet()¶
function from http://therenderblog.com/creating-id-mask-passes-using-python-based-on-selection-sets/ Not tested good example of AOV code
Arnolddisplacement¶
- createDisplacementNodes(nodeList, imagePath='', displacementType='VDM', tangentType='tangent', autoBump=False, maxDivisions=5, scaleMultiplier=1.0, bounds=0.1)¶
Creates a displacement setup for Arnold
Builds the shader node networks and changes the Arnold mesh attributes too Shading Group and Mesh selection is automatic nodeList can be any selection type related to a shader. eg mesh, transform, shader or shading group
- Parameters:
nodeList (list) – list of nodes names that could be or are related to the shading group
imagePath (str) – Optional path of the image, can be left empty str “”
displacementType (str) – either “VDM” (vector displacement map) or “height” (b&w)
tangentType (str) – either “tangent” or “object”
autoBump (bool) – autobump is a setting for regular displacement only and potentially adds a bump for fine details
maxDivisions (int) – max divisions is the highest level of subdivides the mesh can go
scaleMultiplier (float) – the scale multiplier of the displacement
bounds (float) – Increase this value if clipping occurs in the displacement
- Return shadingGroupList:
list of the shading groups names that now have displacement nodes
- Rtype shadingGroupList:
list
- Return fileNodeList:
list of the fileNodes (texture) names that have been created
- Rtype fileNodeList:
list
- Return place2dTextureNodeList:
list of the place2dTextureNode names that have been created
- Rtype place2dTextureNodeList:
list
- createDisplacementNodesSelected(imagePath='', displacementType='VDM', tangentType='tangent', autoBump=False, maxDivisions=5, scaleMultiplier=1)¶
Creates a displacement setup for Arnold from a selection Will build the node networks and change the mesh attributes too the selection can be any selection type related to a shaders, meshes, transforms, shaders or shading groups
- Parameters:
- Return shadingGroupList:
list of the shading groups names that now have displacement nodes
- Rtype shadingGroupList:
list
- Return fileNodeList:
list of the fileNodes (texture) names that have been created
- Rtype fileNodeList:
list
- Return place2dTextureNodeList:
list of the place2dTextureNode names that have been created
- Rtype place2dTextureNodeList:
list
- deleteDisplacementNodes(meshList, fileNodeList, place2dTextureNodeList, displaceNode)¶
Deletes a displacement setup for Arnold
Deletes the displacement nodes and resets the mesh subdivision attributes to be off
- Parameters:
meshList (list(str)) – The list of meshes affected by the displacement, subdivision will be turned off
fileNodeList (list(str)) – list of texture file nodes, will be deleted
place2dTextureNodeList (list()) – list of 2d place texture file nodes, will be deleted
displaceNode (str) – the Arnold displacement node type “displacementShader”
- getDisplacementAttrValues(meshList, shadingGroupList, fileNodeList, place2dTextureNodeList, displaceNode)¶
Retrieves the main attribute values of the displacement setup, usually for the UI
- Parameters:
meshList (list(str)) – The list of meshes affected by the displacement, subdivision will be turned off
fileNodeList (list(str)) – list of texture file nodes, will be deleted
place2dTextureNodeList (list()) – list of 2d place texture file nodes, will be deleted
displaceNode (str) – the Arnold displacement node type “displacementShader”
- Returns:
- Return type:
- setDisplacementAttrValues(meshList, shadingGroupList, fileNodeList, place2dTextureNodeList, displaceNode, attrDict, message=False)¶
Sets all attributes on the displacement network
- Parameters:
meshList (list(str)) – The list of meshes affected by the displacement, subdivision will be turned off
fileNodeList (list(str)) – list of texture file nodes, will be deleted
place2dTextureNodeList (list()) – list of 2d place texture file nodes, will be deleted
displaceNode (str) – the Arnold displacement node type “displacementShader”
attrDict (dict()) – Dictionary with displacement attr values see keys DISP_ATTR in shdmulticonstants.py
message (bool) – Report the message to the user?
- updateMeshes(newConnectionsList, breakConnectionsList, attrDict, enabled)¶
When a new mesh is connected, update the mesh to match the settings of the shader displacement
- Parameters:
newConnectionsList (list(str)) – A list of Maya meshes to update, these are newly connected
breakConnectionsList (list(str)) – A list of Maya meshes to update, these are no longer part of the network
attrDict (dict()) – Dictionary with displacement attr values see keys DISP_ATTR in shdmulticonstants.py
enabled (bool) – Is the displacement enabled? Affects .aiSubdivType attribute
- setEnabled(meshList, displaceNode, enableValue=True, autoBump=False)¶
Sets the enable state of the entire displacement network
In Arnold use aiSubdivType on each mesh and disconnect the displacement from the sahder
Arnoldshaders¶
Arnold related shader functions
- loadArnold()¶
Load Arnold
- mtoaVersionNumber()¶
Returns the version number of the mtoa plugin and not Arnold!
- Return major:
the major version number 4.2.1 will be 4
- Rtype major:
int
- Return minor:
the minor version number 4.2.1 will be 2
- Rtype minor:
int
- Return patch:
the major version number 4.2.1 will be 1
- Rtype patch:
int
- createAiStandardSurface(shaderName='shader_ARN', specWeight=0.0, message=True, rgbColor=(0.5, 0.5, 0.5))¶
Creates a aiSurfaceStandard Shader In Maya
:param shaderName:The name of the aiSurfaceStandard shader in Maya to be created :type shaderName:str :param specOff: If True the specular weight is set to 0 (off) :type specOff: bool :param message:If on will return the create message to Maya :type message:bool :return:The name of the pxr shader in Maya that was created :type message:str (possibly unicode)
- createAiShadowMatte(shaderName='shadowMatte_ARN', message=True)¶
Creates a aiShadowMatte Shader In Maya Shadow mattes are for shadows only and or reflections, usually for comping
:param shaderName:The name of the aiSurfaceStandard shader in Maya to be created :type shaderName:str :param message:If on will return the create message to Maya :type message:bool :return:The name of the pxr shader in Maya that was created :type message:str (possibly unicode)
- assignNewAiStandardSurface(objList, shaderName='shader_ARN', specWeight=0.0, message=True, rgbColor=(0.5, 0.5, 0.5), selectShader=True)¶
Creates a aiStandardSurface Shader and assigns it to the objList
- Parameters:
- Return shaderName:
The name of the aiStandardSurface shader in Maya that was created
- assignNewAiShadowMatte(objList, shaderName='shadowMatte_ARN', message=True, selectShader=True)¶
Creates a aiShadowMatte Shader and assigns it to the objList Shadow mattes are for shadows only and or reflections, usually for comping
- assignSelectedNewAiStandardSurface(shaderName='shader_ARN', specWeight=0.0, message=True, rgbColor=(0.5, 0.5, 0.5))¶
Creates a aiStandardSurface Shader and assigns it to the current selection
- Parameters:
- Return shaderName:
The name of the aiStandardSurface shader in Maya that was created
- assignSelectedNewAiShadowMatte(shaderName='shadowMatte_ARN', message=True)¶
Creates a aiShadowMatte Shader and assigns it to the current selection Shadow mattes are for shadows only and or reflections, usually for comping
Buildtexturedshader¶
from zoo.libs.maya.cmds.shaders import buildtexturedshader textureDict = buildtexturedshader.testTextureDictFromPath() # test data buildtexturedshader.buildTexturedShader(textureDict, shaderType=”standardSurface”, shaderName=””)
- textureDictFromPath(path, textureList, searchSuffixList)¶
Creates a dictionary of shader paths. search suffix is the key and the path is the value.
textureList is
- Parameters:
- Return textureDict:
A dictionary with search suffixing as keys and texture paths as values, might change
- Rtype textureDict:
dict(str: str)
- testTextureDictFromPath()¶
Creates a texture dict test data for testing
- buildTexturedShader(textureDict, shaderType='standardSurface', shaderName='')¶
Creates a new shader with textures from a texture dictionary.
- Parameters:
textureDict (dict(str: str)) – A dictionary with search suffixing as keys and texture paths as values, might change
shaderType (str) – The type of shader to build, supported shader types in shdrmultconstants
shaderName (str) – The optional name of the shader, if empty will create the shader name from the textures.
- Return shdInstance:
A Zoo shader instance object
- Rtype shaderInstance:
zoo.libs.maya.cmds.shaders.shadertypes.shaderbase.ShaderBase- Return txtr_nodes_dict:
attrTypes are the keys and texture node lists are the values.
- Rtype txtr_nodes_dict:
dict(str: list(str))
Convertshaders¶
Converts shaders from one type to another.
New style shader code uses zoo’s shader instances.
from zoo.libs.maya.cmds.shaders import convertshaders convertshaders.convertShaderSelection(convertToShaderType=”standardSurface”, reassign=True, message=True)
convertshaders.swatchColorsToNewRenderSpaceScene()
- boolWeightAttr(weight, color)¶
While converting, the final shader may miss a weight attribute, so before setting force the color to have / the weight factored into it already. So force the weight to be either one or zero.
- Parameters:
- Return weight:
The resulting weight attribute in a shader pair (weight/color)
- Rtype weight:
float
- Return color:
The resulting color attribute in a shader pair (weight/color)
- Rtype color:
list(float)
- correctMissingWeight(color)¶
Shaders that are getting converted may be missing a weight attribute, so set it to be 1.0 if color or 0.0 if not
- correctShaderPairAttr(attrDict, weightKey, colorKey)¶
While converting, shaders commonly are missing a weight attribute. Eg. diffuseColor and diffuseWeight, the diffuseWeight attribute may be missing.
While converting either:
The existing shader is missing a weight attr
The destination (newly converted) shader is missing a weight attr
The function corrects both by setting the existing weight value to be either 1.0 or 0.0.
It also corrects color values if weight is set to a number in between zero and one. Eg. weight is 0.34 so adjusts the color accordingly and sets the weight to one.
- Parameters:
- Return attrDict:
The corrected shader dictionary of values generic shader keys with values as per shdm
- Rtype attrDict:
dict(str)
- correctAttrs(attrDict, fromShaderInst, newShaderInst)¶
Corrects shader pairs ready for applying the converted values. See correctShaderPairAttr() for more info.
- Parameters:
attrDict (dict(str)) – A shader dictionary of values generic shader keys with values as per shdm
fromShaderInst (shaderbase.ShaderBase) – The shader instance that is being converted
newShaderInst (shaderbase.ShaderBase) – The newly created shader instance
- Return attrDict:
The corrected shader dictionary of values generic shader keys with values as per shdm
- Rtype attrDict:
dict(str)
- selectedShaders(message=True)¶
returns selected shaders in the scene as shader instances. None if None found
- Parameters:
message (bool) – report a message to the user
- Return shaders:
A list of shader names
- Rtype shaders:
list(str)
- convertShader(shaderName, convertToShaderType='standardSurface', reassign=True, removeShaders=False, maintainConnections=True, message=True)¶
Converts a shader to a new shader type, supports attributes and not textures atm.
Supports shdm.SHADER_TYPE_LIST:
“standardSurface” “lambert”, “blinn”, “phong”, “phongE”, “aiStandardSurface”, “VRayMtl”, “RedshiftMaterial”, “PxrSurface”
- Parameters:
shaderName (str) – The name of the shader to convert
convertToShaderType (str) – The new shader type eg “aiStandardSurface” see shdm.SHADERTYPE_SUFFIX_DICT
reassign (bool) – Reassign the shader assignments to geometry after creating?
removeShaders (bool) – Delete the previous shaders after converting?
maintainConnections (bool) – Maintains any previous connections, copy pastes old textures into new shader.
message (bool) – Report a message to the user?
- Return shaderInstance:
A zoo shader instance of the newly created shader
- Rtype shaderInstance:
shaderbase.ShaderBase
- convertShaderList(shaderList, convertToShaderType='standardSurface', reassign=True, removeShaders=False, maintainConnections=True, message=True)¶
Converts a shader list to a new shader type, supports attributes and not textures atm.
Supports shdm.SHADER_TYPE_LIST:
“standardSurface” “lambert”, “blinn”, “phong”, “phongE”, “aiStandardSurface”, “VRayMtl”, “RedshiftMaterial”, “PxrSurface”
- Parameters:
convertToShaderType (str) – The new shader type eg “aiStandardSurface” see shdm.SHADERTYPE_SUFFIX_DICT
reassign (bool) – Reassign the shader assignments to geometry after creating?
removeShaders (bool) – Delete the previous shaders after converting?
maintainConnections (bool) – Maintains any previous connections, copy pastes old textures into new shader.
message (bool) – Report a message to the user?
- Return shaderInstances:
A list of zoo shader instance of the newly created shader
- Rtype shaderInstances:
list(shaderbase.ShaderBase)
- convertShaderSelection(convertToShaderType='standardSurface', reassign=True, removeShaders=False, maintainConnections=True, message=True)¶
Converts a selected shaders or objects to a new shader type, supports attributes and no textures atm.
Supports shdm.SHADER_TYPE_LIST:
“standardSurface” “lambert”, “blinn”, “phong”, “phongE”, “aiStandardSurface”, “VRayMtl”, “RedshiftMaterial”, “PxrSurface”
- Parameters:
convertToShaderType (str) – The new shader type eg “aiStandardSurface” see shdm.SHADERTYPE_SUFFIX_DICT
reassign (bool) – Reassign the shader assignments to geometry after creating?
removeShaders (bool) – Delete the previous shaders after converting?
maintainConnections (bool) – Maintains any previous connections, copy pastes old textures into new shader.
message (bool) – Report a message to the user?
- Return shaderInstances:
A list of zoo shader instance of the newly created shader
- Rtype shaderInstances:
list(shaderbase.ShaderBase)
- convertShaderScene(convertToShaderType='standardSurface', reassign=True, removeShaders=False, maintainConnections=True, assignedShadersOnly=True, message=True)¶
Converts all shaders in the scene to a new shader type, supports attributes and no textures atm.
If shaders are found who’s shader type is not supported then the shader will be ignored.
Supports shdm.SHADER_TYPE_LIST:
“standardSurface” “lambert”, “blinn”, “phong”, “phongE”, “aiStandardSurface”, “VRayMtl”, “RedshiftMaterial”, “PxrSurface”
- Parameters:
convertToShaderType (str) – The new shader type eg “aiStandardSurface” see shdm.SHADERTYPE_SUFFIX_DICT
reassign (bool) – Reassign the shader assignments to geometry after creating?
removeShaders (bool) – Delete the previous shaders after converting?
maintainConnections (bool) – Maintains any previous connections, copy pastes old textures into new shader.
assignedShadersOnly (bool) – Only converts shaders that are assigned to geo
message (bool) – Report a message to the user?
- Return shaderInstances:
A list of zoo shader instance of the newly created shader
- Rtype shaderInstances:
list(shaderbase.ShaderBase)
- convertShaderSaveScene(fileName, convertToShaderType, removeShaders=False, maintainConnections=True, message=True)¶
Saves the current file to a full path filename and converts all shaders in the scene.
Any shaders that cannot be converted are ignored.
Supports shdm.SHADER_TYPE_LIST:
“standardSurface” “lambert”, “blinn”, “phong”, “phongE”, “aiStandardSurface”, “VRayMtl”, “RedshiftMaterial”, “PxrSurface”
- Parameters:
fileName (str) – The full path filename to save
shaderType (str) – The new shader to convert to type eg “aiStandardSurface” see shdm.SHADERTYPE_SUFFIX_DICT
removeShaders (bool) – Remove the old shaders from the saved file?
maintainConnections (bool) – Maintains any previous connections, copy pastes old textures into new shader.
message (bool) – Report a message to the user
- openConvertFileSave(openPath, shaderType, oldRenderer='Maya', removeShaders=False, maintainConnections=True, useRendererSuffix=True, message=True)¶
Opens an existing file and saves out a new file with new shaders.
c:/APath/someFile_STRD.ma
c:/APath/someFile_arnold.ma
Supports shdm.SHADER_TYPE_LIST:
“standardSurface” “lambert”, “blinn”, “phong”, “phongE”, “aiStandardSurface”, “VRayMtl”, “RedshiftMaterial”, “PxrSurface”
- Parameters:
openPath (str) – The path of the file to open and convert
shaderType (str) – The new shader type to convert to eg “aiStandardSurface” see shdm.SHADERTYPE_SUFFIX_DICT
oldRenderer (str) – Usually “Maya” removed the suffix from the name while saving.
removeShaders (bool) – Remove the old shaders from the saved file?
maintainConnections (bool) – Maintains any previous connections, copy pastes old textures into new shader.
useRendererSuffix (bool) – Save the file with the renderer suffix lowercase “_arnold” or use the shader “_ARN”
message (bool) – Report a message to the user
- swatchColorsToNewRenderSpace(shaderName, originalRenderSpace='scene-linear Rec.709-sRGB', message=True)¶
Upgrades swatch colors for a single shader from the originalRenderSpace to the scene current space.
Used to upgrade scenes from old linear space in 2020 to new ACES color space.
Affects supported zoo shaders only.
Upgrades attributes
diffuse color
specular color
coat color
emission color
Default Rendering Spaces:
scene-linear Rec.709-sRGB
ACEScg
ACES2065-1
scene-linear DCI-P3 D65
Rec.2020
- swatchColorsToNewRenderSpaceScene(originalRenderSpace='scene-linear Rec.709-sRGB', message=True)¶
Upgrades swatch colors for all shaders in the scene from the originalRenderSpace to the scene current space.
Affects supported zoo shaders only.
Upgrades attributes
diffuse color
specular color
coat color
emission color
- Parameters:
message (bool) – Report messages to the user
- swatchColorsToNewRenderSpaceSel(originalRenderSpace='scene-linear Rec.709-sRGB', message=True)¶
Upgrades swatch colors for selected shaders usually from the originalRenderSpace to the scene current space.
Affects supported zoo shaders only.
Upgrades attributes
diffuse color
specular color
coat color
emission color
- Parameters:
message (bool) – Report messages to the user
Createshadernetwork¶
- createSGOnShader(shader)¶
Creates a shading group for the given shader and connects it, usually needed if one doesn’t exist
- Parameters:
shader (str) – the shader name
- Return shadingGroup:
the shading group name
- Rtype shadingGroup:
str
- createRampShaderFacingRatio(shaderName='rampSamplerInfo_shad', report=False)¶
Creates an ambient ramp shader useful for facing ratio tasks”
:param shaderName:name of the shader node :type shaderName:str :param report:display report message? :type report:bool :return rampShader:name of the ramp shader :type rampShader:str
- createAnimCurveUL2Keys(curveName='animUL_crv', value1=0, float1=0, value2=1, float2=1, report=False, weighted=1)¶
Creates an (UL unit length) anim curve useful in shader creation, also can be used in rigs and for various tasks
:param curveName:name of the curve :type curveName:str :param value1:first key value :type value1:float :param float1:first key float value (sometimes time value) :type float1:float :param value2:second key value :type value2:float :param float2:second key float value (sometimes time value) :type float2:float :param report:display report message? :type report:bool :param weighted: Is the curve weighted (0) or non weighted tangents (1) :type weighted: bool :return curveNode:name of the returned animCurve Node :type curveNode:str
- prepareColorOutput(textureNode)¶
- Returns the output attribute of the texture node, different renderers have different out attr
Should also change this to find outcolor as most Maya nodes have an outcolor not only “file”
- Parameters:
textureNode
- Returns:
- Return type:
- createMultiplyDivideColor()¶
Creates the node network rgbToHsv > multiplyDivide > hsvToRgb Useful for hue sat value adjustment when the renderer can’t handle Maya’s newer nodes.
- Return multiplyNode:
the multiply node
- Rtype multiplyNode:
str
- Return hsvToRgb:
the hsvToRgb node
- Rtype hsvToRgb:
str
- Return rgbToHsv:
the rgbToHsv node
- Rtype rgbToHsv:
str
- connectMultiplyDivideColor(textureNode)¶
Connect the node setup (rgbToHsv > multiplyDivide > hsvToRgb) to the given texture’s out also maintain the current conenctions input to (usually the shader) if already connected
- Parameters:
textureNode (str) – Then texture nodes name, can be multiple node types see prepareColorOutput()
- Return successState:
True if the operation was successful
- Rtype successState:
bool
- connectMultiplyDivideColorSelected()¶
Connect the node setup (rgbToHsv > multiplyDivide > hsvToRgb) to the given texture’s out Texture node should be selected by the user
- createLambertMaterial(shaderName='shader_VP2', specWeight=0.0, message=True, rgbColor=(0.5, 0.5, 0.5))¶
Creates a lambert Shader In Maya
:param shaderName:The name of the RedshiftMaterial shader in Maya to be created :type shaderName:str :param specOff: If True the specular weight is set to 0 (off) :type specOff: bool :param message:If on will return the create message to Maya :type message:bool :return:The name of the redshift material shader in Maya that was created :type message:str (possibly unicode)
Displacementmulti¶
- displaceMessageNodeSetup(meshList, shadingGroupList, fileNodeList, place2dTextureNodeList, displacementNode, renderer, autoBump)¶
Connects displacement nodes to a network node named “zooDisplacement_*” (NW_DISPLACE_NODE)
The network node can be handy later, for deleting or managing objects, return back to default states etc
- Parameters:
meshList (list) – list of Maya mesh names strings (nodes)
shadingGroupList (list) – list of Maya shading group names strings (nodes)
fileNodeList (list) – list of Maya node file node names strings (nodes)
renderer (bool) – The renderer name
renderer – The autobump value, we store this value for Renderman and Arnold and disable enable the network
- Return place2dTextureNodeList:
The string Maya name of the network node created
- Rtype place2dTextureNodeList:
str
- getDisplaceNetworkNode(nodeList)¶
From a node list, find the displacement network nodes and return them as a list
- getDisplaceNetworkSelected()¶
From the selected objects or sel nodes, find the displacement network nodes and return them as a list
- Return networkNodeList:
A list of Displacement Network names. Empty list if nothing found.
- Rtype networkNodeList:
list(str)
- getDisplaceNetworkNodeAll()¶
Gets all displacement nodes in the scene and returns them as a list
- Return networkNodes:
a list of displacement network nodes in the scene
- Rtype networkNodes:
list(str)
- getDisplacementNetworkItems(networkNode)¶
Given a displacement network node name return its objects and shaders
- createDisplacementRenderer(renderer, nodeList, imagePath='', displacementType='VDM', tangentType='tangent', autoBump=False, maxDivisions=5, scaleMultiplier=1, networkNodes=True, recreated=False, bounds=0.1)¶
Creates displacement on multiple renderers based on nice names. “Arnold”, “Renderman”, “Redshift” From a given node list
- Parameters:
renderer (str) – renderer nice name “Arnold”, “Renderman”, “Redshift”
nodeList (list) – list of nodes names that could be or are related to the shading group
imagePath (str) – Optional path of the image, can be left empty str “”
displacementType (str) – either “VDM” (vector displacement map) or “height” (b&w)
tangentType (str) – either “tangent” or “object”
networkNodes (bool) – create the network nodes for deletion and displacement management
recreated (bool) – Only for messages, reports “recreated” to the user instead of ‘created’
bounds (bool) – Renderman only setting that can cull objects if too low
- createDisplacementNodes(nodeList, renderer, imagePath='', displacementType='VDM', tangentType='tangent', autoBump=False, maxDivisions=5, scaleMultiplier=1, recreated=False, bounds=0.1)¶
- createDisplacementSelectedRenderer(renderer, imagePath='', displacementType='VDM', tangentType='tangent', autoBump=False, maxDivisions=5, scaleMultiplier=1, recreated=False, bounds=0.1)¶
Creates displacement on multiple renderers based on nice names. “Arnold”, “Renderman”, “Redshift” From selection
The selection can be any selection type related to a shaders, meshes, transforms, shaders or shading groups
- Parameters:
renderer (str) – renderer nice name “Arnold”, “Renderman”, “Redshift”
imagePath (str) – Optional path of the image, can be left empty str “”
displacementType (str) – either “VDM” (vector displacement map) or “height” (b&w)
tangentType (str) – either “tangent” or “object”
recreated (bool) – Only for messages, reports “recreated” to the user instead of ‘created’
bounds (float) – Can cull objects if too low, so may need to use a larger value for all renderers
- Return meshList:
list of the mesh shape names that now are affected by the displacement
- Rtype meshList:
list
- Return shadingGroupList:
list of the shading groups names that now have displacement nodes
- Rtype shadingGroupList:
list
- Return fileNodeList:
list of the fileNodes (texture) names that have been created
- Rtype fileNodeList:
list
- Return place2dTextureNodeList:
list of the place2dTextureNode names that have been created
- Rtype place2dTextureNodeList:
list
- checkValidDisplacementNetwork(shadingGroupList, fileNodeList, place2dTextureNodeList, displaceNode, renderer)¶
Checks the displacement network is valid, see getDisplacementNetworkAttrs() for documentation
This checks if the displacement has been broken, ie the user most likely manually deleted nodes.
- Return displacementValid:
True if valid, False if not valid (broken)
- Rtype displacementValid:
- forceMeshShapes(meshList)¶
Helper function that makes sure a mesh list is returned as shape nodes, ignores intermediate shape originals
- getShaderAndNetworkMeshes(networkNode, shader)¶
Returns the mesh shape list that is attached to the network node, and also returns the shapes/faces connected the shader.
This is used for comparing the current shader assignments with the displacement nodes.
- connectNewMeshesToNetwork(networkNode, shader, message=True)¶
Checks if a new object has been created and adds it to the meshList on the network node.
Compares the meshList from the network node with the meshList from the shader assignment
If a new mesh from shader assignments is not in the network meshList then connect it.
- Parameters:
- Return connectedMeshes:
a list of meshes that were connected, should be an empty list most of the time
- Rtype connectedMeshes:
list(str)
- disconnectUnusedMeshesFromNetwork(networkNode, shader, message=True)¶
Checks the shader assigned mesh shapes against the network node shapes, if mismatch will disconnect meshes
- getDisplacementNetworkAttrs(networkNode)¶
From a displacement network node return all the network node’s related UI attribute values in a dictionary
DISP_ATTR_TYPE: str “Tangent” or “Object” DISP_ATTR_DIVISIONS: int (Redshift Arnold only, Renderman returns to 4) DISP_ATTR_SCALE: Float DISP_ATTR_AUTOBUMP: Bool DISP_ATTR_IMAGEPATH: string The file path DISP_ATTR_RENDERER: float (Renderman only)
- Parameters:
networkNode (str) – A displacement network node name
- Return displacementAttrValDict:
A dictionary with the values of the UI attributes
- Rtype displacementAttrValDict:
dict()
- getDisplacementNetworkAttrsSel(renderer)¶
Type: Tangent or Object Divisions: int (Redshift Arnold) Scale: Float Auto Bump: Bool Image Path: string Bounds: float (Renderman only)
- Parameters:
renderer
- Returns:
- Return type:
- setDisplacementNetworkAttrs(displacementAttrDict, renderer, networkNode, message=True)¶
Sets displacement attributes on the Displacement Network
- Parameters:
- Return success:
True if successful, False if not
- Rtype success:
bool
- setDisplacementNetworkAttrsNodes(nodeList, displacementAttrDict, renderer, message=True)¶
Sets all attributes on the network nodes associated with nodeList names
- Parameters:
- Return success:
True if successful, False if not
- Rtype success:
bool
- setDisplacementNetworkAttrsSel(displacementAttrDict, renderer)¶
Sets displacement attributes on the Displacement Network
- updateMeshes(renderer, newConnectionsList, breakConnectionsList, attrDict, enabled)¶
When a new mesh is connected, update the mesh to match the settings of the shader displacement
- Parameters:
renderer (str) – The nice name of the renderer
newConnectionsList (list(str)) – A list of Maya meshes to update, these are newly connected
breakConnectionsList (list(str)) – A list of Maya meshes to update, these are no longer part of the network
attrDict (dict()) – Dictionary with displacement attr values see keys DISP_ATTR in shdmulticonstants.py
enabled (bool) – Is the displacement enabled? Affects .aiSubdivType attribute
- enableDisplacement(networkNode, renderer, enableValue=1)¶
Enables the displacement network so that it renders or doesn’t render.
- enableDisplacementSG(shadingGroup, renderer, enableValue=True)¶
Enables the displacement network so that it renders or doesn’t render. Takes the shading group.
- enableDisableAll(renderer, enableValue=1, message=True)¶
Enables or disables all network nodes in the scene
- getEnableDisplacement(networkNode, renderer)¶
Retrieves the enable state of the displacement network as True (enabled) or False (disabled)
Takes a network node
- getEnableDisplacementSG(shadingGroup, renderer)¶
Retrieves the enable state of the displacement network as True (enabled) or False (disabled)
Takes a shading group
- deleteDisplacementRenderer(renderer, meshList, fileNodeList, otherNodeList, displaceNode)¶
Deletes the displacement setup for a given renderer.
Note will delete texture nodes even if they are used on other attributes. Uncommon in rendering
Does not delete the displacement node
- Parameters:
renderer (str) – The renderer nice name
meshList (list(str)) – list of the mesh shape names that are affected by the displacement
fileNodeList (list(str)) – list of the fileNodes (texture) names that have been created
otherNodeList (list(str)) – list of the place2dTextureNode names that have been created
- Return success:
True if successful
- Rtype success:
bool
- deleteDisplacementNetwork(networkNode, message=True)¶
Given a displacement network node name, delete it’s displacement setup
- deleteBrokenDisplaceNetwork(networkNode)¶
- deleteDisplacementNetworkNodes(nodeList, message=True)¶
- deleteDisplacementNetworkSelected(message=True)¶
From the selected objects or sel nodes, find the displacement network and delete it.
- deleteBrokenDisplacementAll()¶
Deletes all broken networks in the scene
- selectNode(shadingGroup, nodeKey='zooDisplacementNetwork', selectNetworkNode=False)¶
Selects a node from the network using the dictionary keys:
NW_DISPLACE_NODE = “zooDisplacementNetwork” NW_DISPLACE_MESH_ATTR = “zooDisplaceMeshConnect” NW_DISPLACE_SG_ATTR = “zooDisplaceSGConnect” NW_DISPLACE_FILE_ATTR = “zooDisplaceFileConnect” NW_DISPLACE_PLACE2D_ATTR = “zooDisplacePlace2dConnect” NW_DISPLACE_NODE_ATTR = “zooDisplaceNode”
- Parameters:
- selectShader(shaderName)¶
Simple function to select the shader by its name
Randomshaders¶
Module for assigning and managing randomized shaders
Author: Andrew Silke
- split(lst, n)¶
Divide a list into a list of multiple lists
- indexInList(lst, index)¶
Simple function that returns True False if an index is in a list
- class RandomShader¶
Bases:
objectClass for assigning random colors to an object selection, maybe shells in the future
- setObjs(objList)¶
Adds the objects to the class as a zapi node list self.nodeList
- setSelectedObjs()¶
- setShaderAmount(shaderAmount)¶
- setColor(color)¶
- setValueRangeColor(color, valueRangeFloat)¶
- setSaturationRangeColor(color, saturationRangeFloat)¶
- setHueRangeColor(color, hueRangeFloat)¶
- setAffectShells(affectShells)¶
- setShaderBaseName(shaderBaseName)¶
- setShaderType(shaderType)¶
- setRenderer(renderer)¶
- setSuffix(suffix)¶
- shadersColorable()¶
- lockColor(color)¶
Records the current color as a HSV color and single values for easy access
- updateHue(hueRangeFloat)¶
Used by sliders to interactively update the hue range of the randomize colors
See self.updateSaturation() for the math.
- Parameters:
hueRangeFloat (float) – The hue range to randomize as a single float
- updateSaturation(saturationRangeFloat)¶
Used by sliders to interactively update the saturation range of the randomize colors
Math is:
colSat = 0.9 # the initial color saturation curSat = 0.95 # the current color saturation rangeSatFloat = 0.2 # the current range of saturation diff = curSat - colSat # the difference between the initial and current saturation multiply = diff / rangeSatFloat # the multiply value to use in the new calculation newValue = colSat + (rangeX * multiply) # the new result
- Parameters:
saturationRangeFloat (float) – The saturation range to randomize as a single float
- updateValue(valueRangeFloat)¶
Used by sliders to interactively update the value range of the randomize colors
See self.updateSaturation() for the math.
- Parameters:
valueRangeFloat (float) – The value range to randomize as a single float
- updateColor(color)¶
Updates the main color to randomize.
- assignShaders()¶
Assigns the shaders, assumes all preparation of the data has completed
- updateShaderAmount(shaderAmount)¶
Updates the amount of shaders used in the randomize. And deletes or creates new shaders.
- Parameters:
shaderAmount (int) – The amount of shaders to distribute for the randomize.
- updateShaderNames(shaderBaseName)¶
Renames all the shader names on existing shaders if they exist
- reseedColors()¶
Reseeds/randomizes the colors and update applies them to all objects
- reseedAssignments()¶
Reseed/Randomizes the object/shader assignments and applies them to all objects
- averageColor(colorList)¶
Finds the average color of a list, colors can be None and the list can be empty
- Parameters:
colorList – A list of colors, some entries can be None or the list can be empty.
- Return averageColor:
The average color of all the colors, can return an empty list
- Rtype averageColor:
- useShaders()¶
Uses the selected shaders and adds them to randomize
- Return shaderAmount:
The amount of shaders found
- Rtype shaderAmount:
int
- Return shaderAverageColor:
The Average color of the shaders
- Rtype shaderAverageColor:
list(float)
- randomizeShaders()¶
This button starts the randomize, will assign the shaders but is not used in updating.
- clearCache()¶
Resets the cache fresh, deletes the randomize and shader data
- exists()¶
Returns whether the current instance contains data
- Return exists:
Does the data exist?
- Rtype exists:
bool
Redshiftaovs¶
- openRenderSettingsTabAOV()¶
Opens the render settings at the AOV tab
- createAOV(type='Puzzle Matte', nodeName='')¶
Creates a redshift AOV, possible types…
“Depth”, “Puzzle Matte”, “Motion Vectors”, “ObjectID”, “Diffuse Lighting”, “Diffuse Lighting Raw”, “Diffuse Filter”, “Specular Lighting”, “Sub Surface Scatter”, “Sub Surface Scatter Raw”, “Reflections”, “Reflections Raw”, “Reflections Filter”, “Refractions”, “Refractions Raw”, “Refractions Filter”, “Emission”, “Global Illumination”, “Global Illumination Raw”, “Caustics”, “Caustics Raw”, “Ambient Occlusion”, “Shadows”, “Normals”, “Bump Normals”, “Matte”, “Volume Lighting”, “Volume Fog Tint”, “Volume Fog Emission”, “Translucency Lighting Raw”, “Translucency Filter”, “Translucency GI Raw”, “Total Diffuse Lighting Raw”, “Total Translucency Lighting Raw”, “Object-Space Positions”, “Object-Space Bump Normals”, “Background”
- createAOVPuzzleMatte(imageNumber, nodeName='rsAov_PuzzleMatte', message=True)¶
Creates a puzzleMatte AOV (rgb Matte) node only and adds it to the list in the AOV tab under Render Settings checks for unique names as not sure how return the node name in redshift .mel
- Parameters:
- Return nodeName:
the name of the node created
- Rtype nodeName:
str
- Return matteNodeNumber:
the number of the matte node starts at 0
- Rtype matteNodeNumber:
int
- checkPuzzleMatteColorExists(colorStr, imageNumber)¶
Checks to see if the puzzle mate number already exists Does this by cycling through all nodes named “rsAov_PuzzleMatte” To see if the appropriate value and number already exists
- setMatteSG(shaderGroup, matteColor, imageNumber)¶
Sets a matte in Redshift, assumes all nodes are called something like “rsAov_PuzzleMatte” so can break, this is the default in Redshift assumes names like “rsAov_PuzzleMatte”, “rsAov_PuzzleMatte001”, “rsAov_PuzzleMatte002”
Redshiftdisplacement¶
- createDisplacementNodes(nodeList, imagePath='', displacementType='VDM', tangentType='tangent', autoBump=False, maxDivisions=5, scaleMultiplier=1, bounds=1.0)¶
Creates a displacement setup for Redshift Builds the shader node networks and changes the Redshift mesh attributes too Shading Group and Mesh selection is automatic nodeList can be any selection type related to a shader. eg mesh, transform, shader or shading group
- Parameters:
nodeList (list) – list of nodes names that could be or are related to the shading group
imagePath (str) – Optional path of the image, can be left empty str “”
displacementType (str) – either “VDM” (vector displacement map) or “height” (b&w)
tangentType (str) – either “tangent” or “object”
autoBump (bool) – enable the autoBump checkbox?
maxDivisions (int) – The maximum divisions of the displacement
scaleMultiplier (float) – Multiplies the intensity of the displacement by this amount
bounds (float) – The clipping bounds, usually set low on displacement in Redshift is “Maximum Displacement”
- Return shadingGroupList:
list of the shading groups names that now have displacement nodes
- Rtype shadingGroupList:
list
- Return fileNodeList:
list of the fileNodes (texture) names that have been created
- Rtype fileNodeList:
list
- Return place2dTextureNodeList:
list of the place2dTextureNode names that have been created
- Rtype place2dTextureNodeList:
list
- createDisplacementNodesSelected(displacementType='VDM', tangentType='tangent', autoBump=False, maxDivisions=5, scaleMultiplier=1, bounds=1.0)¶
Creates a displacement setup for Redshift from a selection Will build the node networks and change the mesh attributes too the selection can be any selection type related to a shaders, meshes, transforms, shaders or shading groups
- Parameters:
- Return meshList:
list of the mesh names that now have displacement nodes
- Rtype meshList:
list
- Return shadingGroupList:
list of the shading groups names that now have displacement nodes
- Rtype shadingGroupList:
list
- Return fileNodeList:
list of the fileNodes (texture) names that have been created
- Rtype fileNodeList:
list
- Return place2dTextureNodeList:
list of the place2dTextureNode names that have been created
- Rtype place2dTextureNodeList:
list
- deleteDisplacementNodes(meshList, fileNodeList, place2dTextureNodeList)¶
Deletes a displacement setup for Redshift
Deletes the displacement nodes and resets the mesh subdivision attributes to be off
- getDisplacementAttrValues(meshList, shadingGroupList, fileNodeList, place2dTextureNodeList, displaceNode)¶
Retrieves the main attribute values of the displacement setup, usually for the UI
TODO: could export with a dictionary would be cleaner
- Parameters:
meshList (list(str)) – The list of meshes affected by the displacement, subdivision will be turned off
fileNodeList (list(str)) – list of texture file nodes, will be deleted
place2dTextureNodeList (list()) – list of 2d place texture file nodes, will be deleted
displaceNode (str) – the Arnold displacement node type “displacementShader”
- Return dtype:
displacement type “Tangent” or “Object”
- Rtype dtype:
str
- Return divisions:
The amount of displacment divisions
- Rtype divisions:
int
- Return scale:
The scale of the displacement
- Rtype scale:
float
- Return autoBump:
Is the autobump on or off?
- Rtype autoBump:
bool
- Return image:
The full image file path
- Rtype image:
str
- Return bounds:
The clipping bounds of the displacement
- Rtype bounds:
- setDisplacementAttrValues(meshList, shadingGroupList, fileNodeList, place2dTextureNodeList, displaceNode, attrDict, message=False)¶
Sets the attributes for the vector displacement setup
- Parameters:
meshList (list(str)) – The list of meshes affected by the displacement, subdivision will be turned off
fileNodeList (list(str)) – list of texture file nodes, will be deleted
place2dTextureNodeList (list()) – list of 2d place texture file nodes, will be deleted
displaceNode (str) – the Arnold displacement node type “displacementShader”
attrDict (dict) – The dictionary with values to set, see shdmulticonstants.py for a list of keys
message (bool) – report the message to the user?
- updateMeshes(newConnectionsList, breakConnectionsList, displacementAttrDict, enabled)¶
When a new mesh is connected, update the mesh to match the settings of the shader displacement
- Parameters:
newConnectionsList (list(str)) – A list of Maya meshes to update, these are new connections
breakConnectionsList (list(str)) – A list of Maya meshes to update, these are no longer part of the network
displacementAttrDict (dict()) – Dictionary with displacement attr values see keys DISP_ATTR in shdmulticonstants.py
enabled (bool) – Is the displacement enabled?
- setEnabled(meshList, enableValue=True)¶
Sets the enable state of the entire displacement network
In Redshift just use rsEnableSubdivision on each mesh
Redshiftshaders¶
Redshift related shader functions
- loadRedshift()¶
Loads the Redshift renderer
- createRedshiftMaterial(shaderName='shader_RS', specWeight=0.0, message=True, rgbColor=(0.5, 0.5, 0.5))¶
Creates a RedshiftMaterial shader.
- createRedshiftMatteShadowCatcher(shaderName='shadowMatte_RS', message=True)¶
Creates a RedshiftMatteShadowCatcher Shader In Maya.
Shadow mattes are for shadows only and or reflections, usually for compositing.
- assignNewRedshiftMaterial(objList, shaderName='shader_RS', specWeight=0.0, message=True, rgbColor=(0.5, 0.5, 0.5), selectShader=True)¶
Creates a RedshiftMaterial Shader and assigns it to the objList.
If None will just create the shader.
- Parameters:
- Returns:
The name of the RedshiftMaterial shader in Maya that was created
- Type:
- assignNewRedshiftMatteShadowCatcher(objList, shaderName='shadowMatte_RS', message=True, selectShader=True)¶
Creates a RedshiftMatteShadowCatcher Shader and assigns it to the objList.
Shadow mattes are for shadows only and or reflections, usually for compositing.
- Parameters:
- Returns:
The name of the RedshiftMatteShadowCatcher shader in Maya that was created
- Type:
- assignSelectedNewRedshiftMaterial(shaderName='shader_RS', specWeight=0.0, message=True, rgbColor=(0.5, 0.5, 0.5))¶
Creates a RedshiftMaterial Shader and assigns it to the current selection
- Parameters:
- Returns:
The name of the redshift shader in Maya that was created.
- Type:
- assignSelectedNewRedshiftMatteShadowCatcher(shaderName='shadowMatte_RS', message=True)¶
Creates a RedshiftMatteShadowCatcher Shader and assigns it to the current selection Shadow mattes are for shadows only and or reflections, usually for comping
Rendermanaovs¶
Renderman AOV matte related, Renderman has changed and supports RGB mattes differently now.
Todo
Add the following code https://renderman.pixar.com/answers/questions/14093/create-in-code-rman-attrs-and-aovs-in-v23-rfm2.html?childToView=14837#answer-14837
import rfm2
pdict = {'name': 'MatteID1', 'label': 'MatteID1',
'type': 'color', 'default': (1, 0, 0),
'connectable': False}
rfm2.ui.user_attrs.user_attrs_add('rman_userAttrs', ['nurbsSphere1'], pdict)
- createPxrMatteID(textureName='PxrMatteID', matteNumber=0, message=True)¶
Creates a PxrMatteID Texture in Maya, these are used for RGBA Mattes (AOVs)
- Parameters:
textureName – The name of the pxrMatteID node in Maya to be created
message (bool) – If on will return the create message to Maya
- Return pxrMatteID:
The name of the pxrMatteID Node in Maya that was created
- rmanCreateRenderSettingsMatteAOV(matteNumber)¶
Creates a Renderman Matte AOV in nodes, Render Settings will need to be reopened for settings to apply
If node setup already exists should bail
Annoying function possibly and easier way with rfm2 api
- Parameters:
matteNumber (int) – The number of the image to create starts at 0
- rmanAddAttrMatte(rendermanShader, matteNumber=0, matteColor=(1, 0, 0))¶
Creates an attribute for pxrMattes this defines the matte color on a shader
:param pxrSurfaceShader:The Shader name that the attr is added to :param matteNumber:The image number of the matte, starts at 0 :param matteColor:the color of the matte as a rgb tuple (1, 0, 0) is red :return:
- getColorStringFromTuple(matteColor)¶
changes a tuple (0, 1, 1) into a string “green”
- Parameters:
matteColor (tuple) – color as a tuple (0, 0, 1) is blue
- Return colorString:
color as a string
- Rtype colorString:
str
- connectPxrMatteID(rendermanShader, pxrMatteID=None, matteNumber=0, matteColor=(1, 0, 0))¶
When a Shader is selected will create and connect the PxrMatteID for RGB Mattes (AOVs) Can pass in specific node names
need to check if object matte is already connected
- connectPxrMatteIDSelected(matteNumber, matteColor, pxrMatteID=None)¶
From the selected shader/s or object transforms assign the matte color to be the given color by nodes.
Filters v21 Renderman Shaders only
Still needs to be able to reassign colors and image number if node already exists
- Parameters:
Rendermandisplacement¶
- createVectorDisplacement(shadingGroupList, imagePath='', tangentType='tangent', scaleMultiplier=1, message=True, selectFilenode=True)¶
Creates a vector displacement setup for Renderman on the given shading groups Builds the node networks required
- Return shadingGroupList:
list of the shading groups names that now have displacement nodes
- Rtype shadingGroupList:
list
- Parameters:
imagePath (str) – Optional path of the image, can be left empty str “”
tangentType (str) – either “tangent” or “object”
scaleMultiplier (float) – the scale multiplier of the displacement
message (bool) – display messages for the user success warnings etc
selectFilenode (bool) – at the end of creation select the filenode for adding the texture?
- Return pxrDisplaceList:
list of pxrDisplace nodes that were created
- Rtype pxrDisplaceList:
list
- Return PxrDisplaceTransformList:
list of PxrDisplaceTransform nodes that were created
- Rtype PxrDisplaceTransformList:
list
- Return PxrTextureList:
list of PxrTexture nodes that were created
- Rtype PxrTextureList:
list
- createDisplacement(nodeList, imagePath='', displacementType='VDM', tangentType='tangent', scaleMultiplier=1, bounds=0.1, selectFilenode=True)¶
Creates a displacement setup for Renderman Builds the shader node networks required Shading Group and Mesh selection is automatic nodeList can be any selection type related to a shader. eg mesh, transform, shader or shading group
- Parameters:
nodeList (list) – list of nodes names that could be or are related to the shading group
imagePath (str) – Optional path of the image, can be left empty str “”
displacementType (str) – either “VDM” (vector displacement map) or “height” (b&w)
tangentType (str) – either “tangent” or “object”
scaleMultiplier (float) – the scale multiplier of the displacement
bounds (float) – The scale of the displacement bounds, displacement setting that can cull objects if too low
selectFilenode (bool) – at the end of creation select the filenode for adding the texture?
- createDisplacementSelected(imagePath='', displacementType='VDM', tangentType='tangent', scaleMultiplier=1, selectFilenode=True)¶
Creates a displacement setup for Renderman from a selection Builds the shader node networks required Shading Group and Mesh selection is automatic nodeList can be any selection type related to a shader. eg mesh, transform, shader or shading group
- Parameters:
imagePath (str) – Optional path of the image, can be left empty str “”
displacementType (str) – either “VDM” (vector displacement map) or “height” (b&w)
tangentType (str) – either “tangent” or “object”
scaleMultiplier (float) – the scale multiplier of the displacement
selectFilenode (bool) – at the end of creation select the filenode for adding the texture?
- deleteDisplacementNodes(meshList, fileNodeList, otherNodeList)¶
Deletes a displacement setup for Renderman
Deletes the displacement nodes and resets the mesh subdivision attributes to be off
- getDisplacementAttrValues(meshList, shadingGroupList, fileNodeList, place2dTextureNodeList, displaceNode)¶
Retrieves the main attribute values of the displacement setup, usually for the UI
- Parameters:
meshList (list(str)) – The list of meshes affected by the displacement, subdivision will be turned off
fileNodeList (list(str)) – list of texture file nodes, will be deleted
place2dTextureNodeList (list()) – list of 2d place texture file nodes, will be deleted
displaceNode (str) – the Arnold displacement node type “displacementShader”
- Returns:
- Return type:
- setDisplacementAttrValues(meshList, shadingGroupList, fileNodeList, place2dTextureNodeList, displaceNode, attrDict, message=False)¶
- setEnabled(displaceNode, enableValue=True)¶
Sets the enable state of the entire displacement network
In Renderman use .enabled on the PxrDisplace node
Rendermanshaders¶
Renderman related shader functions
- loadRenderman()¶
Loads Renderman
- createPxrSurface(shaderName='shader_PXR', specWeight=0.0, message=True, rgbColor=(0.5, 0.5, 0.5))¶
Creates a PxrSurface Shader In Maya
:param shaderName:The name of the pxr shader in Maya to be created :type shaderName:str :param message:If on will return the create message to Maya :type message:bool :return:The name of the pxr shader in Maya that was created :type message:str (possibly unicode)
- assignNewPxrSurface(objList, shaderName='shader_PXR', specWeight=0.0, message=True, rgbColor=(0.5, 0.5, 0.5), selectShader=True)¶
Creates a PxrSurface Shader and assigns it to the objList.
- Parameters:
- Returns:
The name of the RedshiftMaterial shader in Maya that was created
- Type:
- assignSelectedNewPxrSurface(shaderName='shader_PXR', specWeight=0.0, message=True, rgbColor=(0.5, 0.5, 0.5))¶
Creates a PxrSurface Shader and assigns it to the current selection
:param shaderName:The name of the pxr shader in Maya to be created :type shaderName:str :param specWeight: The weight of the specular layer (not working) :type specWeight: float :param rgbColor: The initial color fo the shader (not working) :type rgbColor: list() :param message: Report message to the user? :type message: bool :return shaderName: The name of the shader :type shaderName: str
- createPxrLayerSurface(shaderName='shader_PXR', specWeight=0.0, rgbColor=(0.5, 0.5, 0.5), message=True)¶
Creates a PXR Layer Surface shader, a layered shader, returns all nodes.
:param shaderName:The name of the pxr shader in Maya to be created :type shaderName:str :param specWeight: The weight of the specular layer (not working) :type specWeight: float :param rgbColor: The initial color fo the shader (not working) :type rgbColor: list() :param message: Report message to the user? :type message: bool :return shader: The name of the shader :type shader: str :return layerMixer: The name the mixer node :type layerMixer: str :return layer1: The name layer 1 node :type layer1: str :return layer2: The name layer 2 node :type layer2: str
- setShadowHoldout(objList, message=True)¶
Creates a shadow holdout (shadow matte) for the selected objects. In Renderman the mesh attribute Mesh Shape > Render Stats > Hold-Out is ticked to be on. Renderman will Render the shader as per usual but it will be invisible. So the reflective properties of the object/s are set via their shaders.
- Parameters:
objList – List of object names
message (bool) – If on will return the create message to Maya
- Return objList:
- Rtype objList:
- setSelectedShadowHoldout(message=True)¶
Creates a shadow holdout (shadow matte) for the selected objects. In Renderman the mesh attribute Mesh Shape > Render Stats > Hold-Out is ticked to be on. Renderman will Render the shader as per usual but it will be invisible. So the reflective properties of the object/s are set via their shaders.
:param message:If on will return the create message to Maya :type message: bool :return selObjs: the objects set to holdout on :rtype selObjs: list
Shadermulti¶
The new shadermultirenderer, will take over from shader multi renderer
Use this module to access shaders without knowing their renderer or shader type.
Example use:
from zoo.libs.maya.cmds.shaders import shadermulti
shaderInstances = shadermulti.shaderInstancesFromSelected()
from zoo.libs.maya.cmds.shaders import shadermulti
shaderInstances = shadermulti.shaderInstanceFromShader("shaderName")
Author: Andrew Silke
- removeShaderSuffix(shaderName)¶
removes a shader suffix of a shadername. Iterates through suffixes in the dictionary shdcn.SHADERTYPE_SUFFIX_DICT Does not rename an object, just a string operation.
Supports suffixes in shdcn.SHADERTYPE_SUFFIX_DICT
- Parameters:
shaderName (str) – The name of a shader
- Return shaderNoSuffix:
The name with the suffix potentially removed
- Rtype shaderNoSuffix:
str
- emptyInstance(shaderName='')¶
Creates an empty shader instance for use when no shader is selected
- shaderInstance(shaderType, shaderName='', create=False, ingest=True, suffixName=False)¶
Creates or ingests (loads) a shader instance of a specific shader type.
Supports shdcn.SHADER_TYPE_LIST:
“standardSurface” “lambert”, “blinn”, “phong”, “phongE”, “aiStandardSurface”, “VRayMtl”, “RedshiftMaterial”, “PxrSurface”
- Parameters:
shaderType (str) – The type of shader to create eg “aiStandardSurface” see shdcn.SHADERTYPE_SUFFIX_DICT
shaderName (str) – The name of the shader to create
suffixName (bool) – Add an autosuffix for the shader name? Example shader_STRD
create (bool) – True if creating a new shader, False if using an existing shader
ingest (bool) – False if creating a new shader, True if using an existing shader
- Return shaderInstance:
A zoo shader instance of the specified shader
- Rtype shaderInstance:
shaderbase.ShaderBase
- shaderInstanceFromShader(shaderName, suffixName=False)¶
Loads a shader instance from an existing shader. Auto detects the shader type.
Supports shdcn.SHADER_TYPE_LIST:
“standardSurface” “lambert”, “blinn”, “phong”, “phongE”, “aiStandardSurface”, “VRayMtl”, “RedshiftMaterial”, “PxrSurface”
if no shader exists then returns None
- createShaderInstanceType(shaderType, shaderName='', suffixName=False)¶
Creates a new shader of shader type with a shader name and returns the shader instance.
- Parameters:
- Return shaderInstance:
A zoo shader instance of the specified shader
- Rtype shaderInstance:
shaderbase.ShaderBase
- createAssignShdInstType(shaderType, shaderName='', suffixName=False)¶
Creates and assigns a new shader to sel geo. From shader type with a shader name and returns a shader instance.
- Parameters:
- Return shaderInstance:
A zoo shader instance of the specified shader
- Rtype shaderInstance:
shaderbase.ShaderBase
- createDefaultShadRenderer(renderer, shaderName='', suffixName=False, assignGeo=True, message=False)¶
Creates a default shader of the current renderer type
- Parameters:
renderer (str) – The render nice name “Arnold” “Redshift” etc.
shaderName (str) – The name of the shader, if “” will be a default shader name
suffixName (bool) – Add an autosuffix for the shader name? Example shader_STRD
assignGeo (bool) – Will assign to currently selected geo if Ture
message (bool) – Report a message to the user?
- Return shaderInstance:
A zoo shader instance of the specified shader
- Rtype shaderInstance:
shaderbase.ShaderBase
- createDefaultShadRendererAuto(shaderName='', suffixName=False, assignGeo=True, message=False)¶
Creates a default shader and assigns to geo of the currently loaded renderer in Zoo Tools Pro
multirenderersettings.currentRenderer()
- Parameters:
- Return shaderInstance:
A zoo shader instance of the specified shader
- Rtype shaderInstance:
shaderbase.ShaderBase
- shaderInstancesFromNodes(nodes)¶
From shaders geometry or shading groups return a list of associated zoo shader instances
- shaderInstancesFromSelected(message=True)¶
From selected shaders geometry or shading groups return a list of associated zoo shader instances
- Parameters:
message (bool) – Report warnings to the user?
- Return shaderInstances:
A list of zoo shader instances
- Rtype shaderInstances:
list(
shaderbase.ShaderBase)
- getShadersSceneShaderType(shaderType)¶
- getShaderType(shader)¶
- assignValuesSelected(shaderDict, noneIsDefault=False, message=True)¶
- copyShaderSelected(message=True)¶
Copies a shaders name and zoo supported attributes to a singleton class:
shaderTrackerInst = shaderutils.ZooShaderTrackerSingleton()
Supports both selected shader and objects. Finds the first instance and uses it to extract the name and values.
- Parameters:
message (bool) – Report a message to the user?
- Return shaderData:
A shader dictionary with values and a shader name.
- Rtype shaderData:
tuple(dict, str)
- pasteShaderSelected(message=True)¶
Pastes a shader from the shader name, the shader name must exist in the scene.
Uses the shader tracker singleton class to paste from:
shaderTrackerInst = shaderutils.ZooShaderTrackerSingleton()
Existing shader assignments are replaced.
- Parameters:
message (bool) – Report a message to the user?
- Return shaderName:
The name of a shader
- Rtype shaderName:
str
- pasteShaderAttrsSelected(message=True)¶
Pastes shader data onto the currently selected shaders. Shader data is from a dictionary with zoo supported attributes. Shaders remain with tweaked values.
Uses the shader tracker singleton class to paste from:
shaderTrackerInst = shaderutils.ZooShaderTrackerSingleton()
- Parameters:
message (bool) – Report a message to the user?
- Return shaderInstances:
A list of shader instances with new values.
- Rtype shaderInstances:
list(
shaderbase.ShaderBase)
Shadermultirenderer¶
- getShadersSceneRenderer(rendererNiceName)¶
Returns all shaders in a scene of the renderer, only supported shaders as per RENDERERSHADERS
- Parameters:
rendererNiceName (str) – the nice name of the renderer
- Return shaderList:
A list of shaders of the renderer type
- Rtype shaderList:
list(str)
- getShadersSceneShaderType(shaderType)¶
- getRendererFromShaderType(shaderType)¶
given an Shader Type return the nice name of the renderer
- Parameters:
shaderType (str) – the type of the shader eg “PxrSurface”
- Return renderer:
Nice name of the supported renderer
- Rtype renderer:
str
- listCompatibleShaders()¶
returns a list of all the compatible shader types, “RedshiftMaterial”, “PxrSurface” etc
- Return compatibleShaderList:
shader node type names
- Rtype compatibleShaderList:
list
- getAllSupportedRenderers()¶
returns all supported renderers in order from the RENDERERSHADERS dict
- getAllSupportedShaders(newShaders=False)¶
returns all the supported shader types in order from the RENDERERSHADERS dict
- if oldstyle shaders use RENDERERSHADERS:
[“RedshiftMaterial”, “PxrSurface”, “PxrLayeredSurface”, “aiStandardSurface”]
- if newShaders use SHADER_TYPE_LIST:
- [STANDARD_SURFACE, LAMBERT, BLINN, PHONG, PHONGE, AI_STANDARD_SURFACE, VRAY_MTL,
REDSHIFT_MATERIAL, PXR_SURFACE]
- Parameters:
newShaders (bool) – if style is new shaders use the SHADER_TYPE_LIST with more shader types
- Return allShadersList:
A list of all the supported shader types
- Rtype allShadersList:
list(str)
- testIfSupportedShader(shader, newShaders=False)¶
Tests to see if the shader is supported
- Parameters:
shader (str) – a shader name
- Return isSupported:
The node type of the shader if it’s supported, None if not supported
- Rtype isSupported:
bool
- autoTypeShader(rendererNiceName)¶
Returns the most common uber shader from a given renderer nice name
- Parameters:
rendererNiceName (str) – the nice name of the renderer
- Return shaderType:
the type of the shader node
- Rtype shaderType:
str
- convertShaderDictToLinearColor(shaderDict)¶
Converts a shader dict (not nested) to linear color by finding attributes with suffixes “_srgb” and converting those
- Parameters:
shaderDict (dict) – a dict of shader attributes with generic shader attributes as keys, not a nested dict
shaderDict – shader attributes now with srgb colors converted to linear
- convertPresetShadersDictToLinear(presetShadersDict)¶
Converts a presetShaderDict (generic preset shader info) to be in linear color by finding attributes with suffixes “_srgb” and converting those
- Parameters:
presetShadersDict (dict) – nested dictionary of preset generic shader info (maya attr)
- Return presetShadersDict:
preset generic shader info now in linear color
- Rtype presetShadersDict:
dict
- getShaderDict(filename='shaderpresets_ior.json', convertSrgbToLinear=True)¶
Loads the .json file of the shader presets
- Parameters:
filename (str) – the name of the json file, filename only, should be in same directory as this file
- Return presetShaderDict:
The .json file as a python dict
- Rtype presetShaderDict:
dict
- getShaderPresetNamesList(presetShadersDict, firstInList='Matte Grey')¶
retrieves the Preset Shader names in alphabetical order [“Copper”, “Car Paint Blue”, “Car Paint Red”] First in list must exist in the list or it will fail
- Parameters:
- Return presetShadersList:
list of shaders in alphabetical order
- Rtype presetShadersList:
list
- redshiftMaterialAttributes()¶
attribute conversion names for RedshiftMaterial Shader
- Return shaderDict:
redshiftMaterialAttributes dictionary
- Rtype shaderDict:
dict
- aiStandardSurfaceAttributes()¶
attribute conversion names for aiStandardSurface Shader
- Return shaderDict:
aiStandardSurface dictionary
- Rtype shaderDict:
dict
- pxrSurfaceAttributes()¶
attribute conversion names for PxrSurface Shader
- Return shaderDict:
PxrSurface dictionary
- Rtype shaderDict:
dict
- pxrSurfaceFixAttrValues(shaderDict)¶
this function fixes the pxrSurface attributes while applying as it is missing the spec and coat weights, and the default mode is in artistic not physical for spec and coat Some math has to be done in srgb color, incoming is in linear and outgoing too
- Parameters:
shaderDict (dict) – a dict of shader attributes with generic shader attributes as keys, not a nested dict
shaderDict – a dict of shader attributes with generic shader attributes as keys, not a nested dict
- aiSurfaceStandardFixAttrValues(shaderDict)¶
Fixes the aiSurfaceStandard as the color is always white, no matter so should be used on the weight
Newer versions of Arnold are no better, tried using the if and else on Arnold version but it’s still wrong.
legacy code:
- mtoaMajorVersion = arnoldshaders.mtoaVersionNumber()[0]
- if mtoaMajorVersion < 4:
convert color to hsv
- Parameters:
shaderDict (dict) – a dict of shader attributes with generic shader attributes as keys, not a nested dict
shaderDict – a dict of shader attributes with generic shader attributes as keys, not a nested dict
- getShadersSelectedRenderer(renderer, reportSelError=False)¶
Returns all shaders associated with the selection and then filters them by the given Renderer
- getFirstSupportedShaderSelected(reportSelError=False, newShaders=False, message=True)¶
Find a the first supported shader from selected
- buildNameWithSuffix(shaderName, suffix, renderer)¶
Returns the shader name given the name without a suffix, the suffix bool (checkbox) and the renderer
- supportedShaderType(shader, message=True)¶
Get the supported shader type, None if it is not supported.
- renameShaderUniqueSuffix(oldName, newName, message=True)¶
renames a shader and auto adds the appropriate suffix
- getShaderAttributesDict(shaderType)¶
Returns the shader attributes of a given shader type. Shader type will be important when multi shader support.
- Parameters:
shaderType (str) – The type of shader redshiftMaterial, PxrSurface etc
- Return attrDict:
the attributes with conversions types as a dictionary
- Rtype attrDict:
dict
- getShaderPresetShaders(shaderType, convertSrgbToLinear=True)¶
Given a shader type will return the shaderDict (from .json file) now with all the attributes renamed to suit the current shader type ie. RedshiftMaterial diffuseColor attribute becomes, diffuse_color
- setPresetShaderAttrs(shaderName, presetShaderName, shaderType)¶
Will set the maya shader’s attributes to the preset type shader type must be given and attributes will be converted “shader1”, “Gold”, “PxrSurface”
- setShaderAttrs(shaderName, shaderType, shaderDict, convertSrgbToLinear=True, reportMessage=True)¶
Will set the maya shader’s attributes to the preset type, this is from a single shader input not presets
- Parameters:
shaderName (str) – The maya name of the shader, could be any user defined name
shaderType (str) – the type of shader, RedshiftMaterial pxrSurface alStandardSurface etc
shaderDict (dict) – a dict of shader attributes with generic shader attributes as keys, not a nested dict
reportMessage (bool) – report the success message or hid it?
- createShaderTypeObjList(shaderType, objList=None, shaderName='shader', specWeight=0.0, message=True, rgbColor=(0.5, 0.5, 0.5))¶
Creates a shader give the type, supports main monolithic shaders in Redshift, Arnold and Renderman Assigns to an object list if it exists
- Parameters:
shaderType (str) – the type of shader, RedshiftMaterial PxrSurface alStandardSurface etc
objList (list()) – list to assign the shader to, can be None
shaderName (str) – The maya name of the shader, could be any user defined name
specWeight (float) – the default specular weight
message (bool) – return the messages to the user
rgbColor (tuple) – the diffuse color of the shader
- Return shaderName:
the shader name created
- Rtype shaderName:
str
- createShaderTypeSelected(shaderType, shaderName='shader', specWeight=0.0, message=True, rgbColor=(0.5, 0.5, 0.5))¶
Creates a shader give the type, supports main monolithic shaders in Redshift, Arnold and Renderman
- Parameters:
shaderType (str) – the type of shader, RedshiftMaterial PxrSurface alStandardSurface etc
shaderName (str) – The maya name of the shader, could be any user defined name
specWeight (float) – the default specular weight
message (bool) – return the messages to the user
rgbColor (tuple) – the diffuse color of the shader
- Return shaderName:
the shader name created
- Rtype shaderName:
str
- createShaderType(shaderType, shaderName='shader', specWeight=0.0, message=True, rgbColor=(0.5, 0.5, 0.5))¶
Creates a shader of the given type
- Parameters:
shaderType (str) – the type of shader, RedshiftMaterial PxrSurface alStandardSurface etc
shaderName (str) – The maya name of the shader, could be any user defined name
specWeight (float) – the default specular weight
message (bool) – return the messages to the user
rgbColor (tuple) – the diffuse color of the shader
- Return shaderName:
The maya name of the shader, could be any user defined name
- Rtype shaderName:
str
- checkShaderRendererMatch(shader, renderer)¶
checks the shader type and current renderer match, returns True if match, False if not a match
Used in UIs to check is correct
- getShaderTexturedAttrs(shader, renderer)¶
Returns a list of attributes that have incoming source connections, usually textures.
Attributes are generic attributes and not the shader’s attributes
- Parameters:
shader (str) – The shader node name
- Return genericKeyList:
A list of generic attributes that have incoming source connections
- Rtype genericKeyList:
list(str)
- getTexturedInfo(shader, renderer)¶
Creates a dictionary with texture information. Used by convert renderer to rehook textures
Example
{“gDiffuseColor_srgb”: “fileTexture01.outColor”, “gSpecRoughness”: “fileTexture02.outAlpha”}
No textures will be an empty dict.
- getShaderAttributes(shader)¶
Pulls shader attributes from the given shader and enters them into a generic attributes dict
Note: Querying textured attributes returns either black or zero, may have to handle later
- Parameters:
shader (str) – The shader name
- Return attributesDict:
dictionary of generic shader attributes correctly converted
- Rtype attributesDict:
dict()
- getShaderSelected(reportNoneFoundError=False, newShaders=False, shaderName='')¶
Pulls shader attributes from the given selection and enters them into a generic attributes dict will cycle through a list returning one shader, the first legitimate type found
- getShaderList(shaderList)¶
From a shader list pull the shader attributes into a dictionary of attributes Returns a nested dict with each key the shader name
- Parameters:
shaderList (list) – a list of shader names, should be in scen no error checking
- Return shaderListAttributesDict:
a nested dictionary of the shader name, then the dict of generic attribute values
- Rtype shaderListAttributesDict:
dict
- getShaderObjectAssignDict(shader, removeSuffix=True)¶
Pulls nested dict with the shader information as a generic dict, shadername, and object/face assignements
- Parameters:
shader (str) – Maya shader name
- Return shaderObjAssignDict:
dict containing shader info such as the attributesDict, shader name and obj assignments
- Rtype shaderObjAssignDict:
- getMultiShaderObjAssignDict(shaderList, removeSuffix=True)¶
Returns a multi shader dict, keys are the shader names, contents are nested dicts with attribute, name and object/face assignment details
- Parameters:
shaderList (list) – a list of Maya shader names
- Return multiShaderGenericDict:
keys are the shader names, with attribute, name and object/face assignment details
- Rtype multiShaderGenericDict:
dict
- getMultiShaderObjAssignDictSelected(removeSuffix=True)¶
Returns a multi shader dict, from selected objects/shaders keys are the shader names, contents are nested dicts with attribute, name and object/face assignment details
- Return multiShaderGenericDict:
keys are the shader names, with attribute, name and object/face assignment details
- Rtype multiShaderGenericDict:
dict
- getMultiShaderObjAssignDictScene(removeSuffix=True, checkNonUnique=False)¶
Returns a multi shader dict, from scene, currently mesh objects only keys are the shader names, contents are nested dicts with attribute, name and object/face assignment details
- Return multiShaderGenericDict:
keys are the shader names, with attribute, name and object/face assignment details
- Rtype multiShaderGenericDict:
dict
- createApplyShaderWithDict(shaderName, genericShaderDict, rendererNiceName, addSuffix=True, overwrite=True)¶
Creates shaders if they don’t already exist If shader exists and overwrite is on delete the old shader, if overwite is off then add a suffix to the new shader so there are no conflicts
- Parameters:
shaderName (str) – The name of the shader, usually without a suffix
genericShaderDict (dict) – generic shader dictionary with attribute settings only
rendererNiceName (str) – the nice name of the renderer
addSuffix (bool) – add a suffix to the shader name or the renderer type
overwrite (bool) – delete the shader if it exists or keep it and apply the attribute settings?
- Return shaderName:
the name of the shader
- Rtype shaderName:
str
- createShaderApplyToObjFace(shaderName, genericShaderDict, objFace, rendererNiceName, addSuffix=True, overwrite=True)¶
Creates a shader and applies it to an object/face list will overwite existing shaders if overwite is on, if off will use existing shaders can add suffix of the renderer type
- Parameters:
shaderName (str) – The name of the shader, usually without a suffix
genericShaderDict (dict) – generic shader dictionary with attribute settings only
objFace (list) – a list of polygon objects and faces in Maya format that it uses to make selections
rendererNiceName (str) – renderer nice name “Arnold”, “Renderman”, “Redshift”
addSuffix (bool) – add a suffix to the shader name or the renderer type
overwrite (bool) – delete the shader if it exists or keep it and apply the attribute settings?
- createShaderApplyToObjFaceCheck(shaderName, genericShaderDict, objFace, rendererNiceName, addSuffix=True, overwrite=True)¶
Creates a shader and check if obj exists and if so applies it the object/face list will overwite existing shaders if overwite is on, if off will use existing shaders can add suffix of the renderer type
- Parameters:
shaderName (str) – The name of the shader, usually without a suffix
genericShaderDict (dict) – generic shader dictionary with attribute settings only
objFace (list) – a list of polygon objects and faces in Maya format that it uses to make selections
rendererNiceName (str) – renderer nice name “Arnold”, “Renderman”, “Redshift”
addSuffix (bool) – add a suffix to the shader name or the renderer type
overwrite (bool) – delete the shader if it exists or keep it and apply the attribute settings?
- applyMultiShaderDictObjAssign(multiShaderGenericDict, rendererNiceName, addSuffix=True, overwrite=True)¶
Apples a multiShaderGenericDict, by creating the shader if it doesn’t exist and assigning to the objects/faces will overwite existing shaders if overwite is on, if off will rename the incoming shaders to have a unique prefix can add suffix of the renderer type
- Parameters:
multiShaderGenericDict (dict) – keys are the shader names, with attribute, name and object/face assignment details
rendererNiceName (str) – renderer nice name “Arnold”, “Renderman”, “Redshift”
addSuffix (bool) – add a suffix to the shader name or the renderer type
overwrite (bool) – delete the shader if it exists or keep it and apply the attribute settings?
- Return shaderList:
list of shaders
- Rtype shaderList:
list
- deleteShader(shaderName, checkValid=True, deleteShaderNetwork=True, message=False)¶
Deletes a compatible shader from the Maya scene
- deleteShadersDict(rendererNiceName, shaderDict, deleteNetwork=True)¶
Deletes all shaders and shading groups from a shader dict, can also delete the entire network (default True)
- createMatteAOVRenderer(rendererNiceName, matteColor, imageNumber)¶
Given a renderer nice name, create an AOV rgb matte supports “Arnold”, “Renderman”, “Redshift”
- Parameters:
- Return rendererFound:
was the renderer nice name in the list
- Rtype rendererFound:
bool
Shaderpresets_ior¶
Sets the Default Presets for the shaderpresets_ior.json
Shaderutils¶
from zoo.libs.maya.cmds.shaders import shaderutils shaderutils.getAllShaders()
from zoo.libs.maya.cmds.shaders import shaderutils shaderutils.assignShader(objFaceList, shader)
- importAndAssignShader(filePath, shaderName='', mayaFileType='mayaAscii')¶
Imports a maya file and finds the first shader of the current renderer and assigns it to the current selection
- Parameters:
- Return newNodes:
A list of new nodes imported as string names
- Rtype newNodes:
list(str)
- Return firstShader:
The name of the first shader imported
- Rtype firstShader:
str
- class ImportAssignShader(filePath, shaderName='', mayaFileType='ma')¶
Bases:
object- doIt()¶
Run the import and assign shader code
- Returns:
- stripNamespace(shader)¶
- duplicateChoicePopup(newShader)¶
Choose one of the options
- Parameters:
newShader
- Returns:
- cleanNamespaces()¶
- reselectObjects()¶
Reselect original objects
- Returns:
- cleanImports()¶
Delete any of the imported data in the scene
- Returns:
- getShaderFromSG(shadingGroup)¶
Returns the main shader from a shading group, this assumes only one shader is related to the shadering group This will have to ignore extra shaders deeper in the node network if there are many nested/layered shaders
- Parameters:
shadingGroup (str) – The name of the shading group
- Return shader:
the shader name
- Rtype shader:
str
- getShadersFromSGList(shadingGroupSet)¶
Returns a list of shaders from a set of shading groups
- Parameters:
shadingGroupSet (set) – set of shading group names
- Return shaderList:
- Rtype shaderList:
- getShadingGroupFromShader(shader)¶
Returns the Shading Group from a shader
- Parameters:
shader (string) – the shader name
- Return shadingGroup:
the shading group node (can easily be None if not assigned)
- Rtype shadingGroup:
str
- getShadingGroupFromShaderList(shaderList)¶
- getShadingGroupsFromObj(mayaObj)¶
Returns all the Shading Groups related to a mesh or nurbsSurface object
- Parameters:
mayaObj (str) – A transform or shape node that is or has a “mesh” or “nurbsSurface” node
- Return shadingGroupList:
list of shading group names
- Rtype shadingGroupList:
list
- getShadingGroupsObjList(nodeList)¶
Returns all the Shading Groups related to an object list
Note
Only supports geometry, does not support selected shaders etc
see function getShadingGroupsFromNodes() for all nodes
- Parameters:
nodeList (list) – list of Maya Object names
- Return shadingGroupList:
list of shading group names
- Rtype shadingGroupList:
list
- getShadersObjList(objList)¶
Gets a list of shader names related to a object list
Note
Only supports geometry, does not support selected shaders etc
see function getShadersFromNodes() for all nodes
Used for matte assignments only
- getShadersSelected(reportMessage=True)¶
From selection return all related shaders as a list This includes shape nodes, transforms, shaders (will return themselves) and shadingGroups
- Parameters:
reportMessage (bool) – report the message back to the user?
- Return shaderList:
A list of shader names
- Rtype shaderList:
list
- getShaderWildcard(wildcardName)¶
Finds all shaders in a scene with the given suffix
- Parameters:
wildcardName (str) – The suffix name
- Return shaderList:
the shaders
- Rtype shaderList:
list
- getShadersShadeNode(shapeNode)¶
Get the related shaders connected to the given shapeNode
- Parameters:
shapeNode (str) – name of the shape node
- Return shaderList:
the shader names
- Rtype shaderList:
list
- getShadersShapeNodeList(shapeNodeList)¶
Returns the shaders attached to a list of shape nodes
- Parameters:
shapeNodeList (str) – list of shape node names
- Return shaderList:
the shader names
- Rtype shaderList:
list
- shaderAndAssignmentsFromObj(objTransform, message=True)¶
Returns a shader list and a selection list from the selected mesh object, can included face selection.
Assumes the transform only has one mesh shape node. Used in transferShaderTopology()
Example 1 return:
["redShadingGroup"] [["|pSphere3"]]
Example 2 return:
["redShadingGroup", "blueShadingGroup] [["|pSphere3.f[0:47]", "|pSphere3.f[101:222]"], ["|pSphere3.f[48:100]", "|pSphere3.f[223:228]"]]
- Parameters:
- Return shadingGroupList:
List of shading groups assigned to the object, can be multiple if face assigned
- Rtype shadingGroupList:
list(str)
- Return objectsFacesList:
List of shader assignments to this object, can be face assigned, see function description
- Rtype objectsFacesList:
list(list(str))
- transferShaderTopology(sourceObject, targetObject, ignoreTopologyMismatch=True, message=True)¶
Transfers shader/s from one object to another with matching topology, handles face assignment
Copies the shaders from the source object and copies them onto the target object
Objects must be transforms and can have “mesh” or “nurbsSurface” shapes
Todo
Nurbs does not support multiple shaders yet
- Parameters:
sourceObject (str) – The source object name to copy the shader info from, should be a long name
targetObject (str) – The target object name to copy the shader info onto, should be a long name
ignoreTopologyMismatch (bool) – Ignores the topology difference and copies the first shader found
message (bool) – Return messages to the user om2.MGlobal
- Returns:
True if the transfer succeeded via matching topology False if not
- Return type:
- transferShaderTopologySelected(message=True)¶
Transfers shader/s from one object to another with matching topology, handles face assignment
The first object in the selection’s shader/s are copied to all other selected objects
Objects must be transforms and can have “mesh” or “nurbsSurface” shapes TODO: Nurbs does not support multiple shaders yet
- Parameters:
message (bool) – Return messages to the user om2.MGlobal
- getAllShadersAndObjectFaceAssigns(filterOnlyUsed=False, filterShaderType=None)¶
Gets all shaders, shading groups and their face assignments in the scene if filterOnlyUsed then return only those with scene assignments, ie not unused shaders
- Parameters:
filterOnlyUsed (bool) – only return used shaders, shaders that contain assignments, obj or face etc
- Return shaderList:
list of shader names
- Rtype shaderList:
list
- Return shadingGroupList:
list of shading group names
- Rtype shadingGroupList:
list
- Returns:
list of face/obj assignements
- Return type:
- getAllShaders()¶
return all shaders types that could be created in a scene
- Returns:
list of shader names
- Return type:
- getObjectsFacesAssignedToSG(shadingGroup, longName=True)¶
gets objects and faces of the given shading group
- getObjectsFacesAssignedToShader(shader, longName=True)¶
gets objects and faces of the given shader
- assignShadingGroup(objFaceList, shadingGroup)¶
Assigns the shader to an object/face list
- assignShader(objFaceList, shader)¶
Assigns the shader to an object/face list
- assignShaderCheck(objFaceList, shader)¶
Assigns the shader to an object/face list, checks to see if the object exists before assigning
- assignShaderSelected(shader)¶
Assigns the given shader to current selection
- Parameters:
shader (str) – The shader name
- getShadingGroupsFromNodes(nodeList)¶
Finds shaders assigned to current node list, Includes shape nodes, transforms, shaders and shadingGroups (will return themselves)
- Parameters:
nodeList (list) – list of maya node names, can be any nodes
- Return shadingGroupList:
List of shading group names associated with the given nodes
- Rtype shadingGroupList:
list
- getShadingGroupsFromSelectedNodes()¶
finds shaders assigned to current selection of nodes This includes shape nodes, transforms, shaders and shadingGroups (will return themselves)
- Return shadingGroupList:
List of shading group names associated with the given nodes
- Rtype shadingGroupList:
list
- getShadersFromNodes(nodeList)¶
Will return a shader list from given nodes, This includes shape nodes, transforms, shaders (will return themselves) and shadingGroups
- Parameters:
nodeList (list) – list of maya node names, can be any nodes
- Return shaderList:
List of Shader Names associated with the nodeList
- Rtype shaderList:
list
- getShadersFromSelectedNodes(allDescendents=False, reportSelError=False)¶
Will return a shader list from given selection of nodes, This includes shape nodes, transforms, shaders (will return themselves) and shadingGroups Also can retrieve shaders on all descendents of the selected objects
- selectMeshFaceFromShaderName(shaderName)¶
Selects objects and faces assigned from a shader
- Parameters:
shaderName (str) – The name of a Maya shader
- selectMeshFaceFromShaderNames(shaderNames)¶
Selects objects and faces assigned to multiple shaders
- selectMeshFaceFromShaderSelection(message=True)¶
Selects objects and faces assigned to multiple shaders found in either mesh face or shader selection.
- Parameters:
message (bool) – report a message to the user?
- getMeshFaceFromShaderNodes(nodeList, selectMesh=True, objectsOnly=False)¶
Will return a mesh shape node list from given nodeList, This includes shape nodes, transforms, shaders (will return themselves) and shadingGroups
- Parameters:
- Return meshList:
List of mesh node names, can be transforms (needs fixing possibly to be only shapes)
- Rtype meshList:
list
- getMeshFaceFromShaderSelection(selectMesh=True, objectsOnly=False)¶
Will return a mesh (shape) node list from given selection of nodes, This includes shape nodes, transforms, shaders (will return themselves) and shadingGroups
- transferAssign(objFaceList)¶
from a list take the first objects shader (it can be a shader or shading group too) and assign it to the remaining list objects
- Parameters:
objFaceList (list) – list of maya objects and or face selection
- transferAssignSelection(message=True)¶
from a selection take the first object’s shader (it can be a shader or shading group itself too) and assign it to the remaining list objects, this is like copy shader from an object to objects
- Parameters:
message (bool) – report warnings to the user
- removeShaderSuffix(shaderName)¶
Removes the shader suffix from a shader name, will remove all shader suffix names for any renderer
Will remove suffix for all renderers
- Parameters:
shaderName (str) – the Maya shader name
- Return shaderName:
the Maya shader name now with suffix removed
- Rtype shaderName:
str
- removeShaderSuffixRenderer(shaderName, renderer)¶
Removes the shader suffix from a shader name, will remove all shader suffix names for any renderer
Will remove on for the given renderer.
- Parameters:
shaderName (str) – A Maya shader name
- Return shaderName:
the Maya shader name now with suffix removed
- Rtype shaderName:
str
- removeShaderSuffixList(shaderNameList, renderer)¶
- getShaderNameFromNode(node, removeSuffix=False)¶
from the given node return the shader name that’s attached to it can remove the suffix if it’s in the dict rendererManage.ALLRENDERERSUFFIX
- getShaderNameFromNodeSelected(removeSuffix=False)¶
from the first selected object return the shader name that’s attached to it can remove the suffix if it’s in the dict rendererManage.ALLRENDERERSUFFIX
- Parameters:
removeSuffix (bool) – removes the suffix name if it’s in the rendererManage.ALLRENDERERSUFFIX dict
- Return shaderName:
the shader name
- Rtype shaderName:
str
- connectSurfaceShaderToViewportShader(surfaceShader, viewportShadingGroup, renderer, connectedCount=0)¶
Connects the surface shader (usually the renderer shader) to the viewport shaders shading group Usually via the surface attribute. Useful while rendering in an engine whilst having the shaders looking nice in the viewport. This is a single shader setup
- Parameters:
surfaceShader (str) – the renderers shader to be connected to the viewport shaders shading group
viewportShadingGroup (str) – the viewport shaders shading group name
connectedCount (int) – useful for looping and messaging, usually used by another function for counting connections
renderer (str) – which renderer are you using “redshift”, “arnold”, “vray”, mentalRay”, “renderman”. Only Redshift is supported
- Return connectedCount:
Was the connection made, if so return this number as a +1
- Rtype connectedCount:
int
- saveSelectedShader(directory, saveType='auto')¶
Saves selected shader
- uniqueFileName(dirPath, name, ext='ma')¶
Generates a unique file name based on the directory path
- Parameters:
dirPath
name
ext
- Returns:
- exportShader(shader, path, type_='ma')¶
Export shader to file path
- Parameters:
shader
path
- Returns:
- assignSurfaceShaderWildcard(surfaceSuffix='RS', viewportSuffix='VP2', renderer='redshift')¶
Connects the surface shader (usually the renderer shader) to the viewport shader via the surface attribute. Useful while rendering in an engine whilst having the shaders looking nice in the viewport. works off matching suffix shader names eg skin_RS => skin_VP2’s shading group To Do 1. checks if the shader is already connected, if not disconnects the current connection and reconnects 2. disconnect
- cleanNamespaces(objs, prefix='')¶
Remove the namespace
- Parameters:
objs
prefix
- Returns:
- renameShader(shader, newName, shaderGroup=True)¶
Rename the shader and the shader group
- Parameters:
shader
newName
shaderGroup
- Returns:
- replaceShader(oldShader, newShader)¶
Replaces all objects with the old shader with the new shader
- Parameters:
oldShader
newShader
- Returns:
- shaderExists(name)¶
Returns True if shader exists
- Parameters:
name
- Returns:
- deleteShaderNetwork(shaderName)¶
deletes the shader network of a shader
- Parameters:
shaderName (str) – the name of the shader
- Return shaderNodes:
all nodes deleted
- Rtype shaderNodes:
list
- deleteShaderNetworkList(shaderList)¶
Deletes the shading network of a shading node
- Parameters:
shaderList (list) – a list of maya shader names
- Return shaderNodeDeletedList:
- Rtype shaderNodeDeletedList:
- shaderOpenAttrEditor()¶
Selects the shader of the selected object and opens the attribute editor.
- Returns:
- Return type:
- selectNodeOrShaderAttrEditor()¶
This script selects the shader or the selected nodes:
Selects the node if selected in the channel box and opens the attribute editor
Or if a transform node is selected, select the shaders of the current selection and open attr editor
- Return selectedReturn:
A list of the currently selected objects/shader nodes
- Rtype selectedReturn:
list
- renameShadingGroup(shaderName)¶
- renameShadingGroupsScene()¶
Shdmultconstants¶
Misc shader constants
from zoo.libs.maya.cmds.shaders import shdmultconstants shdmultconstants.ARNOLD
Author: Andrew Silke
Toggleshaders¶
Toggles/Swaps Shaders in a scene, usually given by two suffix’s Can mod this later for doing various things with two sets of shaders such as linking shaders to shading groups of Arnold and Redshift too. Main shader toggle is most handy in Renderman where shaders cannot be overidden for the viewport in the shading group.
- removeSuffix(name, suffix)¶
Remove suffix from a string if it exists.
- findFirstWildcardShader(suffix1, suffix2)¶
This checks the scene for polygon meshes and returns the first suffix that it finds in a shader name This may be either suffix1 or suffix2
- toggleShader(shaderFromSuffix, shaderToSuffix)¶
Toggles all shaders in a scene swapping the shaders with the given suffix’s. Swap goes from shaderFrom and applies it to shaderToSuffix so the shaderToSuffix are assigned Only works on polygons, not currently NURBS
- Parameters:
shaderFromSuffix
shaderToSuffix
- findMatchingShadersForFirstShader(shaderA, shaderB)¶
- toggleShaderAuto(shader1Suffix='VP2', shader2Suffix='PXR')¶
Toggles all shaders in a scene swapping the shaders with the given suffix’s. The swap is based off the first shader found in the scene that includes either suffix So the swap is automatic and will swap all shaders with the corresponding suffix’s Only works on polygons, not currently NURBS