Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import maya.cmds as cmds
- def connectTex(image,material,input):
- # if a file texture is already connected to this input, update it
- # otherwise, delete it
- conn = cmds.listConnections(material+'.'+input,type='file')
- if conn:
- # there is a file texture connected. replace it
- cmds.setAttr(conn[0]+'.fileTextureName',image,type='string')
- else:
- # no connected file texture, so make a new one
- newFile = cmds.shadingNode('file',asTexture=1)
- newPlacer = cmds.shadingNode('place2dTexture',asUtility=1)
- # make common connections between place2dTexture and file texture
- connections = ['rotateUV','offset','noiseUV','vertexCameraOne','vertexUvThree','vertexUvTwo','vertexUvOne','repeatUV','wrapV','wrapU','stagger','mirrorU','mirrorV','rotateFrame','translateFrame','coverage']
- cmds.connectAttr(newPlacer+'.outUV',newFile+'.uvCoord')
- cmds.connectAttr(newPlacer+'.outUvFilterSize',newFile+'.uvFilterSize')
- for i in connections:
- cmds.connectAttr(newPlacer+'.'+i,newFile+'.'+i)
- # now connect the file texture output to the material input
- cmds.connectAttr(newFile+'.outColor',material+'.'+input,f=1)
- # now set attributes on the file node.
- cmds.setAttr(newFile+'.fileTextureName',image,type='string')
- cmds.setAttr(newFile+'.filterType',0)
- #grab all DX11Shaders
- shaders = cmds.ls(type='dx11Shader')
- #path to head vis map
- LVmap = 'C:/Telltale/ArtData/Characters/Sk61/BatmanGM/Textures/sk_bm200sharedParts_headKit_Visibility.tga'
- for i in shaders:
- #if the dx11shader has head in the name
- if 'head' in i:
- #build a dx11shader att string (material name + strange dx11 attr name for the head vis true/false value
- bULVString = (i + '.sMaterialStatic81a2c141682d2846_Value')
- #set the true false value to true
- cmds.setAttr(bULVString, 2)
- #string for the strange dx11shader attr for the texture channel of the line visibility
- LVchannel = 'sMaterialTexture87b579ec018fbd4d_texture'
- #run function to plug int he texture
- connectTex(LVmap, i, LVchannel)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement