本文整理汇总了Python中pymel.core.shadingNode函数的典型用法代码示例。如果您正苦于以下问题:Python shadingNode函数的具体用法?Python shadingNode怎么用?Python shadingNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shadingNode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: doIDShdNetwork
def doIDShdNetwork(*args):
## check if the shading network is existing
shdName = 'idSetup'
if( len( pm.ls(shdName + "_SHD") ) ) != 0:
pm.confirmDialog(t="Warning", message="The shader has been existed!", icon='warning')
return 0
# aiUserDataColor
dataColor = pm.shadingNode('aiUserDataColor', asUtility=True, name=shdName+'DataColor')
dataColor.colorAttrName.set('idcolor')
# aiUserDataString
dataString = pm.shadingNode('aiUserDataString', asUtility=True, name=shdName+'DataString')
dataString.stringAttrName.set('Id')
# aiWriteColor
writeColor = pm.shadingNode('aiWriteColor', asUtility=True, name=shdName+'WriteColor')
# aiUtility
aiIDShd = pm.shadingNode('aiUtility', asShader=True, name=shdName+'_SHD')
aiIDShd.shadeMode.set(2)
# connections
dataColor.outColor >> writeColor.input
dataString.outValue >> writeColor.aovName
writeColor.outColor >> aiIDShd.color
示例2: sumAttr
def sumAttr(sumCtrl=None,
ctrlAttrA=None, ctrlAttrB=None,
ctrlAttrResult=None,
scaleA=None, scaleB=None):
pmaNode = pm.shadingNode('plusMinusAverage',n='%s_Sum'%sumCtrl, asUtility=1)
if scaleA:
scaleA_node = pm.shadingNode('multiplyDivide',n='%s_ScaleA'%sumCtrl, asUtility=1)
pm.setAttr('%s.input1X'%scaleA_node,scaleA)
pm.connectAttr(ctrlAttrA,'%s.input2X'%scaleA_node,f=1)
pm.connectAttr('%s.outputX'%scaleA_node,'%s.input1D[0]'%pmaNode,f=1)
else:
pm.connectAttr(ctrlAttrA,'%s.input1D[0]'%pmaNode,f=1)
if scaleB:
scaleB_node = pm.shadingNode('multiplyDivide',n='%s_ScaleB'%sumCtrl, asUtility=1)
pm.setAttr('%s.input1X'%scaleB_node,scaleB)
pm.connectAttr(ctrlAttrB,'%s.input2X'%scaleB_node,f=1)
pm.connectAttr('%s.outputX'%scaleB_node,'%s.input1D[1]'%pmaNode,f=1)
else:
pm.connectAttr(ctrlAttrB,'%s.input1D[1]'%pmaNode,f=1)
try:
pm.addAttr(sumCtrl, ln=ctrlAttrResult.split('.')[1], k=1)
except Exception, e:
raise( e )
示例3: createLight
def createLight(self, position):
value = self.distance_float.value()
if self.lightType_menu.currentIndex() == 1:
light = pm.shadingNode('areaLight', asLight=True)
pm.setAttr(light + '.intensity', 500)
pm.setAttr(light + '.decayRate', 2)
pm.setAttr(light + '.areaLight', 1)
elif self.lightType_menu.currentIndex() == 2:
light = pm.shadingNode('spotLight', asLight=True)
pm.setAttr(light + '.intensity', 500)
pm.setAttr(light + '.decayRate', 2)
elif self.lightType_menu.currentIndex() == 3:
light = pm.shadingNode('directionalLight', asLight=True)
elif self.lightType_menu.currentIndex() == 4:
light = pm.shadingNode('pointLight', asLight=True)
pm.setAttr(light + '.intensity', 500)
pm.setAttr(light + '.decayRate', 2)
pm.rename(light, light_name)
pm.xform(light, a=True, t=position)
pm.xform(light, r=True, t=(0, 0, value))
return light
示例4: offsets_hookUp
def offsets_hookUp():
loc = pm.ls(sl=True)[-1]
iks = pm.ls(sl=True)[:-1]
loc.addAttr('chomp', k=True, at='double', min=0, max=10)
for attr in ['offset','offsetMax','offsetMin']:
for ik in iks:
attrName = '%s_%s'%(ik.name().replace('_IK',''), attr)
loc.addAttr(attrName, at='double', k=False, dv=0)
for ik in iks:
attrName = '%s_offset'%ik.name().replace('_IK','')
attrNameMax = '%s_offsetMax'%ik.name().replace('_IK','')
attrNameMin = '%s_offsetMin'%ik.name().replace('_IK','')
loc.attr(attrName).set(1, cb=True)
loc.attr(attrNameMin).set(0, cb=True)
loc.attr(attrNameMax).set(1, cb=True)
linearMult = pm.shadingNode('multDoubleLinear', n=ik.name().replace('_IK','_LMD'), asUtility=True)
remapValue = pm.shadingNode('remapValue', n=ik.name().replace('_IK','_RMV'), asUtility=True)
loc.chomp.connect(linearMult.input1)
loc.attr(attrName).connect(linearMult.input2)
linearMult.output.connect(remapValue.inputValue)
loc.attr(attrNameMin).connect(remapValue.outputMin)
loc.attr(attrNameMax).connect(remapValue.outputMax)
remapValue.outValue.connect(ik.offset)
示例5: Maya_createNode
def Maya_createNode(self, nodeType, *args):
if nodeType == 'aiStandard':
# Ask for name
name = self.User_inputDialog("Create aiStandard", "Enter a name for the node: ")
# Create and assign shader
aiStd = pc.shadingNode('aiStandard', asShader=True, name=name)
aiStdSg = pc.sets(renderable=True, noSurfaceShader=True, empty=True, name=name + 'SG')
aiStd.outColor >> aiStdSg.surfaceShader
self.UI_refreshShaders()
return(str(aiStd))
if nodeType == 'file':
# Ask for name
name = self.User_inputDialog("Create file", "Enter a name for the node: ")
# Ask for location of the file
location = pc.fileDialog2(fm=1, dialogStyle=2)
myTex = pc.shadingNode('file', asTexture=True, name=name)
myTex.fileTextureName.set(location)
return(str(myTex))
if nodeType == 'ygColorCorrect':
# Ask for name
name = self.User_inputDialog("Create ygColorCorrect", "Enter a name for the node: ")
ygC = pc.shadingNode('ygColorCorrect', asShader=True, name=name)
return(str(ygC))
示例6: create_system
def create_system(self):
shader = pm.shadingNode('transmat', asShader= True)
volume = pm.polyCube(name= 'fog_volume', width=40,
height=40, depth=40)[0]
pm.hyperShade(volume, assign= shader)
parti_volume = pm.mel.eval('mrCreateCustomNode -asShader "" parti_volume;')
pm.setAttr('%s.scatter' % (parti_volume), 1,1,1, type= 'double3' )
pm.setAttr('%s.min_step_len' % (parti_volume), .03)
pm.setAttr('%s.max_step_len' % (parti_volume), .2)
pm.connectAttr('%s.outValue' % (parti_volume),
'%sSG.miVolumeShader' % (shader), force= True)
light_node = pm.shadingNode('%s' % (self.light_types[value]),
asLight= True)
light_node.translate.set(0,15,0)
light_node.rotate.set(-90,0,0)
light = pm.rename(light_node, 'fog_light')
pm.connectAttr('%s.message' % (light.getShape()),
'%s.lights[0]' % (parti_volume), force= True)
if self.checkBox.getValue() == 1:
# mrCreateCustomNode -asUtility "" physical_light;
# // Result: Connected physical_light1.message to fog_lightShape.mentalRayControls.miLightShader. //
phys_light = pm.mel.eval('mrCreateCustomNode -asUtility "" physical_light;')
pm.connectAttr('%s.message' % (phys_light),
'%s.mentalRayControls.miLightShader' % (light.getShape()))
示例7: Maya_createFullNetwork
def Maya_createFullNetwork(self, withFile, nodeName, *args):
if not withFile:
nodeName = self.Maya_createNode('file')
fileNode = pc.PyNode(nodeName)
aiName = self.Maya_createNode('aiStandard')
aiNode = pc.PyNode(aiName)
# DiffCC
diffCC = pc.shadingNode('ygColorCorrect', asTexture=True, name='diffCC_' + aiNode)
# specCC
specCC = pc.shadingNode('ygColorCorrect', asTexture=True, name='specCC_' + aiNode)
# roughCC
roughCC = pc.shadingNode('ygColorCorrect', asTexture=True, name='roughCC_' + aiNode)
# bumpCC
bumpCC = pc.shadingNode('ygColorCorrect', asTexture=True, name='bumpCC_' + aiNode)
# Bump node
bumpNode = pc.shadingNode('bump2d', asUtility=True, name='bump_' + aiNode)
# Connect everything
fileNode.outColor >> diffCC.image
fileNode.outColor >> specCC.image
fileNode.outColor >> roughCC.image
fileNode.outColor >> bumpCC.image
bumpCC.outAlpha >> bumpNode.bumpValue
bumpNode.outNormal >> aiNode.normalCamera
diffCC.outColor >> aiNode.color
specCC.outColor >> aiNode.KsColor
roughCC.outAlpha >> aiNode.specularRoughness
示例8: setupNetwork
def setupNetwork(aovName, *args):
# If already existing, do nothing
listShd = pc.ls(aovName+'_SHD')
if len(listShd) == 0:
# aiUserDataColor
dataColor = pc.shadingNode('aiUserDataColor', asShader=True, name=aovName+'DataColor')
dataColor.setAttr('colorAttrName', aovName, type='string')
# aiWriteColor
writeColor = pc.shadingNode('aiWriteColor', asShader=True, name=aovName+'WriteColor')
# Target aiStandard
aiStd = pc.shadingNode('surfaceShader', asShader = True, name=aovName+'_SHD')
# Make connections
dataColor.outColor >> writeColor.beauty
writeColor.outColor >> aiStd.outColor
# Creates AOV
aovs.AOVInterface().addAOV('id_'+aovName)
idAov = pc.PyNode('aiAOV_id_'+aovName)
# Connect the shader previously created to the default shader input of the AOV
aiStd.outColor >> idAov.defaultValue
else:
print "Network already in place. Skipping setup."
示例9: texNode
def texNode(cgfx, texType, shdName):
"""
:return:
"""
import pymel.core as pm
# create file nodes for all textures and set them up
texFile = pm.shadingNode("file", asTexture = True, n = str(shdName+texType+"_File"))
placeUV = pm.shadingNode("place2dTexture", asUtility = True, n = str(shdName+texType+"_uvPlace"))
placeUV.coverage >> texFile.coverage
placeUV.translateFrame >> texFile.translateFrame
placeUV.rotateFrame >> texFile.rotateFrame
placeUV.mirrorU >> texFile.mirrorU
placeUV.mirrorV >> texFile.mirrorV
placeUV.stagger >> texFile.stagger
placeUV.wrapU >> texFile.wrapU
placeUV.wrapV >> texFile.wrapV
placeUV.repeatUV >> texFile.repeatUV
placeUV.offset >> texFile.offset
placeUV.rotateUV >> texFile.rotateUV
placeUV.noiseUV >> texFile.noiseUV
placeUV.vertexUvOne >> texFile.vertexUvOne
placeUV.vertexUvTwo >> texFile.vertexUvTwo
placeUV.vertexUvThree >> texFile.vertexUvThree
placeUV.vertexCameraOne >> texFile.vertexCameraOne
placeUV.outUV >> texFile.uv
placeUV.outUvFilterSize >> texFile.uvFilterSize
return texFile
示例10: create_VarFkCtrls
def create_VarFkCtrls( IdName, guideSurface, numberOfCtrls ):
# create controls
ctrlGrp = pm.group( name = IdName + '_ctrls', empty = True, world = True)
ctrlGrp.inheritsTransform.set(0)
listOfCtrls = []
for currentCtrlIndex in range(numberOfCtrls):
if numberOfCtrls > 1:
FolliclePos = ( 1.0 / (numberOfCtrls-1) ) * currentCtrlIndex
else:
FolliclePos = ( 1.0 / (numberOfCtrls) ) * currentCtrlIndex
# create controlshape
currentCtrl = pm.circle( name = ( 'ctrl_vFK' + str( currentCtrlIndex+1 )+ '_' + IdName ), c=(0,0,0), nr=(1,0,0), sw=360, r=1.5, d=3, ut=0, tol=0.01, s=8, ch=False)
currentCtrl[0].overrideEnabled.set(True)
currentCtrl[0].overrideColor.set(4)
# lock'n hide translates + scaleX
currentCtrl[0].translateX.set( lock = True, keyable = False, channelBox = False )
currentCtrl[0].translateY.set( lock = True, keyable = False, channelBox = False )
currentCtrl[0].translateZ.set( lock = True, keyable = False, channelBox = False )
currentCtrl[0].scaleX.set( lock = True )
# add strength, position, radius attributes
pm.addAttr( longName='rotateStrength', attributeType='float', keyable=True, defaultValue=1 )
pm.addAttr( longName='position', attributeType='float', keyable=True, min=0-FolliclePos, max=1-FolliclePos )
pm.addAttr( longName='radius', attributeType='float', keyable=True, min=0.0001, defaultValue=0.3 )
# position min/max relative to defaultposition so ctrl can be zeroed out. Is remapped later back to 0 to 1 when connected to Follicle
currentFollicle = create_follicle( guideSurface[0], uPos=FolliclePos, vPos=0.5 )
currentFollicle.simulationMethod.set(0)
currentFollicle.collide.set(0)
currentFollicle.flipDirection.set( True )
currentFollicle = pm.listRelatives( currentFollicle, parent=True )
# connect to strength multiplier
rotateStrengthMultiplier = pm.shadingNode( 'multiplyDivide', asUtility = True, n = str( currentCtrl[0] ) + '_strength_mult' )
currentCtrl[0].rotate >> rotateStrengthMultiplier.input1
pm.connectAttr( currentCtrl[0] + '.rotateStrength', rotateStrengthMultiplier + '.input2X', f=1 )
pm.connectAttr( currentCtrl[0] + '.rotateStrength', rotateStrengthMultiplier + '.input2Y', f=1 )
pm.connectAttr( currentCtrl[0] + '.rotateStrength', rotateStrengthMultiplier + '.input2Z', f=1 )
# compensate position zero value by current follicle position
jntposZeroCompensate = pm.shadingNode( 'plusMinusAverage', asUtility = True, n=currentCtrl[0] + '_jntposZeroCompensate' )
pm.setAttr( jntposZeroCompensate + '.input1D[0]', pm.getAttr( currentFollicle[0].getShape() + '.parameterU' ) )
pm.connectAttr( currentCtrl[0] + '.position', jntposZeroCompensate + '.input1D[1]', f=1 )
pm.connectAttr( jntposZeroCompensate + '.output1D', currentFollicle[0].getShape() + '.parameterU', f=1 )
# grouping
buf = createBufGrp( currentCtrl )[0]
pm.parent( buf, ctrlGrp, relative = True )
pm.parent( currentFollicle, ctrlGrp )
# connect follicle position to control buffer
currentFollicle[0].translate >> buf.translate
listOfCtrls.append( currentCtrl[0] )
pm.select( clear = 1 )
print( 'Successfully created ' + currentCtrl[0] )
return listOfCtrls
示例11: make_file_nodes
def make_file_nodes(textures, shaders, attribute='color'):
""" Creates (or uses existing) file nodes and assigns them to shaders on the given attribute
Args:
textures [str]: list of file paths to textures
shaders [pm.nodetypes.Blinn] list of blinn (or other) shaders
attribute (str): attribute to connect texture to on shader
"""
file_nodes = []
print shaders
for shader in shaders:
udims = re.findall('1[01][0-9][0-9]', shader.name())
file_node = shader_udim = tex_match = None
if udims:
shader_udim=udims[0]
# Get the corresponding exr for the proper udim of the shader
if shader_udim:
for texture in textures:
print 'checking texture %s against udim search %s'%(tex_match, shader_udim)
try:
tex_match = re.search('.*%s.*'%shader_udim, texture).group()
print 'texture %s matches for udim search %d'%(tex_match, shader_udim)
break
except:
pass
# Get connected file node or make a non-existing one
connected_textures = shader.attr(attribute).listConnections()
if connected_textures and shader_udim:
print 'Using previously connected file nodes for attribute %s on shader %s'%(attribute, shader.name())
file_node = connected_textures[0]
# Special bump map section
if attribute == 'normalCamera':
try:
bump_node = shader.attr(attribute).listConnections()[0]
file_node = bump_node.bumpValue.listConnections()[0]
except:
pass
else:
file_node = pm.shadingNode('file',
asTexture=True,
n=file_name%(shader_udim, attribute))
# Special bump map section
if attribute == 'normalCamera':
bump_node = pm.shadingNode('bump2d', asUtility=True)
file_node.alphaIsLuminance.set(True)
file_node.outAlpha.connect(bump_node.bumpValue)
bump_node.outNormal.connect(shader.attr(attribute))
else:
file_node.outColor.connect(shader.attr(attribute))
# Now if we have a file node and a matching exr we can finally set the file texture name
if tex_match and file_node:
file_node.fileTextureName.set(tex_match)
file_nodes.append(file_node)
return file_nodes
示例12: complex_outdoor
def complex_outdoor(* args):
#create_ibl()
my_sun = pm.shadingNode('directionalLight', asLight= True)
pm.rename(my_sun, 'Sun')
my_sky = pm.shadingNode('areaLight', asLight= True)
new_light = pm.rename(my_sky, 'Sky')
new_light.translate.set(0,16,0)
new_light.rotate.set(-90,0,0)
new_light.scale.set(16,16,16)
示例13: createFlcs
def createFlcs(self,direction,ends):
folicles = []
pm.select(cl=1)
for i in range(self.numJnt):
jnt = self.ikJntList[i]
print jnt
pm.select(cl=1)
flcShape = pm.createNode('follicle', name = self.srf.name() + '_flcShape_' + str(i).zfill(2) )
flcTransform = flcShape.getParent()
flcTransform.rename(flcShape.name().replace('flcShape','flc') )
folicles.append(flcTransform)
srfShape = pm.listRelatives(self.srf)[0]
srfShape.local.connect(flcShape.inputSurface)
srfShape.worldMatrix[0].connect(flcShape.inputWorldMatrix)
flcShape.outRotate.connect(flcTransform.rotate)
flcShape.outTranslate.connect(flcTransform.translate)
#flcShape.flipDirection.set(1)
cposNode = pm.shadingNode( 'closestPointOnSurface', asUtility = True ,n = jnt.name() + '_cpos')
decMtx = pm.shadingNode('decomposeMatrix',asUtility = True, name = jnt.name() + '_dmtx')
self.srf.getShape().worldSpace[0].connect(cposNode.inputSurface)
decMtx.outputTranslate.connect(cposNode.inPosition)
jnt.worldMatrix[0].connect(decMtx.inputMatrix)
pm.addAttr(jnt, shortName='jointPosition', longName='jointPosition', defaultValue=0, minValue=0, maxValue=1)
jntPos = cposNode.parameterU.get()
jnt.jointPosition.set(jntPos)
self.cposList.append(cposNode)
#cposNode.parameterU >> flcShape.parameterU
flcShape.parameterV.set(0.5)
pm.orientConstraint(flcTransform,self.rigJntList[i],mo=1)
#pm.pointConstraint(flcTransform,self.rigJntList[i],mo=1,weight=0)
blendAttr = pm.shadingNode( 'blendTwoAttr', asUtility = True ,n = flcTransform.name() + '_b2a')
self.stretchRev.outputX >> blendAttr.attributesBlender
jnt.jointPosition >> blendAttr.input[0]
cposNode.parameterU >> blendAttr.input[1]
blendAttr.output >> flcShape.parameterU
pm.select(cl=1)
flcGrp = pm.group(folicles,n=self.srf.name() + '_flc_grp')
pm.select(cl=1)
pm.parent(flcGrp,self.mainGrp)
self.flcTransformList = folicles
示例14: add_squash_n_stretch
def add_squash_n_stretch(self, follicles):
"""
Args:
None
Returns (None)
Usage:
"""
base_name = '%s_flexiPlane' % self.flexiPlaneNameField.getText()
wire_name = '%s_wire_CRV' % base_name
main_crv_name = '%s_main_CTRL' % base_name
wire = pm.PyNode(wire_name)
arc_len = pm.arclen(wire, ch = True)
pm.rename( arc_len, wire_name + 'info' )
arc_len_val = pm.getAttr( wire_name + 'info.arcLength')
multDiv_length = pm.shadingNode( 'multiplyDivide', asUtility = True )
pm.rename( multDiv_length, base_name + '_div_squashStretch_length' )
pm.setAttr( base_name + '_div_squashStretch_length.operation', 2 )
pm.connectAttr( wire_name + 'info.arcLength', base_name + '_div_squashStretch_length.input1X' )
pm.setAttr( base_name + '_div_squashStretch_length.input2X', arc_len_val )
multDiv_volume = pm.shadingNode( 'multiplyDivide', asUtility = True )
pm.rename( multDiv_volume, base_name + '_div_volume' )
pm.setAttr( base_name + '_div_volume.operation', 2 )
pm.setAttr( base_name + '_div_volume.input1X', 1 )
pm.connectAttr( base_name + '_div_squashStretch_length.outputX', base_name + '_div_volume.input2X', f = True )
conditional_volume = pm.shadingNode( 'condition', asUtility = True )
pm.rename( conditional_volume, base_name + '_cond_volume' )
pm.setAttr( base_name + '_cond_volume.secondTerm', 1 )
pm.connectAttr( main_crv_name + '.squashN_stretch', base_name + '_cond_volume.firstTerm' )
multDiv_globelScale = pm.shadingNode( 'multiplyDivide', asUtility = True )
pm.rename( multDiv_globelScale, base_name + '_mult_globalScale' )
pm.connectAttr( base_name + '_div_volume.outputX', base_name + '_mult_globalScale.input1X' )
pm.connectAttr( main_crv_name + '.scaleX', base_name + '_mult_globalScale.input2X' )
pm.connectAttr( base_name + '_mult_globalScale.outputX', base_name + '_cond_volume.colorIfTrueR' )
for index,follicle in enumerate(follicles):
jnt_name = self.format_string.format(PREFIX = self.flexiPlaneNameField.getText(),
INDEX = 'flexiPlane_jnt%03d' % (index+1),
SUFFIX = 'JNT')
jnt_offset_name = jnt_name.replace('_JNT','Offset_GRP')
tweek_crv_name = self.format_string.format(PREFIX = self.flexiPlaneNameField.getText(),
INDEX = 'flexiPlane_tweak%03d' % (index+1),
SUFFIX = 'CTRL')
pm.scaleConstraint( tweek_crv_name + 'Con_GRP', jnt_offset_name )
pm.connectAttr( base_name + '_cond_volume.outColorR', jnt_name + '.scaleX')
pm.connectAttr( base_name + '_cond_volume.outColorR', jnt_name + '.scaleZ')
pm.select( clear = True )
示例15: addUV
def addUV(*args): #Create UV pass with shader
if not pm.objExists( 'aiAOV_UV' ): #check if UV AOV already exists
shdrUV = pm.shadingNode('aiUtility', asShader = True, name = 'GEN_UV')
shdrUV.shadeMode.set(2)
shdrUV.color.set(0,0,0)
siUV = pm.shadingNode('samplerInfo', asShader = True, name = 'INFO_UV')
siUV.uvCoord.uCoord >> shdrUV.color.colorR
siUV.uvCoord.vCoord >> shdrUV.color.colorG
aovUV = aovs.AOVInterface().addAOV('UV')
aovUV = pm.PyNode('aiAOV_UV')
shdrUV.outColor >> aovUV.defaultValue
print 'UV AOV DONE!'