Renderer¶
Arnold Render Settings¶
- setGlobalsArnold()¶
Sets the current renderer in the render globals to renderman and builds the core options
- loadRendererArnold(setZooDefaults=True)¶
Loads the Arnold renderer and sets the render settings to Arnold too
- setArnoldSamples(cameraAA=3, diffuse=2, specular=2, transmission=2, sss=2, volumeIndirect=2, progressive=0, adaptiveSampling=0, maxCamAA=20, adaptiveThreshold=0.015)¶
Sets Arnold’s Sample and Adaptive Sample settings in the Render Settings window.
Globals must be set with setGlobalsArnold()
- Parameters:
cameraAA (int) – Camera AA samples
diffuse (int) – Diffuse samples
specular (int) – Specular samples
transmission (int) – Transmission samples
sss (int) – Sub Surface Scattering samples
volumeIndirect (int) – Volume Indirect samples
progressive (int) – The Progressive Render check box either 0 or 1
adaptiveSampling (int) – The Adaptive Sampling check box, either 0 or 1
maxCamAA (int) – The Max. Camera (AA) setting if Adaptive Sampling is on
adaptiveThreshold (float) – Adaptive Threshold setting if Adaptive Sampling is on
Export Alembic Shader Lights¶
Todo
Exporting lights should use long names?
from zoo.libs.maya.cmds.renderer import exportabcshaderlights exportabcshaderlights.scaleToSceneConversion(1.0, fromUnit=”cm”)
- tagTransformsZooABCAttr(nodeType, attrName)¶
Tags transform nodes of shape nodes of the given type Will tag by creating a float attribute named attrName message nodes cannot be exported by alembic
- tagZooABCAttributes(meshes=False, lights=True, cameras=False, locators=False, curves=False)¶
Tags all nodes (transforms) in the scene with a message attribute with the prefix “zooABC” eg. zooABC_light The attribute tags can be exported with alembic These tags enable us to control what’s in the scene on ABC import by deleting or managing unwanted types This is really only handy for lights which often need to be deleted but can’t be found via querying the object type as they are usually empty transform nodes
- Parameters:
meshes (bool) – tag mesh transform node types with an attribute identifier
lights (bool) – tag lights transform node types with an attribute identifier
cameras (bool) – tag camera transform node types with an attribute identifier
locators (bool) – tag locators transform node types with an attribute identifier
curves (bool) – tag curves transform node types with an attribute identifier
- deleteZooABCAttrObjs(rendererNiceName='', meshes=False, lights=True, cameras=False, locators=False, curves=False, message=False, lightGrps=True, checkNodes='', skipLightGrps=False)¶
Deletes objects with attribute tags by type, usually used for lights from ABC as they aren’t imported as light types and so can’t be tracked or deleted.
- Parameters:
rendererNiceName (bool) – the renderer name “Arnold” “Redshift” etc, needs to be specified for deleting light groups
meshes (bool) – delete objects with mesh tags
lights (bool) – delete objects with light tags
cameras (bool) – delete objects with camera tags
locators (bool) – delete objects with locator tags
curves (bool) – delete objects with curves tags
message (bool) – report the message to message user
checkNodes (list) – only check these nodes, otherwise the whole scene
skipLightGrps (bool) – skips the deletion of the light grp of the current renderer
- Return deletedNodes:
all the deleted nodes
- Rtype deletedNodes:
list
- getShaderLightDict(rendererNiceName, getShader=True, getLight=True, exportSelected=False, includeSelChildren=False)¶
get the information from the scene to build the shader/light dictionaries given the options passed in
- Parameters:
- Return zooSceneDict:
the lightShader dictionary with version number
- Rtype zooSceneDict:
dict
- removeNamespaceZooScene(zooSceneDict, shaderMultiDict, lightMultiDict)¶
Depreciated function, might not be needed anymore since Alembic supports namespaces removes all namespaces from the zooSceneDict, might be handy for strip namespaces to match that flag for alembic
Could be done better as a flag while collecting the dict info, maybe will do later Ugly dict and string handling :/
- Deletes namespaces in the
zooSceneDict[MESHOBJECTS] = the keys (long names) zooSceneDict[LIGHTS][AREALIGHTS] = the area light keys (short names) zooSceneDict[LIGHTS][IBLSKYDOMES] = the ibl keys (short names) zooSceneDict[SHADERDICT][OBJECTFACES] = then go through each list (short names)
- Parameters:
zooSceneDict (dict) – the lighting/shader/subd dict the .zooscene
- Return zooSceneDict:
the lighting/shader/subd dict the .zooscene, now with namespaces removed
- Rtype zooSceneDict:
dict
- createShaderLightDict(rendererNiceName, shadMultDict, lightMultDict, setShaders=True, setLights=True, addSuffix=True, replaceShaders=True, replaceLights=True, includeLights=True)¶
Given the renderer and zooSceneDict, build the lights and shaders in the scene,
- Parameters:
rendererNiceName (str) – name of the renderer nicename “Arnold”
zooSceneDict (dict) – the lightShader dictionary with light and shader info
setShaders (bool) – apply/import the shaders?
setLights (bool) – import the lights?
addSuffix (bool) – add suffixes to the shaders and lights?
replaceShaders (bool) – replace the existing shaders? if off will add shaders but with new names 001 002 etc
includeLights (bool) – if False then skip the importing of lights, override
- Return allNodes:
all shader and light nodes created
- Rtype allNodes:
list
- getTexturedAttributes(shaderList, renderer)¶
Builds the nested dictionary from shader connections so it can be rebuilt later with transferRenderer():
- {“shaderName”: {“gDiffuseColor_srgb”: “fileTexture01.outColor”,
“gSpecRoughness”: “fileTexture02.outAlpha”}}
If no textures the dicts will be empty.
{“shaderName”: {}}
See reconnectTextures() for rebuilding the connections after Renderer convert
- reconnectTextures(texturedShaderDict, fromRenderer, toRenderer, addSuffix)¶
Reconnects textures while converting transferRenderer(). Uses a nested dict texturedShaderDict:
- {“oldShaderName”: {“gDiffuseColor_srgb”: “fileTexture01.outColor”,
“gSpecRoughness”: “fileTexture02.outAlpha”}}
- Parameters:
- transferRenderer(fromRenderer, toRenderer, transferShader=True, transferLights=True, transferSelected=False, addSuffix=True, replaceShaders=True, deleteOld=False)¶
Transfers a scene (transferSelected=False) or selection to a new renderer using the generic shader dicts Many options Currently will always delete lights while rebuilding
- Texture Note:
Textures that are connected to supported generic attributes ie. shadermultirenderer.GEN_KEY_LIST will be reconnected. However they will not be converted, so it’ll only work with native Maya nodes such as ramps and native file textures and or math nodes etc that are supported by the both renderers.
TODO: Add support attributes such as metalness, normals, bump, displacement etc.
- Parameters:
fromRenderer (str) – The renderer converting from “Arnold”
toRenderer (str) – The renderer converting to “Redshift”
transferShader (bool) – transfer the shaders?
transferLights (bool) – transfer the lights?
transferSelected (bool) – transfer only selected objects? If false will export scene, shaders are assigned to objs
addSuffix (bool) – add a suffix to the shader names while creating
replaceShaders (bool) – replace shaders with the same names
deleteOld (bool) – delete the old lights and shaders (if they are being transferred) Shaders use suffix’s
- Return wasConverted:
if converted True if not False
- Rtype wasConverted:
bool
- exportAbcWithDictInfo(filePathAlembic, zooSceneDict=None, exportSelected=False, noMayaDefaultCams=True, exportGeo=False, exportCams=False, exportAll=True, dataFormat='ogawa', frameRange='', visibility=True, creases=True, uvSets=True, exportSubD=True)¶
- Exports the .abc data with a generic zooSceneDict .zooScene file
has a number of filter options, including exporting hierarchies containing geo or cams. Can exclude Maya default cams, persp front bottom back Can export SubD attribute info to the .zooScene file Other regular .abc export flags too.
- Parameters:
filePathAlembic (str) – the full filepath to the .abc file to save
zooSceneDict (dict) – the exported dict usually for .zooScene writing, if None it will be created
exportSelected (bool) – export selected, will override other filters like noMayaDefaultCams
noMayaDefaultCams (bool) – omit the Maya default cams, ‘front’ ‘left’ ‘bottom’ ‘back’ ‘persp’ etc
exportGeo (bool) – export the geometry? Note, child nodes of all objects root parent will still be included
exportCams (bool) – export the cameras? Note, child nodes of all cameras root parent will still be included
exportAll (bool) – will export everything, maya default cams are still potentially filtered
visibility (bool) – will export visibility state of every object
creases (bool) – will export creases on objects, currently broken
uvSets (bool) – will export poly objects with uv sets
dataFormat (str) – abc format type, “ogawa” is small and fast, “hdf” supports backwards compatibility
frameRange (str) – frame to and from as a string eg “0 10”. If left empty will default to current frame.
exportSubD (bool) – export the subD settings into the .zooScene file
- Return zooSceneDict:
the exported dict usually for .zooScene writing extra data uch as subD and objExist info
- Rtype zooSceneDict:
dict
- exportAbcGenericShaderLights(zooSceneFullPath, rendererNiceName='Arnold', exportSelected=False, exportShaders=True, exportLights=True, exportAbc=True, noMayaDefaultCams=True, exportGeo=False, exportCams=False, exportAll=True, dataFormat='ogawa', frameRange='', visibility=True, creases=True, uvSets=True, exportSubD=True, exportNamespaces=True, tagInfoDict={}, includeSelChildren=False, keepThumbnailOverride=False)¶
Saves files
.zooScene file with misc info
The shader file with generic shader info
The lights file with generic light info
An alembic file with the same name in the same location
The zooInfo file with information meta data about the file
While saving lights or shaders only it’s worth saving this same filetype, and the remaining category will be an empty dict.
The related importer will only import the dictionaries it finds with legit data. Please note that the ‘exportGeo’ and ‘exportCams’ will save the root node of each of those object types, the alembic will export all viable nodes parented into that hierarchy.
- Parameters:
zooSceneFullPath (str) – the full filepath to the json file to save
rendererNiceName (str) – which rendererNice name should the lights be saved from? Saving shaders only = not needed
exportSelected (bool) – export selected, will override other filters like noMayaDefaultCams
exportShaders (bool) – export all meshes (poly only) in the scene and all related shaders
exportLights (bool) – will export supported light types, the lights in generic (not alembic) format as .zooScene
exportAbc (bool) – will export an alembic files with the same name as the .zooScene
noMayaDefaultCams (bool) – omit the Maya default cams, ‘front’ ‘left’ ‘bottom’ ‘back’ ‘persp’ etc
exportGeo (bool) – export the geometry? Note, child nodes of all objects root parent will still be included
exportCams (bool) – export the cameras? Note, child nodes of all cameras root parent will still be included
exportAll (bool) – will export everything, maya default cams are still potentially filtered
visibility (bool) – will export visibility state of every object
creases (bool) – will export creases on objects, currently broken
uvSets (bool) – will export poly objects with uv sets
dataFormat (str) – abc format type, “ogawa” is small and fast, “hdf” supports backwards compatibility
frameRange (str) – frame to and from as a string eg “0 10”. If left empty will default to current frame.
exportSubD (bool) – export the subD settings into the .zooScene file
exportNamespaces (bool) – exports namespaces to the .zooscene folder, bug in .abc means it must created before import
exportNamespaces – exports namespaces to the .zooscene folder, bug in .abc means it must created before import
keepThumbnailOverride (bool) – keeps the existing thumbnail image if over righting, usually for delete when renaming
- Return tagInfoDict:
tag info dictionary that is saved as a .zooInfo, if empty and will be created as empty
- Rtype tagInfoDict:
dict
- Return includeSelChildren:
include whole hierarchy of selected, will override to auto on if alembic and exportsel
- Rtype includeSelChildren:
dict
- Return zooSceneFullPath:
file path of the alembic file saved
- Rtype filePathAlembic:
str
- selectedZooSceneObjDictFix(zooSceneDict, gShaderDict, objectRootList)¶
This function adjusts for exporting selected nodes on the long file names fixing the paths alembic exports from the root and leaves out other dag objects higher in the hierarchy so on importing those parent objects are missing. this function checks and fixes the long name pathing
- Parameters:
- Return objectLongList:
the object long list now fixed with the parent of the alembic roots cut out of the prefix
- Rtype objectLongList:
list
- Return zooSceneDict:
the now updated zooSceneDict
- Rtype zooSceneDict:
dict
- importAbcDict(filePathAlembic, zooSceneDict, shadMultDict, lightMultDict, rendererNiceName, replaceRoots=False, importSubDInfo=True, returnNodes=True, createNamespaces=True, deleteAbcLightNulls=True, importLights=True, replaceLights=True)¶
Imports an alembic file and uses zooSceneDict to potentially replace existing roots
- Parameters:
filePathAlembic (str) – the full filepath to the .abc file to save
zooSceneDict (dict) – the nested exported dict which contains subD information
replaceRoots (bool) – Will delete an existing hierarchy root to make way for the imported hierarchy
createNamespaces (bool) – needs to create empty namespaces in the scene for namespaces to be imported correctly
deleteAbcLightNulls (bool) – deletes nulls that were once lights, and so avoids clashes with maya/generic lights
importLights (bool) – this is for the generic light importer, if off don’t delete the existing scene lights
replaceLights (bool) – if True then we need to delete the renderer lights grp here for returning all abc nodes
- Return filePathAlembic:
the full filepath to the .abc file to save
- Rtype filePathAlembic:
str
- importAbcGenericShaderLights(zooSceneFullPath, rendererNiceName='Arnold', importShaders=True, importLights=True, importAbc=True, replaceShaders=True, addShaderSuffix=True, importSubDInfo=True, replaceRoots=False, returnNodes=True, replaceLights=True)¶
Imports the generic .zooScene file (shaders, shader assignment and lighting) with alembic data supported and various flags for importing.
- Parameters:
zooSceneFullPath (str) – the full path of the .zooScene file to be saved
rendererNiceName (str) – The renderer nice name used to import generic shaders eg. “Redshift” “Arnold”
importShaders (bool) – will import shaders in generic format
importLights (bool) – will import lights in generic format
importAbc (bool) – imports the accompanying .abc alembic file
replaceShaders (bool) – will delete existing shaders before importing those of the same name
addShaderSuffix (bool) – Adds renderer suffixes to shader imports eg _RS, _ARN, _PXR
importSubDInfo (bool) – Imports the subD info, includes maya subd info data like renderer level etc.
replaceRoots (bool) – Will delete an existing hierarchy root to make way for the imported hierarchy
newNodes (bool) – returns the new nodes created if returnNodes=True, otherwise returns None
replaceLights (bool) – if lights are imported will delete lights with the incoming/clashing names
- Return newNodes:
returns the new nodes created if returnNodes=True, otherwise returns None
- Rtype newNodes:
list
- saveLightsZooScene(zooSceneFullPath, renderer, exportAll=True)¶
Simple function that exports lights with hardcoded export options
- importLightPreset(zooSceneFullPath, rendererNiceName, overideDeleteLights)¶
Imports the lights only from a .zooScene and the dependency file .zooGShad
- Parameters:
- Return allLightShapes:
all light shapes and I think transforms created
- RtypeallLightShapes:
list
- updateIBLPaths(zooSceneDir, oldIblPath='D:/3dtrainingResources/HDRImages/_neatHDRIcollection', newIblPath='')¶
temp functexportglobalsion to fix bad ibl paths for .zooScene directories. Useful for upgrading or batch fixing
Note: is likely depreciated, nothing is using this function
- Parameters:
- Return lightFilesRenamedList:
a list of fileNames full path that have been renamed
- Rtype lightFilesRenamedList:
list
- setShaderAttrsZscnInstance(shaderInstance, zooScenePath, convertToRendering=True)¶
Sets a shader instance to the values of the first shader in a zooscene dict file.
- Parameters:
shaderInstance (zoo.libs.maya.cmds.shaders.shadertypes.shaderbase.ShaderBase()) – A zoo shader instance
zooScenePath (str) – The full path of the zooScene file on disk
convertToRendering (bool) – If True the incoming dict is in display space (SRGB) and will apply as rendering space
- setShaderAttrsZooScene(zooScenePath, shaderName, shaderType, renameToZooName=False, message=True)¶
Sets a shader’s attributes from a .zooScene file
Will find the first shader in the file, and then it’s attributes
Can rename the shader to the .zooScene name, useful for creating from a preset or thumb browser
- 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
renameToZooName (str) – Rename the existing shader to the shader name in the .zooScene
message (bool) – report the success message to the user?
- Return shaderName:
The name of the shader set
- Rtype shaderName:
str
- saveShaderPresetZooScene(zooSceneFullPath, shaderInScene, shaderName)¶
Saves a Shader Preset as a .zooScene file with the generic shader JSON file (.zooGShad). No other data is saved.
- Parameters:
- Return zooSceneFullPath:
The full path of the .zooScene file saved
- Rtype zooSceneFullPath:
str
- Return gShaderFullPath:
The full path of the shader JSON file saved (.zooGShad)
- Rtype gShaderFullPath:
str
- saveShaderInstanceZooScene(zooSceneFullPath, shaderName, shaderInstance)¶
Saves a Shader Preset as a .zooScene file with the generic shader JSON file (.zooGShad). No other data is saved.
Uses Zoo shaderInstance as the input, it must already exist in the scene.
- Parameters:
zooSceneFullPath (str) – The full file path including the filename
shaderName (str) – The name of the shader as saved. Can be different from the shaderInstance.shaderName()
shaderInstance (
zoo.libs.maya.cmds.shaders.shadertypes.shaderbase.ShaderBase
) – The shader name that will be read from the scene, it’s data will be saved
- Return zooSceneFullPath:
The full path of the .zooScene file saved
- Rtype zooSceneFullPath:
str
- Return gShaderFullPath:
The full path of the shader JSON file saved (.zooGShad)
- Rtype gShaderFullPath:
str
Multi Renderer Settings¶
- currentRenderer()¶
Returns the current renderer that is set in Zoo Tools.
returns
“Arnold” or Redshift” or “Renderman”
- Return renderer:
Returns the nice name of the currently active renderer in Zoo Tools
- Rtype renderer:
str
- changeRenderer(renderer, setDefault=True, load=True, message=True)¶
Change renderer for the whole of Zoo Tools Pro:
“Arnold” or Redshift” or “Renderman”
- Parameters:
- Return generalSettingsPrefsData:
The prefs data as a dict, now updated
- Rtype generalSettingsPrefsData:
dict
- setDefaultRenderSettings(renderer, message=True)¶
Sets the default Zoo render settings for each renderer
- setRenderGlobals(renderer)¶
- Parameters:
renderer (str) – The renderer nice name
- Returns:
- Return type:
- loadRenderer(renderer, bypassWindow=False)¶
Loads the given renderer with a confirmation popup window.
- setDefaultRenderSettingsAuto()¶
Sets the default render settings on the currently selected renderer
- openRenderview(renderer, final=False, ipr=False)¶
Opens a render view window and optionally starts rendering a final fame or IPR for the given renderer.
Redshift Render Settings¶
- setGlobalsRedshift()¶
Sets the current renderer in the render globals to Redshift and builds the core options
- loadRendererRedshift(setZooDefaults=True)¶
Loads the Redshift renderer and sets the render settings to Redshift too
- setBounces(bounces=3, primaryEngine=4, secondaryEngine=4, message=True)¶
Sets the GI bounces in Redshift
Primary Engine:
0: None 1: Photon Map 3: Irradiance Cache 4: Brute Force
Secondary Engine:
0: None 1: Photon Map 2: Irradiance Point Cloud 4: Brute Force
- Parameters:
- Return success:
True if successfully completed, can fail easily if Renderman Globals are not in the scene
- Rtype success:
bool
- setIPRMaxPasses(passes=256, forceProgressive=1, message=True)¶
Sets the IPR passes in Redshift
- Parameters:
- Return success:
True if successfully completed, can fail easily if Renderman Globals are not in the scene
- Rtype success:
bool
- setMinMaxSamples(maxSamples=256, minSamples=64, adaptiveThreshold=0.01, message=True)¶
Sets the minimum and maximum samples for Redshift
- Parameters:
- Return success:
True if successfully completed, can fail easily if Renderman Globals are not in the scene
- Rtype success:
bool
Rendererconstants¶
Rendererload¶
from zoo.libs.maya.cmds.renderer import rendererload
- currentZooRenderer()¶
Returns primary renderer that Zoo Tools has set in its preferences. Note the renderer may not be loaded in Maya.
“Arnold”, “Redshift”, “Renderman”, “VRay”, “Maya”
- Returns:
The currently set renderer as a string
- Return type:
- getRendererIsLoaded(rendererNiceName)¶
checks if the renderer by nice name is loaded “Arnold”, “Renderman”, “Redshift”
- Parameters:
rendererNiceName (str) – the nice name of the renderer “Redshift”, “Arnold”
- Return loaded:
is the renderer loaded?
- Rtype loaded:
bool
- loadRenderer(renderer, setZooDefaults=True)¶
Load renderer by it’s nice name, “Arnold”, “Renderman”, “Redshift”
“Maya” will be ignored as plugin is not needed.
- Parameters:
renderer (str) – renderer nice name “Arnold”, “Renderman”, “Redshift”
- Return loaded:
did the renderer get loaded?
- Rtype loaded:
bool
- getLoadedRenderers()¶
Returns a nice name renderer list of the renderers currently loaded
- Parameters:
rendererNiceNameList (str) – the nice name of the renderer “Redshift”, “Arnold”
- unloadRenderer(rendererNiceName, message=True)¶
Unload renderer by it’s nice name, “Arnold”, “Renderman”, “Redshift”
- Parameters:
rendererNiceName (str) – renderer nice name “Arnold”, “Renderman”, “Redshift”
- unloadRendererSafe(rendererNiceName)¶
Safe unloads a renderer by checking if it’s ok to unload, renderer is by nicename “Arnold”, “Renderman”, “Redshift”
- Parameters:
rendererNiceName (str) – renderer nice name “Arnold”, “Renderman”, “Redshift”
- Return unloaded:
did the renderer get unloaded?
- Rtype unloaded:
bool
- printLoadedRenderPlugins()¶
Prints the renderer if it’s loaded, will use the renderer nice name.
- safeUnloadAllRenderers()¶
Turns off all the render plugins, best if this happens in an empty scene, can crash Maya
Renderer Stats¶
———- Render Stats ————- Enables the user to easily toggle the following modes for render visibility
Example:
from zoo.libs.maya.cmds.renderer import renderstats renderstats.renderStatsSel(vis=False, attr=RS_PRIMARY_VIS)
TODO: Add renderer specific attributes
Author: Andrew Silke
- renderStats(shapeList, vis=False, attr='primaryVisibility', message=True)¶
Sets an attribute to be true or false, used for setting Render Stats though could be used for anything
see globals for attrs to set
Renderman Render Settings¶
- setGlobalsRenderman()¶
Sets the current renderer in the render globals to renderman
- loadRendererRenderman(setZooDefaults=True)¶
Loads the Renderman renderer and sets the render settings to Renderman too
- setMinMaxSamples(maxSamples=256, minSamples=0, pixelVariance=0.015, iprMax=256, iprPixelVariance=0.015, message=-1)¶
Sets the Renderman max and min samples for regular and IPR rendering
- Parameters:
maxSamples (int) – The maximum samples for full quality Renderman renders
minSamples (int) – The minimum samples for full quality Renderman renders
pixelVariance (float) – The pixel variance for full quality Renderman renders
iprMax (int) – The maximum samples for IPR (interactive) Renderman renders
iprPixelVariance (float) – The pixel variance for IPR Renderman renders
message (float) – Report a message to the user?
- Return success:
True if successfully completed, can fail easily if Renderman Globals are not in the scene
- Rtype success:
bool