shaderlib

shaderlib.apply_lkf(lookfile_path=None, shapes=False, wholeScene=False, as_aniLook=False, nreal_brain=None, use_info_file=True)

Loads a maya lookfile ‘maLkf’ (if not loaded) and apply the shaders based on the objects ‘shd’ tag

Parameters:
  • lookfile_path
  • shapes
  • wholeScene
  • as_aniLook – will load the ‘maTex’ lookfile type rather than the default ‘maLkf’
  • nreal_brain – a instance of nreal_brain API
  • use_info_file – use the shdInfo type from the snapshot to do the shader assignemnts if one is available
Returns:

shaderlib.apply_tagged(shd_library=None, shapes=None, wholeScene=False, use_lookdev_tags=False)

Load/Sync/Assign the shaders to all given ‘mat’ tagged surfaces/curves

Parameters:
  • shd_library – shader library root path (usually should be <project_root>/assets/shaders)
  • shapes – the given surfaces/curves
  • wholeScene – Applies on the whole scene rather than selectively
Returns:

list of unresolved objects

shaderlib.build_channels_network(renderer='prman', path_expr='', pTex=False, as_udim=True, linearize=False, create_manifold=False, asLKF=False, done_nodes=[])
shaderlib.commitTex(project_code, project_root, shapes=None, force=True, whole_scene=False, variant='')

Creates/Sets the tex_dir attribute on surfaces/curves to the texture directory root to be used by the shaders from the shader library later when the shaders are resolved.

Parameters:
  • shapes – optional list of objects, otherwise the whole scene will be resolved
  • force – applies the job on objects even if they already have tex_dir
  • variant – when provided, the tex_dir will be decided based on the given look variant
Returns:

shaderlib.connect(script, nodeA, a_out, nodeB, b_in)
shaderlib.create_attr_tex_node(node, attr, path_expr='', renderer='prman', shdName='shd', pTex=False, as_udim=True, linearize=False, create_manifold=False, asLKF=False, done_nodes=[])

creates a texture node for the given attribute of the given shading node, and setting the texture default value to the original attr value before the new texNode creation

shaderlib.create_texture_manifold(texNodes=[])
shaderlib.get_best_xml(shape)
shaderlib.get_mat_from_xml(shape, xml_file=None)
shaderlib.inject_render_node(script, node_name, shdType='PxrTexture', attr='', shdNodeType='PrmanShadingNode', parameters=None)
shaderlib.listNodeAttr(node)
shaderlib.load(sgName)
shaderlib.prepare_file_tex_dir(astRoot, tmpTexDir, txmake=False, brain=None)

This is similar to prepare_tex_dir() method, but this works on objects to respect any texture files attached to hair nodes, weight maps or even a light. if txmake is True, both the sourceimages and the tex texture will be copied to the sourceimages dir to be published if txmake is ‘auto’, the sourceimages will be converted to .tex and only the tex will be copied to sourceimages dir to be published.

shaderlib.prepare_file_tex_dir_deprecated(astRoot, tmpTexDir, txmake=False)

This is similar to prepare_tex_dir() method, but this works on objects to respect any texture files attached to hair nodes, weight maps or even a light. if txmake is True, both the sourceimage and the tex texture will be copied to the sourceimages dir to be published if txmake is ‘auto’, the sourceimages will be converted to .tex and only the tex will be copied to sourceimage dir to be published.

shaderlib.prepare_shapes_tex_dir(astRoot, tmpTexDir, txmake=False, brain=None)

make dir with all images attached to obejcts, if txmake is True, both the sourceimage and the tex texture will be copied to the sourceimages dir to be published if txmake is ‘auto’, the sourceimages will be converted to .tex and only the tex will be copied to sourceimage dir to be published.

shaderlib.prepare_tex_dir(astRoot, tmpTexDir, txmake=False, brain=None)

if txmake is True, both the sourceimages and the tex texture will be copied to the sourceimages dir to be published if txmake is ‘auto’, the sourceimages will be converted to .tex and only the tex will be copied to sourceimages dir to be published.

shaderlib.publish_geo_shader(geo, name=False)

Publish the one Shader assigned to the given single geometry the shader goes to $MATERIAL_LIB

shaderlib.publish_lkf(geos, lkfName)

Publish lookFile (maya file with multible shaders) for the given/selected groups/geos This is best suited for character lookfiles where one lookFile being used to resolve the whole character skin, cloth, probs ..etc The lookfile goes to $MATERIAL_LIB

shaderlib.publish_shader(SG, lkf=True, lkfName='')

Publish the selected shadingGroup(s) as shader or as lookFile

shaderlib.selected_channels()
shaderlib.set_file_path(node, attr, filepath)

Set file path attribute for the given node (setAttr on filepath has a maya bug where it doesn’t work if the basename of the file was not changed), this method uses OpenMaya instead to set the path

Parameters:
  • node – the fileTexture node name
  • attr – the filepath attribute name (filename, fileTextureName…etc)
  • filepath – the destination path
Returns:

shaderlib.set_source_files_dir(texNode, texture_expression, attr=None)

Sets the texture filepath expression for the given texture node

shaderlib.set_sourceimages_dir(destination_dir, as_tex=True)

loop over all maya texture nodes or pxr_texture nodes and set the texture basedir to the given path

shaderlib.set_sourceimages_path(texNode, texture_expression, attr=None)

Sets the texture filepath expression for the given texture node

shaderlib.set_tex_path_to_attr(geo)
Set the file nodes texture file paths to arnold attribute variables to all the files downstream the given shading group,
ie., <attr:diff>.<udim>.tx
Returns True if successfull, or a list of unresloved attributes if something went wrnong or not supported.
shaderlib.sgNode(script, material, nodes_names=None, nodes_types=None)
shaderlib.shader_to_katana(sg_name, katPy_script)

Writes out the given maya shading node input graph to katana python script that you can execute in katana to reproduce the same shading network there

Parameters:
  • sg_name – any maya shading node, usually the ShadingGroup of shader network
  • katPy_script – the katPy script path to be generated.
Returns:

katPy script path or None

shaderlib.texVerDown()
shaderlib.texVerUp()