本文整理汇总了Python中maya.cmds.shadingNode函数的典型用法代码示例。如果您正苦于以下问题:Python shadingNode函数的具体用法?Python shadingNode怎么用?Python shadingNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shadingNode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _water
def _water(self):
node = cmds.shadingNode('water', asTexture=True)
tex = cmds.shadingNode('place2dTexture', asUtility=True)
cmds.connectAttr(tex + '.outUV', node + '.uvCoord')
cmds.connectAttr(tex + '.outUvFilterSize', node + '.uvFilterSize')
cmds.setAttr(tex + '.repeatU', 1)
cmds.setAttr(tex + '.repeatV', 1)
示例2: substanceOutput
def substanceOutput():
node = cmds.shadingNode('substanceOutput', asTexture=True)
tex = cmds.shadingNode('place2dTexture', asUtility=True)
cmds.connectAttr(tex + '.outUV', node + '.uvCoord')
cmds.connectAttr(tex + '.outUvFilterSize', node + '.uvFilterSize')
cmds.setAttr(tex + '.repeatU', 1)
cmds.setAttr(tex + '.repeatV', 1)
示例3: grid
def grid():
node = cmds.shadingNode('grid', asTexture=True)
tex = cmds.shadingNode('place2dTexture', asUtility=True)
cmds.connectAttr(tex + '.outUV', node + '.uvCoord')
cmds.connectAttr(tex + '.outUvFilterSize', node + '.uvFilterSize')
cmds.setAttr(tex + '.repeatU', 4)
cmds.setAttr(tex + '.repeatV', 4)
示例4: createShader
def createShader(textureNode, shaderType='blinn', fromColour=False, fromNormal=True, fromSpecular=True):
if fromColour and fromNormal and fromSpecular:
raise UserWarning('You have to choose which component to start from')
if not fromColour and not fromNormal and not fromSpecular:
raise UserWarning('You have to choose which component to start from')
if not fromColour and fromNormal and fromSpecular:
raise UserWarning('You have to choose which component to start from')
colorTexture = textureNode
alphaTexture = textureNode
normalTexture = textureNode
specularTexture = textureNode
if shaderType == 'blinn':
# createShader and shadingGroup
shader = cmds.shadingNode('blinn', asShader=True)
shadingGroup = cmds.sets(shader)
if fromColour and fromSpecular:
# create bump/normal node
bumpNode = cmds.shadingNode('bump2d', asUtility=True)
cmds.setAttr(bumpNode+'.bumpInterp', 1)
# connect normal map to bump node
cmds.connectAttr(normalTexture+'.outAlpha', bumpNode+'.bumpValue')
# connect bump to shader
cmds.connectAttr(bumpNode+'.outNormal', shader+'.normalCamera')
示例5: blendS
def blendS(name, fk, ik, child):
cmds.shadingNode( 'blendColors', n=name, au=True)
cmds.connectAttr( '%s.scale' % fk , '%s.color1' % name)
cmds.connectAttr( '%s.scale' % ik , '%s.color2' % name)
cmds.connectAttr('%s.output' % name, '%s.scale' % child)
cmds.setAttr('%s.blender' % name, 0)
return name
示例6: assignArnoldShaders
def assignArnoldShaders(chromnBall,grayBall,whiteBall):
#create and assign chromn ball shader
chromnBallShader = mc.shadingNode('aiStandard', asShader = True, n = "mat_chromnBall")
chromnBallSG = mc.sets(n = chromnBallShader + "SG", renderable = True, noSurfaceShader = True, empty = True)
mc.connectAttr(chromnBallShader+".outColor", chromnBallSG+".surfaceShader", f = True)
mc.setAttr(chromnBallShader+".color",0,0,0, type = "double3")
mc.setAttr(chromnBallShader+".Kd",0)
mc.setAttr(chromnBallShader+".Ks",1)
mc.setAttr(chromnBallShader+".specularRoughness",0)
mc.sets(chromnBall,e = True, forceElement = chromnBallSG)
#create and assign gray ball shader
grayBallShader = mc.shadingNode('aiStandard', asShader = True, n = "mat_grayBall")
grayBallSG = mc.sets(n = grayBallShader + "SG", renderable = True, noSurfaceShader = True, empty = True)
mc.connectAttr(grayBallShader+".outColor", grayBallSG+".surfaceShader", f = True)
mc.setAttr(grayBallShader+".color",0.18,0.18,0.18, type = "double3")
mc.setAttr(grayBallShader+".Kd",1)
mc.setAttr(grayBallShader+".KsColor",0,0,0, type = "double3")
mc.setAttr(grayBallShader+".Ks",0)
mc.setAttr(chromnBallShader+".specularRoughness",0)
mc.sets(grayBall,e = True, forceElement = grayBallSG)
#create and assign white ball shader
whiteBallShader = mc.shadingNode('aiStandard', asShader = True, n = "mat_whiteBall")
whiteBallSG = mc.sets(n = whiteBallShader + "SG", renderable = True, noSurfaceShader = True, empty = True)
mc.connectAttr(whiteBallShader+".outColor", whiteBallSG+".surfaceShader", f = True)
mc.setAttr(whiteBallShader+".color",1,1,1, type = "double3")
mc.setAttr(whiteBallShader+".Kd",1)
mc.setAttr(whiteBallShader+".KsColor",0,0,0, type = "double3")
mc.setAttr(whiteBallShader+".Ks",0)
mc.setAttr(chromnBallShader+".specularRoughness",0)
mc.sets(whiteBall,e = True, forceElement = whiteBallSG)
示例7: updateColor
def updateColor(self, mID, colorname):
"""
Update the color of the Maya's Mesh Node associated with a this
StrandItem, this is done by creating a shadingNode for each color or
connecting the Mesh Mode to an existing shadingNode if one exists
for a given color.
"""
m = Mom()
meshName = "%s%s" % (m.helixMeshName, mID)
color = QColor(colorname)
colorval = "%d_%d_%d" % (color.red(), color.green(), color.blue())
shaderName = "%s%d_%d_%d" % (m.helixShaderName, color.red(),
color.green(),
color.blue())
if not cmds.objExists(shaderName):
# Shader does not exist create one
cmds.shadingNode('lambert', asShader=True, name=shaderName)
cmds.sets(n="%sSG" % shaderName, r=True, nss=True, em=True)
cmds.connectAttr("%s.outColor" % shaderName,
"%sSG.surfaceShader" % shaderName)
cmds.setAttr("%s.color" % shaderName,
color.redF(), color.greenF(), color.blueF(),
type="double3")
cmds.sets(meshName, forceElement="%sSG" % shaderName)
else:
#shader exist connect
cmds.sets(meshName, forceElement="%sSG" % shaderName)
示例8: linkFileToSpecular
def linkFileToSpecular(src, dst):
cmds.shadingNode("remapHsv", n="%s_remapHsc" % dst, au=1)
cmds.shadingNode("solidFractal", n="%s_solidFractal" % dst, at=1)
cmds.shadingNode("place3dTexture", n="%s_place3dTexture" % dst, at=1)
cmds.shadingNode("multiplyDivide", n="%s_multiplyDivide" % dst, au=1)
cmds.shadingNode("ramp", n="%s_ramp" % dst, at=1)
cmds.setAttr("%s.saturation[1].saturation_Position" % ("%s_remapHsc" % dst), 1)
cmds.setAttr("%s.saturation[1].saturation_FloatValue" % ("%s_remapHsc" % dst), 0)
cmds.setAttr("%s.value[0].value_FloatValue" % ("%s_remapHsc" % dst), 0)
cmds.setAttr("%s.value[0].value_Position" % ("%s_remapHsc" % dst), 0.025)
cmds.setAttr("%s.value[1].value_FloatValue" % ("%s_remapHsc" % dst), 1)
cmds.setAttr("%s.value[1].value_Position" % ("%s_remapHsc" % dst), 0.075)
cmds.connectAttr(
"%s.worldInverseMatrix[0]" % ("%s_place3dTexture" % dst), "%s.placementMatrix" % ("%s_solidFractal" % dst), f=1
)
cmds.connectAttr("%s.outColor" % src, "%s.color" % ("%s_remapHsc" % dst), f=1)
cmds.connectAttr("%s.outColor" % ("%s_remapHsc" % dst), "%s.input1" % ("%s_multiplyDivide" % dst), f=1)
cmds.connectAttr("%s.outColor" % ("%s_solidFractal" % dst), "%s.input2" % ("%s_multiplyDivide" % dst), f=1)
cmds.connectAttr("%s.output" % ("%s_multiplyDivide" % dst), "%s.colorGain" % ("%s_ramp" % dst), f=1)
if cmds.nodeType(dst) == "RedshiftArchitectural":
# cmds.disconnectAttr('%s.outColor'%(src), '%s.diffuse'%dst)
cmds.connectAttr("%s.outColor" % ("%s_ramp" % dst), "%s.refl_color" % dst, f=1)
elif cmds.nodeType(dst) == "aiStandard":
# cmds.disconnectAttr('%s.outColor'%(src), '%s.color'%dst)
cmds.connectAttr("%s.outColor" % ("%s_ramp" % dst), "%s.KsColor" % dst, f=1)
# cmds.connectAttr('%s.outColor'%('%s_ramp'%dst), '%s.color'%dst, f = 1)
else:
# cmds.disconnectAttr('%s.outColor'%(src), '%s.color'%dst)
cmds.connectAttr("%s.outColor" % ("%s_ramp" % dst), "%s.reflectedColor" % dst, f=1)
# cmds.connectAttr('%s.outColor'%('%s_ramp'%dst), '%s.color'%dst, f = 1)
linkTopRemapNodeToAll("%s_ramp" % dst)
示例9: createDecoratorNodes
def createDecoratorNodes(self, coords, mID):
"""Create a actual Maya Nodes for a new Pre-Decortators"""
m = Mom()
stapleModIndicatorName = "%s%s" % (m.decoratorNodeName, mID)
transformName = "%s%s" % (m.decoratorTransformName, mID)
meshName = "%s%s" % (m.decoratorMeshName, mID)
shaderName = "%s" % m.decoratorShaderName
cmds.createNode("transform", name=transformName, skipSelect=True)
cmds.setAttr("%s.rotateX" % transformName, 90)
cmds.setAttr("%s.translateX" % transformName, coords[0])
cmds.setAttr("%s.translateY" % transformName, coords[1])
cmds.setAttr("%s.translateZ" % transformName, coords[2])
cmds.createNode("mesh", name=meshName, parent=transformName, skipSelect=True)
# cmds.createNode("spPreDecoratorNode", name=stapleModIndicatorName)
cmds.createNode("polySphere", name=stapleModIndicatorName, skipSelect=True)
cmds.setAttr("%s.radius" % stapleModIndicatorName, 0.25)
cmds.setAttr("%s.subdivisionsAxis" % stapleModIndicatorName, 4)
cmds.setAttr("%s.subdivisionsHeight" % stapleModIndicatorName, 4)
# cmds.connectAttr("%s.outputMesh" % stapleModIndicatorName,
# "%s.inMesh" % meshName)
cmds.connectAttr("%s.output" % stapleModIndicatorName, "%s.inMesh" % meshName)
if not cmds.objExists(shaderName):
# Shader does not exist create one
cmds.shadingNode("lambert", asShader=True, name=shaderName)
cmds.sets(n="%sSG" % shaderName, r=True, nss=True, em=True)
cmds.connectAttr("%s.outColor" % shaderName, "%sSG.surfaceShader" % shaderName)
cmds.setAttr("%s.color" % shaderName, 0.0, 0.0, 0.0, type="double3")
cmds.sets(meshName, forceElement="%sSG" % shaderName)
else:
# shader exist connect
cmds.sets(meshName, forceElement="%sSG" % shaderName)
return (stapleModIndicatorName, transformName, meshName, shaderName)
示例10: _VRayWater
def _VRayWater(self):
node = cmds.shadingNode("VRayWater", asTexture=True)
tex = cmds.shadingNode("place2dTexture", asUtility=True)
cmds.connectAttr(tex + ".outUV", node + ".uvCoord")
cmds.connectAttr(tex + ".outUvFilterSize", node + ".uvFilterSize")
cmds.setAttr(tex + ".repeatU", 1)
cmds.setAttr(tex + ".repeatV", 1)
示例11: ConstraintVisibility
def ConstraintVisibility(self, Objects , ControlObject , SpaceSwitchName = 'spaceSwitch', reverse = False ):
if (self.AddNumericParameter (ControlObject, Name = SpaceSwitchName)):
SWMultDiv = cmds.shadingNode("multiplyDivide",asUtility = True ,name = SpaceSwitchName + "SWMultDivide" )
SWMultDiv = self.NameConv.RMRenameBasedOnBaseName(ControlObject, SWMultDiv, NewName = SWMultDiv)
cmds.connectAttr(ControlObject+"."+SpaceSwitchName ,SWMultDiv+".input1X")
cmds.setAttr(SWMultDiv+".input2X",10)
cmds.setAttr(SWMultDiv+".operation",2)
else:
SWMultDiv = cmds.listConnections(ControlObject + "." + SpaceSwitchName, type = "multiplyDivide")[0]
if reverse == True:
ConnectionsList = cmds.listConnections (SWMultDiv + ".outputX", type = "reverse")
reverseSW = ""
if ConnectionsList and len(ConnectionsList) >= 1:
reverseSW = ConnectionsList[0]
else :
reverseSW = cmds.shadingNode('reverse', asUtility=True, name = SpaceSwitchName + "SWReverse")
reverseSW = self.NameConv.RMRenameBasedOnBaseName(ControlObject, reverseSW, NewName ="SWReverse")
cmds.connectAttr( SWMultDiv + ".outputX", reverseSW + ".inputX")
if self.NameConv.RMIsNameInFormat (ControlObject):
reverseSW = self.NameConv.RMRenameBasedOnBaseName(ControlObject,reverseSW, NewName = reverseSW)
else:
reverseSW = self.NameConv.RMRenameNameInFormat(reverseSW)
for eachObject in Objects:
cmds.connectAttr(reverseSW + ".outputX", eachObject + ".visibility")
else:
for eachObject in Objects:
cmds.connectAttr(SWMultDiv + ".outputX", eachObject + ".visibility")
示例12: shaderAssigner
def shaderAssigner() :
# Assigning temporary shader to selected objects
sels = mc.ls( sl=True )
name = ''
side = ''
nameResult = mc.promptDialog(
title='Shading Name',
message='Enter Name:',
button=['OK', 'Cancel'],
defaultButton='OK',
cancelButton='Cancel',
dismissString='Cancel'
)
if nameResult == 'OK':
name = mc.promptDialog(query=True, text=True)
if name :
shadingName = '%sTmp_lambert' % name
if not mc.objExists( shadingName ) :
mc.shadingNode( 'lambert' , asShader=True , n=shadingName )
mc.select( sels , r=True )
cmd = 'hyperShade -assign %s;' % shadingName
mm.eval( cmd )
mc.select( shadingName , r=True )
示例13: connectThroughBC
def connectThroughBC(parentsA, parentsB, children, instance, switchattr ):
constraints = []
for j in range(len(children)):
switchPrefix = children[j].partition('_')[2]
bcNodeT = cmds.shadingNode("blendColors", asUtility=True, n=instance + 'bcNodeT_switch_' + switchPrefix)
bcNodeR = cmds.shadingNode("blendColors", asUtility=True, n=instance + 'bcNodeR_switch_' + switchPrefix)
bcNodeS = cmds.shadingNode("blendColors", asUtility=True, n=instance + 'bcNodeS_switch_' + switchPrefix)
constraints.append([bcNodeT, bcNodeR, bcNodeS])
# connect to switchattr
if switchattr == 'None':
cmds.setAttr(bcNodeT + '.blender', 1)
cmds.setAttr(bcNodeR + '.blender', 1)
cmds.setAttr(bcNodeS + '.blender', 1)
else:
cmds.connectAttr(switchattr, bcNodeT + '.blender')
cmds.connectAttr(switchattr, bcNodeR + '.blender')
cmds.connectAttr(switchattr, bcNodeS + '.blender')
# Input Parents
cmds.connectAttr(parentsA[j] + '.translate', bcNodeT + '.color1')
cmds.connectAttr(parentsA[j] + '.rotate', bcNodeR + '.color1')
cmds.connectAttr(parentsA[j] + '.scale', bcNodeS + '.color1')
if parentsB != 'None':
cmds.connectAttr(parentsB[j] + '.translate', bcNodeT + '.color2')
cmds.connectAttr(parentsB[j] + '.rotate', bcNodeR + '.color2')
cmds.connectAttr(parentsB[j] + '.scale', bcNodeS + '.color2')
# Output to Children
cmds.connectAttr(bcNodeT + '.output', children[j] + '.translate')
cmds.connectAttr(bcNodeR + '.output', children[j] + '.rotate')
cmds.connectAttr(bcNodeS + '.output', children[j] + '.scale')
return constraints
示例14: assignVrayShaders
def assignVrayShaders(chromnBall,grayBall,whiteBall):
#create and assign chromn ball shader
chromnBallShader = mc.shadingNode('VRayMtl', asShader = True, n = "mat_chromnBall")
chromnBallSG = mc.sets(n = chromnBallShader + "SG", renderable = True, noSurfaceShader = True, empty = True)
mc.connectAttr(chromnBallShader+".outColor", chromnBallSG+".surfaceShader", f = True)
mc.setAttr(chromnBallShader+".color",0,0,0, type = "double3")
mc.setAttr(chromnBallShader+".diffuseColorAmount",0)
mc.setAttr(chromnBallShader+".reflectionColor",1,1,1,type = "double3")
mc.setAttr(chromnBallShader+".refractionIOR",15)
mc.sets(chromnBall,e = True, forceElement = chromnBallSG)
#create and assign gray ball shader
grayBallShader = mc.shadingNode('VRayMtl', asShader = True, n = "mat_grayBall")
grayBallSG = mc.sets(n = grayBallShader + "SG", renderable = True, noSurfaceShader = True, empty = True)
mc.connectAttr(grayBallShader+".outColor", grayBallSG+".surfaceShader", f = True)
mc.setAttr(grayBallShader+".color",0.18,0.18,0.18, type = "double3")
mc.setAttr(grayBallShader+".reflectionColorAmount",0)
mc.sets(grayBall,e = True, forceElement = grayBallSG)
#create and assign white ball shader
whiteBallShader = mc.shadingNode('VRayMtl', asShader = True, n = "mat_whiteBall")
whiteBallSG = mc.sets(n = whiteBallShader + "SG", renderable = True, noSurfaceShader = True, empty = True)
mc.connectAttr(whiteBallShader+".outColor", whiteBallSG+".surfaceShader", f = True)
mc.setAttr(whiteBallShader+".color",1,1,1, type = "double3")
mc.setAttr(whiteBallShader+".reflectionColorAmount",0)
mc.sets(whiteBall,e = True, forceElement = whiteBallSG)
示例15: ImportCustomTexture
def ImportCustomTexture(name):
os.system("cd ~/maya/2014-x64/scripts; python texture.py")
file = '/usr/tmp/texture.jpg'
#create a shader
shader=cmds.shadingNode( "blinn", asShader=True )
#a file texture node
shaderName = file_node=cmds.shadingNode( "file", asTexture=True )
print shaderName
#attach file to node
cmds.setAttr( '%s.fileTextureName' %file_node, file, type = "string")
# a shading group
shading_group= cmds.sets(renderable=True,noSurfaceShader=True,empty=True)
#connect shader to sg surface shader
cmds.connectAttr('%s.outColor' %shader ,'%s.surfaceShader' %shading_group)
#connect file texture node to shader's color
cmds.connectAttr('%s.outColor' %file_node, '%s.color' %shader)
cmds.sets(name, edit=True, forceElement=shading_group)