Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. import maya.cmds as cmds
  2.  
  3. def connectTex(image,material,input):
  4. # if a file texture is already connected to this input, update it
  5. # otherwise, delete it
  6. conn = cmds.listConnections(material+'.'+input,type='file')
  7. if conn:
  8. # there is a file texture connected. replace it
  9. cmds.setAttr(conn[0]+'.fileTextureName',image,type='string')
  10. else:
  11. # no connected file texture, so make a new one
  12. newFile = cmds.shadingNode('file',asTexture=1)
  13. newPlacer = cmds.shadingNode('place2dTexture',asUtility=1)
  14. # make common connections between place2dTexture and file texture
  15. connections = ['rotateUV','offset','noiseUV','vertexCameraOne','vertexUvThree','vertexUvTwo','vertexUvOne','repeatUV','wrapV','wrapU','stagger','mirrorU','mirrorV','rotateFrame','translateFrame','coverage']
  16. cmds.connectAttr(newPlacer+'.outUV',newFile+'.uvCoord')
  17. cmds.connectAttr(newPlacer+'.outUvFilterSize',newFile+'.uvFilterSize')
  18. for i in connections:
  19. cmds.connectAttr(newPlacer+'.'+i,newFile+'.'+i)
  20. # now connect the file texture output to the material input
  21. cmds.connectAttr(newFile+'.outColor',material+'.'+input,f=1)
  22. # now set attributes on the file node.
  23. cmds.setAttr(newFile+'.fileTextureName',image,type='string')
  24. cmds.setAttr(newFile+'.filterType',0)
  25.  
  26. #grab all DX11Shaders
  27. shaders = cmds.ls(type='dx11Shader')
  28.  
  29. #path to head vis map
  30. LVmap = 'C:/Telltale/ArtData/Characters/Sk61/BatmanGM/Textures/sk_bm200sharedParts_headKit_Visibility.tga'
  31.  
  32.  
  33. for i in shaders:
  34.  
  35. #if the dx11shader has head in the name
  36. if 'head' in i:
  37. #build a dx11shader att string (material name + strange dx11 attr name for the head vis true/false value
  38. bULVString = (i + '.sMaterialStatic81a2c141682d2846_Value')
  39. #set the true false value to true
  40. cmds.setAttr(bULVString, 2)
  41. #string for the strange dx11shader attr for the texture channel of the line visibility
  42. LVchannel = 'sMaterialTexture87b579ec018fbd4d_texture'
  43.  
  44. #run function to plug int he texture
  45. connectTex(LVmap, i, LVchannel)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement