本文整理汇总了Python中maya.cmds.hyperShade函数的典型用法代码示例。如果您正苦于以下问题:Python hyperShade函数的具体用法?Python hyperShade怎么用?Python hyperShade使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hyperShade函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: convert_area_light
def convert_area_light(area_light, attributes):
# create and initialise material for object
light_material = cmds.createNode("ms_appleseed_material", n=area_light + "_material")
cmds.setAttr(light_material + ".enable_back_material", 0)
cmds.setAttr(light_material + ".duplicate_front_attributes_on_back", 0)
# create and initialise surface shader
light_surface_shader = ms_commands.create_shading_node("constant_surface_shader", area_light + "_surface_shader")
cmds.setAttr(light_surface_shader + ".alpha_multiplier", 0, 0, 0, type="double3")
# create and initialise edf
light_edf = ms_commands.create_shading_node("diffuse_edf", area_light + "_edf")
cmds.setAttr(
light_edf + ".exitance", attributes["color"][0], attributes["color"][1], attributes["color"][2], type="double3"
)
cmds.setAttr(
light_edf + ".exitance_multiplier",
attributes["multiplier"],
attributes["multiplier"],
attributes["multiplier"],
type="double3",
)
# assign material and connect up nodes
cmds.select(area_light)
cmds.hyperShade(assign=light_material)
cmds.connectAttr(light_edf + ".outColor", light_material + ".EDF_front_color", f=True)
cmds.connectAttr(light_surface_shader + ".outColor", light_material + ".surface_shader_front_color", f=True)
示例2: __init__
def __init__(self, name, index):
#these will need to be actual data, and update as you move the object in the world
self.m_name = name
self.m_index = index
#self.m_scale = (1, 1, 0) #we shouldn't really work with scale
#self.m_position = (0, 0, 0)
#self.m_width = 100#we could instead use scale and just let them scale instead of drag vertex
#self.m_height = 100#then we could just calcualte width and height from base w/h and multiple by scale
#probably the better idea then to let them move around the vertecies
tempCube = cmds.polyCube(n = name, w = 100, h = 100, d = 0)[0]
cmds.rotate(0, 90, 0, r=True, os=True)
self.m_cube = tempCube
self.m_layout = []
self.m_effectNumber = -1
if 'Attack' in self.m_name:
self.b_isAttack = True
self.m_effectNumber = 0
else:
self.b_isAttack = False
#self.addUI()
#red or blue based off of type of box
lambert = cmds.shadingNode('lambert', asShader=True)
cmds.select(self.m_cube)
if "Attack" in self.m_name:
cmds.setAttr ( (lambert + '.color'), 1.0, 0.0, 0.0, type = 'double3' )
else :
cmds.setAttr ( (lambert + '.color'), 0.0, 0.0, 1.0, type = 'double3' )
cmds.setAttr ( (lambert + '.transparency'), 0.90,0.90,0.90, type= 'double3' )
cmds.hyperShade( assign=lambert )
示例3: consolidateShaders
def consolidateShaders(mainMat_sel):
mainMatSG = None
matList = cmds.ls(materials=True, r=True)
mainMatSplit = mainMat_sel.split(":")
mainMat = mainMatSplit[-1]
try:
tmpList = cmds.listConnections(mainMat_sel)
mainSplit = mainMat_sel.split(":")
matVal = mainSplit[-1]
for t in tmpList:
if re.search("SG",t):
mainMatSG = t
break
matList.sort()
if mainMatSG != None:
for m in matList:
if m.split(":")[-1] == matVal:
cmds.select(m)
cmds.hyperShade(objects="")
cmds.sets( e=True, forceElement= mainMatSG )
if m != mainMat_sel:
cmds.delete(m)
except:
pass
示例4: getObjMaterials
def getObjMaterials():
global remapAndLuminaceNodes
shadingType = ["blinn", "phong", "RedshiftArchitectural", "aiStandard"]
displacementShading = ["RedshiftDisplacement", "displacementShader"]
duplicateMaterials = list()
selObjsList = cmds.ls(sl=1, tr=1)
if not selObjsList:
assert "No object is selected!"
for obj in selObjsList:
duplicateNodes = list()
cmds.select(obj, r=1)
cmds.hyperShade(smn=1)
selObjsDuplicateMaterials = cmds.duplicate(un=1)
for item in selObjsDuplicateMaterials:
dupliMater = cmds.rename(item, "%s_duplicate" % (item))
duplicateNodes.append(dupliMater)
for item in duplicateNodes:
if cmds.nodeType(item) in shadingType:
duplicateShading = cmds.sets(r=1, nss=1, em=1, n="%s_SG" % item)
cmds.connectAttr("%s.outColor" % item, "%s.surfaceShader" % duplicateShading, f=1)
duplicateMaterials.append(item)
elif cmds.nodeType(item) == "RedshiftDisplacement":
conInfo = cmds.connectionInfo("%s.displacementShader" % duplicateShading, sfd=1)
if not conInfo:
cmds.connectAttr("%s.out" % item, "%s.displacementShader" % duplicateShading, f=1)
elif cmds.nodeType(item) == "displacementShader":
conInfo = cmds.connectionInfo("%s.displacementShader" % duplicateShading, sfd=1)
if not conInfo:
cmds.connectAttr("%s.displacement" % item, "%s.displacementShader" % duplicateShading, f=1)
cmds.sets(obj, e=1, fe=duplicateShading)
cmds.select(selObjsList, r=1)
return list(set(duplicateMaterials))
示例5: assignShaders
def assignShaders(shadersName):
shaderPath="Y:/TRABAJOS/PECERA_MALVINAS/1_Shot_Related/_ASSETS_GENERALES/04_SHADING/2_EXPORTS/shaders/"
#print shadersName
objSelected=cmds.ls(sl=True)
objFiltered=maya.cmds.listRelatives(objSelected, allDescendents=True, noIntermediate=True, fullPath=True, type="mesh")
for obj in objFiltered:
objName=cmds.listRelatives(obj, parent=True)
#print objName
obj= obj.rsplit('|', 1)
obj=obj[0]
#print obj[0]
if '|' in obj[0]:
obj=obj[1: ]
attrName=cmds.getAttr("%s.objIdName"%(obj))
#print attrName.split("_")[0]
for shader in shadersName:
if ".json" in shader and attrName.split("_")[0] in shader:
json_data=open(shaderPath+shader).read()
jsonList = json.loads(json_data)
shaderName= jsonList[attrName]
cmds.select(obj)
shaderName=shaderName["shader"]
cmds.hyperShade(assign=shaderName)
cmds.select(objSelected)
示例6: linkShaders
def linkShaders(self, *args):
links = self.getLinksFromDB()
if links == None:
return
selection = cmds.ls(sl=True)
if len(selection) > 0:
selection = cmds.listRelatives(selection, allDescendents=True, noIntermediate=True)
# If shader file is available import it
shaderPath = cmds.textFieldButtonGrp("tfbShaderPath", q=True, tx=True)
if len(shaderPath) > 0:
cmds.file(shaderPath, i=True)
cmds.textFieldButtonGrp("tfbShaderPath", e=True, tx="")
# Link shaders
for link in links:
mesh = link[0]
shader = link[1]
if cmds.checkBox("cbSubstring", q=True, value=True):
substring = cmds.textField("tfSubstring", q=True, text=True)
mesh = substring + mesh
if cmds.objExists(mesh):
cmds.select(mesh)
cmds.hyperShade(assign=shader)
print "'" + mesh + "' linked"
print "Finished linking."
示例7: hookup_shaders
def hookup_shaders(reference_node):
hookup_prefix = "SHADER_HOOKUP_"
shader_hookups = {}
for node in cmds.ls(type="script"):
if not node.startswith(hookup_prefix):
continue
obj_pattern = node.replace(hookup_prefix, "") + "\d*"
obj_pattern = "^" + obj_pattern + "$"
shader = cmds.scriptNode(node, query=True, beforeScript=True)
shader_hookups[obj_pattern] = shader
for node in cmds.referenceQuery(reference_node, nodes=True):
for (obj_pattern, shader) in shader_hookups.iteritems():
if re.match(obj_pattern, node, re.IGNORECASE):
# assign the shader to the object
cmds.file(unloadReference=reference_node, force=True)
cmds.setAttr(reference_node + ".locked", False)
cmds.file(loadReference=reference_node)
cmds.select(node, replace=True)
cmds.hyperShade(assign=shader)
cmds.file(unloadReference=reference_node)
cmds.setAttr(reference_node + ".locked", True)
cmds.file(loadReference=reference_node)
else:
print "NODE: " + node + " doesn't match " + obj_pattern
示例8: setupDomeMatteMaterial
def setupDomeMatteMaterial(applyToMeshName):
import maya.cmds as cmds
import maya.mel as mel
#Get the selected geometry
object_selection = applyToMeshName
domeShaderName = 'dome_crossbounce_matte_material'
#Create the mia_material + shading group
dome_mia_shader_group_name = cmds.sets( renderable=True, noSurfaceShader=True, empty=True, name=domeShaderName+'SG' )
#Create a mia_material_x_passes shader
dome_mia_shader_name = cmds.shadingNode( 'mia_material_x_passes', n=domeShaderName, asShader=True)
#Apply the shading group to the selected geometry
if object_selection:
print("Applying the "+dome_mia_shader_name+" surface material to:")
cmds.select(object_selection)
cmds.hyperShade(assign=dome_mia_shader_group_name)
# Set the mia_material to be a matte material
cmds.setAttr(dome_mia_shader_name+".diffuse", 0.5, 0.5, 0.5, type="double3")
cmds.setAttr(dome_mia_shader_name+".diffuse_roughness", 0)
cmds.setAttr(dome_mia_shader_name+".diffuse_weight", 1)
cmds.setAttr(dome_mia_shader_name+".refl_color", 1, 1, 1, type="double3")
cmds.setAttr(dome_mia_shader_name+".reflectivity", 0)
# Connect the mia_material shader to the shading group
cmds.connectAttr(dome_mia_shader_name+'.message', dome_mia_shader_group_name+'.surfaceShader', f=True)
cmds.connectAttr(dome_mia_shader_name+'.message', dome_mia_shader_group_name+'.miPhotonShader', f=True)
cmds.connectAttr(dome_mia_shader_name+'.message', dome_mia_shader_group_name+'.miShadowShader', f=True)
cmds.connectAttr(dome_mia_shader_name+'.message', dome_mia_shader_group_name+'.miMaterialShader', f=True)
示例9: convert_connection_to_image
def convert_connection_to_image(shader, attribute, dest_file, overwrite, resolution=1024, pass_through=False):
if os.path.exists(dest_file) and not overwrite:
return dest_file
dest_dir = os.path.split(dest_file)[0]
create_dir(dest_dir)
plug_name = shader + '.' + attribute
if not cmds.objExists(plug_name):
warning('error converting texture, no object named {0} exists'.format(plug_name))
else:
connection = cmds.listConnections(plug_name)
if not connection:
warning('nothing connected to {0}, skipping conversion'.format(plug_name))
elif pass_through == True:
warning('{0}: skipping conversion'.format(plug_name))
else:
cmds.hyperShade(objects=shader)
connected_object = cmds.ls(sl=True)[0]
cmds.convertSolidTx(connection[0] ,connected_object ,fileImageName=dest_file, antiAlias=True, bm=3, fts=True, sp=True, alpha=True, doubleSided=True, resolutionX=resolution, resolutionY=resolution)
return dest_file
示例10: doRenderRig
def doRenderRig(self) :
path = str(self.ui.path_lineEdit.text())
texturePath = '%s/textures' % path
renderRes = str(self.ui.renderRes_comboBox.currentText())
facialCore.path = texturePath
facialCore.res = renderRes
if mc.objExists(self.defaultHeadName) :
# rename
mc.rename(self.defaultHeadName, self.renderHeadName)
# group
group = mc.group(em = True, n = self.stillGroup)
mc.parent(self.renderHeadName, group)
# render node
ltNode = facialCore.makeRenderFacial()
# create lambert
if not mc.objExists(self.renderNode) :
vrayMtl = mc.shadingNode('VRayMtl', asShader = True, n = self.renderNode)
# connect
mc.connectAttr('%s.outColor' % ltNode, '%s.color' % vrayMtl, f = True)
# assign
mc.select(self.renderHeadName)
mc.hyperShade(assign = vrayMtl)
self.messageBox('Success', 'Set Render Node Complete')
else :
self.messageBox('Warning', '%s not Exists' % self.defaultHeadName)
示例11: combineShader
def combineShader( shaderList ):
cmds.undoInfo( ock=1 )
targetObjs = []
for shader in shaderList:
cmds.hyperShade( objects = shader )
targetObjs += cmds.ls( sl=1 )
shadingEngines = cmds.listConnections( shaderList, s=0, d=1, type='shadingEngine' )
if not shadingEngines: return None
shadingEngines = list( set( shadingEngines ) )
targetShadingEngine = shadingEngines[0]
cmds.sets( targetObjs, e=1, forceElement = targetShadingEngine )
cmds.delete( shadingEngines[1:] )
for shader in shaderList:
shadingEngines = cmds.listConnections( shader, s=0, d=1, type='shadingEngine' )
if not shadingEngines:
cmds.delete( shader )
elif not targetShadingEngine in shadingEngines:
cmds.delete( shader, shadingEngines )
Window_global.nodeInfomation = {}
cmds.undoInfo( cck=1 )
示例12: selectObjectByMaterials
def selectObjectByMaterials( shaderList ):
targetObjs = []
for shader in shaderList:
cmds.hyperShade( objects = shader )
targetObjs += cmds.ls( sl=1 )
cmds.select( targetObjs )
示例13: importAbcFile
def importAbcFile():
importFilePath=pm.textField('path_ABC2', q=True, text=True)
#.abc를 없애준다
filePathDeletAbc = importFilePath.replace('.abc','')
pm.importFile( filePathDeletAbc+'.ma' )
importAbc( filePathDeletAbc+'.abc' )
connectionsTxtFile_open = open(filePathDeletAbc+'.txt')
import pickle
lst = pickle.load(connectionsTxtFile_open)
print lst
for geo, shd, aiShd,disShd in lst:
cmds.select( geo )
cmds.hyperShade( assign=shd )
node=pm.ls(geo)[0]
shape = node.getShape()
shadingGrps = shape.outputs( type='shadingEngine' )
print shadingGrps[0]
shader=pm.ls(aiShd)[0]
print shader
try:
print 'good'
pm.connectAttr(shader.outColor,shadingGrps[0].aiSurfaceShader)
except:
print 'false'
try:
disShader=pm.ls(disShd)[0]
pm.connectAttr(disShader.outColor,shadingGrps[0]..displacementShader)
except:
print 'no dis'
示例14: SundayRenderToolsChangeTextureResolution
def SundayRenderToolsChangeTextureResolution(object, level):
sel = cmds.ls(selection = True)
if object == 'selected':
if len(sel) == 0:
SundayDialogPy.SundayDialogConfirm('ERROR ', 'Nothing selected.', 'OK')
else:
cmds.hyperShade('', shaderNetworksSelectMaterialNodes = True)
selShader = cmds.ls(selection = True)
for curSelShader in selShader:
notes = cmds.hyperShade(listUpstreamNodes = curSelShader)
for note in notes:
if cmds.nodeType(note) == 'file' or cmds.nodeType(note) == 'psdFileTex':
cmds.select(note)
SundayRenderToolsChangeTextureResolutionSet(level, note)
continue
elif object == 'global':
notes = cmds.ls(type = 'file')
for note in notes:
cmds.select(note)
SundayRenderToolsChangeTextureResolutionSet(level, note)
try:
cmds.select(sel)
except:
pass
示例15: roundPlate
def roundPlate():
#get values from UI
rgb = cmds.colorSliderGrp('brickColour', query=True, rgbValue=True)
transparent = cmds.checkBox('makeTransparent', query = True, value = True)
base = cmds.polyCylinder( h = 0.18, r = 0.3 )
cmds.rotate( 90, rotateY = True )
cmds.move( 0.18/2, moveY = True)
wide = cmds.polyCylinder( h = 0.14, r = 0.4 )
cmds.rotate( 90, rotateY = True )
cmds.move( 0.18 + (0.14/2), moveY = True)
stud = cmds.polyCylinder( h = 0.18, r = 0.24 )
cmds.rotate( 90, rotateY = True )
cmds.move( 0.18 + 0.14 + (0.18/2), moveY = True)
rp = cmds.polyUnite( base, wide, stud )
myShader = cmds.shadingNode( 'phong', asShader=True )
cmds.setAttr( myShader+".color", rgb[0], rgb[1], rgb[2], type='double3')
cmds.setAttr( myShader+".reflectivity", 0 )
if( transparent == True ):
cmds.setAttr( myShader+".transparency", 0.5, 0.5, 0.5, type = 'double3' )
cmds.select( rp )
cmds.hyperShade( assign = myShader )
cmds.delete( ch = True )