Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # toMIA_converter v3
- # cwisbg.com
- # Convert to MIA material
- from pymel.core import *
- sl = selected()
- for s in sl:
- matList = []
- matType = s.nodeType()
- colorCon = s.color.listConnections()
- bumpCon = s.normalCamera.listConnections()
- if matType != "lambert":
- specCon = s.specularColor.listConnections()
- nwMatCheck = ls('{0}_mia'.format(s))
- if not nwMatCheck: # Check if theres a material already
- nwMat = shadingNode('mia_material_x_passes',asShader=1,n='{0}_mia'.format(s))
- matList.append(nwMat)
- else:
- nwMat = nwMatCheck[0]
- matList.append(nwMat)
- if colorCon:
- colorCon[0].outColor >> nwMat.diffuse
- else:
- currentColor = getAttr(s.color)
- setAttr(nwMat.diffuse,currentColor)
- if bumpCon:
- bumpCon[0].outNormal >> nwMat.overall_bump
- if specCon:
- specCon[0].outAlpha >> nwMat.reflectivity
- matSG = s.listConnections(t="shadingEngine")[0]
- nwMat.message >> matSG.miMaterialShader
- nwMat.message >> matSG.miShadowShader
- nwMat.message >> matSG.miPhotonShader
- setAttr(nwMat.reflectivity, 0)
- #setAttr(nwMat.refl_gloss, 0.15)
- # Simple add gamma correct
- nodeCheck = "gammaCorrect", "mip_gamma_gain"
- for s in matList:
- colorGrab = listAttr(s,se=1)
- for attr in colorGrab:
- if attr[-5:] == "color" or attr[-7:] == "diffuse":
- currentCon = listConnections("{0}.{1}".format(s,attr), p=1)
- currentType = nodeType(currentCon)
- if currentType in nodeCheck:
- pass
- else:
- nwGamma = shadingNode("gammaCorrect", asUtility=1, n= "{0}_{1}_gamma".format(s, attr))
- setAttr("{0}.gammaX".format(nwGamma), 0.454545)
- setAttr("{0}.gammaY".format(nwGamma), 0.454545)
- setAttr("{0}.gammaZ".format(nwGamma), 0.454545)
- if currentCon:
- currentCon[0] >> nwGamma.value
- else:
- colorCon = getAttr("{0}.{1}".format(s,attr))
- #print "{0}.{1}_gamma.value".format(s,attr)
- setAttr("{0}_{1}_gamma.value".format(s,attr), colorCon,type= "double3")
- nwGamma.outValue >> "{0}.{1}".format(s,attr)
- print "done"
Advertisement
Add Comment
Please, Sign In to add comment