This script is a long one. It gamma corrects all the swatches on all the selected shaders that don’t equal white or black. It also allows you to set the value of the gamma node. Current supported shaders: VRayMtl, VRay Light Mtl, VRay SS2, VRay Car Paint, Phong, Blinn, Lambert, Surface Shader, Anisotropic.
To Run: Select the shaders you want to gamma correct then run the script.
#Gamma Correct Swatches for Maya version 1.0.0 #Should work with up to Vray 2.4 haven't gotten access to a later version to test #Bryanna London www.bryannalondon.com #!/usr/bin/env python #Current Supported Shaders: VRayMtl, VRay Light Mtl, Vray SSS2, Phong, Blinn, Lambert, VRay Car Paint, Surface Shader, Anisotropic #TO RUN: select all the shaders you want to gamma correct than run entire script import maya.cmds as cmds #Identify all selected shaders def gammaSwatches(): #define selected shaders selectedShaders = cmds.ls(selection = True, materials = True) #Prompt gammaPrompt = cmds.promptDialog(title = 'Gamma Swatches', message = 'Enter Gamma Value', button=['OK','Cancel'], defaultButton='OK', cancelButton='Cancel', dismissString='Cancel') #If Add is selected if gammaPrompt == 'OK': #Query prompt value = cmds.promptDialog(query = True, text = True) #for all selected shaders identify its type for selectedShader in selectedShaders: shaderType = cmds.nodeType(selectedShader) #for each Vray Mtl set up each attribute that may need gamma correcting if shaderType == 'VRayMtl': #get diffuse RGB vrayColorR = cmds.getAttr('%s.diffuseColorR' %(selectedShader)) vrayColorG = cmds.getAttr('%s.diffuseColorG' %(selectedShader)) vrayColorB = cmds.getAttr('%s.diffuseColorB' %(selectedShader)) vrayColor = vrayColorR, vrayColorG, vrayColorB #print vrayColor #get reflection RGB vrayReflR = cmds.getAttr('%s.reflectionColorR' %(selectedShader)) vrayReflG = cmds.getAttr('%s.reflectionColorG' %(selectedShader)) vrayReflB = cmds.getAttr('%s.reflectionColorB' %(selectedShader)) vrayRefl = vrayReflR, vrayReflG, vrayReflB #print vrayRefl #get refraction RGB vrayRefrR = cmds.getAttr('%s.refractionColorR' %(selectedShader)) vrayRefrG = cmds.getAttr('%s.refractionColorG' %(selectedShader)) vrayRefrB = cmds.getAttr('%s.refractionColorB' %(selectedShader)) vrayRefr = vrayRefrR, vrayRefrG, vrayRefrB #print vrayRefr #get Fog RGB vrayFogR = cmds.getAttr('%s.fogColorR' %(selectedShader)) vrayFogG = cmds.getAttr('%s.fogColorG' %(selectedShader)) vrayFogB = cmds.getAttr('%s.fogColorB' %(selectedShader)) vrayFog = vrayFogR, vrayFogG, vrayFogB #print vrayFog #get self illumination RGB vrayIllR = cmds.getAttr('%s.illumColorR' %(selectedShader)) vrayIllG = cmds.getAttr('%s.illumColorG' %(selectedShader)) vrayIllB = cmds.getAttr('%s.illumColorB' %(selectedShader)) vrayIll = vrayIllR, vrayIllG, vrayIllB #print vrayIll #if the diffuse color doesn't equal white or black if vrayColor != (0,0,0) and vrayColor !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.diffuseColor',destination = False): #Create gamma node. Change color and change gamma to .454 gamma = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gamma + '.value', vrayColorR, vrayColorG, vrayColorB , type = 'double3') cmds.setAttr(gamma + '.gammaX', float(value)) cmds.setAttr(gamma + '.gammaY', float(value)) cmds.setAttr(gamma + '.gammaZ', float(value)) #Connect gamma to diffuse cmds.connectAttr(gamma + '.outValue', selectedShader + '.color') #if the reflection color doesn't equal white or black if vrayRefl != (0,0,0) and vrayRefl !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.reflectionColor',destination = False): #Create gamma node. Change color and change gamma to .454 gammaRefl = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaRefl + '.value', vrayReflR, vrayReflG, vrayReflB , type = 'double3') cmds.setAttr(gammaRefl + '.gammaX', float(value)) cmds.setAttr(gammaRefl + '.gammaY', float(value)) cmds.setAttr(gammaRefl + '.gammaZ', float(value)) #Connect gamma to reflection color cmds.connectAttr(gammaRefl + '.outValue', selectedShader + '.reflectionColor') #if the refraction color doesn't equal white or black if vrayRefr != (0,0,0) and vrayRefr !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.refractionColor',destination = False): #Create gamma node. Change color and change gamma to .454 gammaRefr = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaRefr + '.value', vrayRefrR, vrayRefrG, vrayRefrB , type = 'double3') cmds.setAttr(gammaRefr + '.gammaX', float(value)) cmds.setAttr(gammaRefr + '.gammaY', float(value)) cmds.setAttr(gammaRefr + '.gammaZ', float(value)) #Connect gamma to refraction Color cmds.connectAttr(gammaRefr + '.outValue', selectedShader + '.refractionColor') #if the fog color doesn't equal white or black if vrayFog != (0,0,0) and vrayFog !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.fogColor',destination = False): #Create gamma node. Change color and change gamma to .454 gammaFog = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaFog + '.value', vrayFogR, vrayFogG, vrayFogB , type = 'double3') cmds.setAttr(gammaFog + '.gammaX', float(value)) cmds.setAttr(gammaFog + '.gammaY', float(value)) cmds.setAttr(gammaFog + '.gammaZ', float(value)) #Connect gamma to fog color cmds.connectAttr(gammaFog + '.outValue', selectedShader + '.fogColor') #if the self illumination color doesn't equal white or black if vrayIll != (0,0,0) and vrayIll !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.illumColor',destination = False): #Create gamma node. Change color and change gamma to .454 gammaIll = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaIll + '.value', vrayIllR, vrayIllG, vrayIllB , type = 'double3') cmds.setAttr(gammaIll + '.gammaX', float(value)) cmds.setAttr(gammaIll + '.gammaY', float(value)) cmds.setAttr(gammaIll + '.gammaZ', float(value)) #Connect gamma to self illumination color cmds.connectAttr(gammaIll + '.outValue', selectedShader + '.illumColor') #VRAY LIGHT MTL if shaderType == 'VRayLightMtl': #get diffuse RGB vrayLColorR = cmds.getAttr('%s.colorR' %(selectedShader)) vrayLColorG = cmds.getAttr('%s.colorG' %(selectedShader)) vrayLColorB = cmds.getAttr('%s.colorB' %(selectedShader)) vrayLColor = vrayLColorR, vrayLColorG, vrayLColorB #print vrayLColor #if the diffuse color doesn't equal white or black if vrayLColor != (0,0,0) and vrayLColor !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.color',destination = False): #Create gamma node. Change color and change gamma to .454 gammaLight = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaLight + '.value', vrayLColorR, vrayLColorG, vrayLColorB , type = 'double3') cmds.setAttr(gammaLight + '.gammaX', float(value)) cmds.setAttr(gammaLight + '.gammaY', float(value)) cmds.setAttr(gammaLight + '.gammaZ', float(value)) #Connect gamma to diffuse cmds.connectAttr(gammaLight + '.outValue', selectedShader + '.color') #BLINN if shaderType == 'blinn': #get diffuse RGB vrayBColorR = cmds.getAttr('%s.colorR' %(selectedShader)) vrayBColorG = cmds.getAttr('%s.colorG' %(selectedShader)) vrayBColorB = cmds.getAttr('%s.colorB' %(selectedShader)) vrayBColor = vrayBColorR, vrayBColorG, vrayBColorB #print vrayBColor #get ambient color RGB vrayBAmbR = cmds.getAttr('%s.ambientColorR' %(selectedShader)) vrayBAmbG = cmds.getAttr('%s.ambientColorG' %(selectedShader)) vrayBAmbB = cmds.getAttr('%s.ambientColorB' %(selectedShader)) vrayBAmb = vrayBAmbR, vrayBAmbG, vrayBAmbB #print vrayBAmb #get incandescence color RGB vrayBIncR = cmds.getAttr('%s.incandescenceR' %(selectedShader)) vrayBIncG = cmds.getAttr('%s.incandescenceG' %(selectedShader)) vrayBIncB = cmds.getAttr('%s.incandescenceB' %(selectedShader)) vrayBInc = vrayBIncR, vrayBIncG, vrayBIncB #print vrayBInc #get specular color RGB vrayBSpecR = cmds.getAttr('%s.specularColorR' %(selectedShader)) vrayBSpecG = cmds.getAttr('%s.specularColorG' %(selectedShader)) vrayBSpecB = cmds.getAttr('%s.specularColorB' %(selectedShader)) vrayBSpec = vrayBSpecR, vrayBSpecG, vrayBSpecB #print vrayBSpec #get reflection color RGB vrayBReflR = cmds.getAttr('%s.reflectedColorR' %(selectedShader)) vrayBReflG = cmds.getAttr('%s.reflectedColorG' %(selectedShader)) vrayBReflB = cmds.getAttr('%s.reflectedColorB' %(selectedShader)) vrayBRefl = vrayBReflR, vrayBReflG, vrayBReflB #print vrayBRefl #if the diffuse color doesn't equal white or black if vrayBColor != (0,0,0) and vrayBColor !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.color',destination = False): #Create gamma node. Change color and change gamma to .454 gammaBlinn = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaBlinn + '.value', vrayBColorR, vrayBColorG, vrayBColorB , type = 'double3') cmds.setAttr(gammaBlinn + '.gammaX', float(value)) cmds.setAttr(gammaBlinn + '.gammaY', float(value)) cmds.setAttr(gammaBlinn + '.gammaZ', float(value)) #Connect gamma to diffuse cmds.connectAttr(gammaBlinn + '.outValue', selectedShader + '.color') #if the ambient color doesn't equal white or black if vrayBAmb != (0,0,0) and vrayBAmb !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.ambientColor',destination = False): #Create gamma node. Change color and change gamma to .454 gammaBAmb = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaBAmb + '.value', vrayBAmbR, vrayBAmbG, vrayBAmbB , type = 'double3') cmds.setAttr(gammaBAmb + '.gammaX', float(value)) cmds.setAttr(gammaBAmb + '.gammaY', float(value)) cmds.setAttr(gammaBAmb + '.gammaZ', float(value)) #Connect gamma to ambient color cmds.connectAttr(gammaBAmb + '.outValue', selectedShader + '.ambientColor') #if the incandescence color doesn't equal white or black if vrayBInc != (0,0,0) and vrayBInc !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.incandescence',destination = False): #Create gamma node. Change color and change gamma to .454 gammaBInc = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaBInc + '.value', vrayBIncR, vrayBIncG, vrayBIncB , type = 'double3') cmds.setAttr(gammaBInc + '.gammaX', float(value)) cmds.setAttr(gammaBInc + '.gammaY', float(value)) cmds.setAttr(gammaBInc + '.gammaZ', float(value)) #Connect gamma to incandescence cmds.connectAttr(gammaBInc + '.outValue', selectedShader + '.incandescence') #if the specular color doesn't equal white or black if vrayBSpec != (0,0,0) and vrayBSpec !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.specularColor',destination = False): #Create gamma node. Change color and change gamma to .454 gammaBSpec = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaBSpec + '.value', vrayBSpecR, vrayBSpecG, vrayBSpecB , type = 'double3') cmds.setAttr(gammaBSpec + '.gammaX', float(value)) cmds.setAttr(gammaBSpec + '.gammaY', float(value)) cmds.setAttr(gammaBSpec + '.gammaZ', float(value)) #Connect gamma to specular color cmds.connectAttr(gammaBSpec + '.outValue', selectedShader + '.specularColor') #if the reflection color doesn't equal white or black if vrayBRefl != (0,0,0) and vrayBRefl !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.reflectedColor',destination = False): #Create gamma node. Change color and change gamma to .454 gammaBRefl = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaBRefl + '.value', vrayBReflR, vrayBReflG, vrayBReflB , type = 'double3') cmds.setAttr(gammaBRefl + '.gammaX', float(value)) cmds.setAttr(gammaBRefl + '.gammaY', float(value)) cmds.setAttr(gammaBRefl + '.gammaZ', float(value)) #Connect gamma to reflection color cmds.connectAttr(gammaBRefl + '.outValue', selectedShader + '.reflectedColor') #VRAY SSS2 if shaderType == 'VRayFastSSS2': #get overall color RGB vraySSSColorR = cmds.getAttr('%s.overallTexR' %(selectedShader)) vraySSSColorG = cmds.getAttr('%s.overallTexG' %(selectedShader)) vraySSSColorB = cmds.getAttr('%s.overallTexB' %(selectedShader)) vraySSSColor = vraySSSColorR, vraySSSColorG, vraySSSColorB #print vraySSSColor #get diffuse color RGB vraySSSDiffR = cmds.getAttr('%s.diffuseTexR' %(selectedShader)) vraySSSDiffG = cmds.getAttr('%s.diffuseTexG' %(selectedShader)) vraySSSDiffB = cmds.getAttr('%s.diffuseTexB' %(selectedShader)) vraySSSDiff = vraySSSDiffR, vraySSSDiffG, vraySSSDiffB #print vraySSSDiff #get sub-surface color RGB vraySSSSubR = cmds.getAttr('%s.subsurfaceColorR' %(selectedShader)) vraySSSSubG = cmds.getAttr('%s.subsurfaceColorG' %(selectedShader)) vraySSSSubB = cmds.getAttr('%s.subsurfaceColorB' %(selectedShader)) vraySSSSub = vraySSSSubR, vraySSSSubG, vraySSSSubB #print vraySSSSub #get scatter color RGB vraySSSScatR = cmds.getAttr('%s.scatterRadiusColorR' %(selectedShader)) vraySSSScatG = cmds.getAttr('%s.scatterRadiusColorG' %(selectedShader)) vraySSSScatB = cmds.getAttr('%s.scatterRadiusColorB' %(selectedShader)) vraySSSScat = vraySSSScatR, vraySSSScatG, vraySSSScatB #print vraySSSScat #get specular color RGB vraySSSSpecR = cmds.getAttr('%s.reflectionR' %(selectedShader)) vraySSSSpecG = cmds.getAttr('%s.reflectionG' %(selectedShader)) vraySSSSpecB = cmds.getAttr('%s.reflectionB' %(selectedShader)) vraySSSSpec = vraySSSSpecR, vraySSSSpecG, vraySSSSpecB #print vraySSSSpec #if the overall color doesn't equal white or black if vraySSSColor != (0,0,0) and vraySSSColor !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.overallTex', destination = False): #Create gamma node. Change color and change gamma to .454 gammaSSS = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaSSS + '.value', vraySSSColorR, vraySSSColorG, vraySSSColorB , type = 'double3') cmds.setAttr(gammaSSS + '.gammaX', float(value)) cmds.setAttr(gammaSSS + '.gammaY', float(value)) cmds.setAttr(gammaSSS + '.gammaZ', float(value)) #Connect gamma to overall color cmds.connectAttr(gammaSSS + '.outValue', selectedShader + '.overallTex') #if the diffuse color doesn't equal white or black if vraySSSDiff != (0,0,0) and vraySSSDiff !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.diffuseTex', destination = False): #Create gamma node. Change color and change gamma to .454 gammaSSSDiff = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaSSSDiff + '.value', vraySSSDiffR, vraySSSDiffG, vraySSSDiffB , type = 'double3') cmds.setAttr(gammaSSSDiff + '.gammaX', float(value)) cmds.setAttr(gammaSSSDiff + '.gammaY', float(value)) cmds.setAttr(gammaSSSDiff + '.gammaZ', float(value)) #Connect gamma to diffuse color cmds.connectAttr(gammaSSSDiff + '.outValue', selectedShader + '.diffuseTex') #if the sub-surface color doesn't equal white or black if vraySSSSub != (0,0,0) and vraySSSSub !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.subsurfaceColor', destination = False): #Create gamma node. Change color and change gamma to .454 gammaSSSSub = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaSSSSub + '.value', vraySSSSubR, vraySSSSubG, vraySSSSubB , type = 'double3') cmds.setAttr(gammaSSSSub + '.gammaX', float(value)) cmds.setAttr(gammaSSSSub + '.gammaY', float(value)) cmds.setAttr(gammaSSSSub + '.gammaZ', float(value)) #Connect gamma to sub-surface color cmds.connectAttr(gammaSSSSub + '.outValue', selectedShader + '.subsurfaceColor') #if the scatter color doesn't equal white or black if vraySSSScat != (0,0,0) and vraySSSScat !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.scatterRadiusColor', destination = False): #Create gamma node. Change color and change gamma to .454 gammaSSSScat = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaSSSScat + '.value', vraySSSScatR, vraySSSScatG, vraySSSScatB , type = 'double3') cmds.setAttr(gammaSSSScat + '.gammaX', float(value)) cmds.setAttr(gammaSSSScat + '.gammaY', float(value)) cmds.setAttr(gammaSSSScat + '.gammaZ', float(value)) #Connect gamma to scatter color cmds.connectAttr(gammaSSSScat + '.outValue', selectedShader + '.scatterRadiusColor') #if the specular color doesn't equal white or black if vraySSSSpec != (0,0,0) and vraySSSSpec !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.reflection', destination = False): #Create gamma node. Change color and change gamma to .454 gammaSSSSpec = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaSSSSpec + '.value', vraySSSSpecR, vraySSSSpecG, vraySSSSpecB , type = 'double3') cmds.setAttr(gammaSSSSpec + '.gammaX', float(value)) cmds.setAttr(gammaSSSSpec + '.gammaY', float(value)) cmds.setAttr(gammaSSSSpec + '.gammaZ', float(value)) #Connect gamma to specular color cmds.connectAttr(gammaSSSSpec + '.outValue', selectedShader + '.reflection') #Phong if shaderType == 'phong': #get diffuse color RGB vrayPDiffR = cmds.getAttr('%s.colorR' %(selectedShader)) vrayPDiffG = cmds.getAttr('%s.colorG' %(selectedShader)) vrayPDiffB = cmds.getAttr('%s.colorB' %(selectedShader)) vrayPDiff = vrayPDiffR, vrayPDiffG, vrayPDiffB #print vrayPDiff #get ambient color RGB vrayPAmbR = cmds.getAttr('%s.ambientColorR' %(selectedShader)) vrayPAmbG = cmds.getAttr('%s.ambientColorG' %(selectedShader)) vrayPAmbB = cmds.getAttr('%s.ambientColorB' %(selectedShader)) vrayPAmb = vrayPAmbR, vrayPAmbG, vrayPAmbB #print vrayPAmb #get incandescence RGB vrayPIncR = cmds.getAttr('%s.incandescenceR' %(selectedShader)) vrayPIncG = cmds.getAttr('%s.incandescenceG' %(selectedShader)) vrayPIncB = cmds.getAttr('%s.incandescenceB' %(selectedShader)) vrayPInc = vrayPIncR, vrayPIncG, vrayPIncB #print vrayPInc #get specular color RGB vrayPSpecR = cmds.getAttr('%s.specularColorR' %(selectedShader)) vrayPSpecG = cmds.getAttr('%s.specularColorG' %(selectedShader)) vrayPSpecB = cmds.getAttr('%s.specularColorB' %(selectedShader)) vrayPSpec = vrayPSpecR, vrayPSpecG, vrayPSpecB #print vrayPSpec #get reflected color RGB vrayPReflR = cmds.getAttr('%s.reflectedColorR' %(selectedShader)) vrayPReflG = cmds.getAttr('%s.reflectedColorG' %(selectedShader)) vrayPReflB = cmds.getAttr('%s.reflectedColorB' %(selectedShader)) vrayPRefl = vrayPReflR, vrayPReflG, vrayPReflB #print vrayPRefl #if the diffuse color doesn't equal white or black if vrayPDiff != (0,0,0) and vrayPDiff !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.color', destination = False): #Create gamma node. Change color and change gamma to .454 gammaPDiff = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaPDiff + '.value', vrayPDiffR, vrayPDiffG, vrayPDiffB , type = 'double3') cmds.setAttr(gammaPDiff + '.gammaX', float(value)) cmds.setAttr(gammaPDiff + '.gammaY', float(value)) cmds.setAttr(gammaPDiff + '.gammaZ', float(value)) #Connect gamma to diffuse color cmds.connectAttr(gammaPDiff + '.outValue', selectedShader + '.color') #if the ambient color doesn't equal white or black if vrayPAmb != (0,0,0) and vrayPAmb !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.ambientColor', destination = False): #Create gamma node. Change color and change gamma to .454 gammaPAmb = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaPAmb + '.value', vrayPAmbR, vrayPAmbG, vrayPAmbB , type = 'double3') cmds.setAttr(gammaPAmb + '.gammaX', float(value)) cmds.setAttr(gammaPAmb + '.gammaY', float(value)) cmds.setAttr(gammaPAmb + '.gammaZ', float(value)) #Connect gamma to ambient color cmds.connectAttr(gammaPAmb + '.outValue', selectedShader + '.ambientColor') #if the incandescence doesn't equal white or black if vrayPInc != (0,0,0) and vrayPInc !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.incandescence', destination = False): #Create gamma node. Change color and change gamma to .454 gammaPInc = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaPInc + '.value', vrayPIncR, vrayPIncG, vrayPIncB , type = 'double3') cmds.setAttr(gammaPInc + '.gammaX', float(value)) cmds.setAttr(gammaPInc + '.gammaY', float(value)) cmds.setAttr(gammaPInc + '.gammaZ', float(value)) #Connect gamma to incandescence color cmds.connectAttr(gammaPInc + '.outValue', selectedShader + '.incandescence') #if the specular color doesn't equal white or black if vrayPSpec != (0,0,0) and vrayPSpec !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.specularColor', destination = False): #Create gamma node. Change color and change gamma to .454 gammaPSpec = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaPSpec + '.value', vrayPSpecR, vrayPSpecG, vrayPSpecB , type = 'double3') cmds.setAttr(gammaPSpec + '.gammaX', float(value)) cmds.setAttr(gammaPSpec + '.gammaY', float(value)) cmds.setAttr(gammaPSpec + '.gammaZ', float(value)) #Connect gamma to specular color cmds.connectAttr(gammaPSpec + '.outValue', selectedShader + '.specularColor') #if the reflection color doesn't equal white or black if vrayPRefl != (0,0,0) and vrayPRefl !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.reflectedColor', destination = False): #Create gamma node. Change color and change gamma to .454 gammaPRefl = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaPRefl + '.value', vrayPReflR, vrayPReflG, vrayPReflB , type = 'double3') cmds.setAttr(gammaPRefl + '.gammaX', float(value)) cmds.setAttr(gammaPRefl + '.gammaY', float(value)) cmds.setAttr(gammaPRefl + '.gammaZ', float(value)) #Connect gamma to specular color cmds.connectAttr(gammaPRefl + '.outValue', selectedShader + '.reflectedColor') #Lambert if shaderType == 'lambert': #get diffuse RGB vrayLColR = cmds.getAttr('%s.colorR' %(selectedShader)) vrayLColG = cmds.getAttr('%s.colorG' %(selectedShader)) vrayLColB = cmds.getAttr('%s.colorB' %(selectedShader)) vrayLCol = vrayLColR, vrayLColG, vrayLColB #print vrayLColor #get ambient color RGB vrayLAmbR = cmds.getAttr('%s.ambientColorR' %(selectedShader)) vrayLAmbG = cmds.getAttr('%s.ambientColorG' %(selectedShader)) vrayLAmbB = cmds.getAttr('%s.ambientColorB' %(selectedShader)) vrayLAmb = vrayLAmbR, vrayLAmbG, vrayLAmbB #print vrayLAmb #get incandescence RGB vrayLIncR = cmds.getAttr('%s.incandescenceR' %(selectedShader)) vrayLIncG = cmds.getAttr('%s.incandescenceG' %(selectedShader)) vrayLIncB = cmds.getAttr('%s.incandescenceB' %(selectedShader)) vrayLInc = vrayLIncR, vrayLIncG, vrayLIncB #print vrayLInc #if the diffuse color doesn't equal white or black if vrayLCol != (0,0,0) and vrayLCol !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.color', destination = False): #Create gamma node. Change color and change gamma to .454 gammaLColor = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaLColor + '.value', vrayLColR, vrayLColG, vrayLColB , type = 'double3') cmds.setAttr(gammaLColor + '.gammaX', float(value)) cmds.setAttr(gammaLColor + '.gammaY', float(value)) cmds.setAttr(gammaLColor + '.gammaZ', float(value)) #Connect gamma to diffuse color cmds.connectAttr(gammaLColor + '.outValue', selectedShader + '.color') #if the ambient color doesn't equal white or black if vrayLAmb != (0,0,0) and vrayLAmb !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.ambientColor', destination = False): #Create gamma node. Change color and change gamma to .454 gammaLAmb = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaLAmb + '.value', vrayLAmbR, vrayLAmbG, vrayLAmbB , type = 'double3') cmds.setAttr(gammaLAmb + '.gammaX', float(value)) cmds.setAttr(gammaLAmb + '.gammaY', float(value)) cmds.setAttr(gammaLAmb + '.gammaZ', float(value)) #Connect gamma to ambient color cmds.connectAttr(gammaLAmb + '.outValue', selectedShader + '.ambientColor') #if the incandescence doesn't equal white or black if vrayLInc != (0,0,0) and vrayLInc !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.incandescence', destination = False): #Create gamma node. Change color and change gamma to .454 gammaLInc = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaLInc + '.value', vrayLIncR, vrayLIncG, vrayLIncB , type = 'double3') cmds.setAttr(gammaLInc + '.gammaX', float(value)) cmds.setAttr(gammaLInc + '.gammaY', float(value)) cmds.setAttr(gammaLInc + '.gammaZ', float(value)) #Connect gamma to incandescence color cmds.connectAttr(gammaLInc + '.outValue', selectedShader + '.incandescence') #VRay Car Paint if shaderType == 'VRayCarPaintMtl': #get base color RGB vrayCarBaseR = cmds.getAttr('%s.base_colorR' %(selectedShader)) vrayCarBaseG = cmds.getAttr('%s.base_colorG' %(selectedShader)) vrayCarBaseB = cmds.getAttr('%s.base_colorB' %(selectedShader)) vrayCarBase = vrayCarBaseR, vrayCarBaseG, vrayCarBaseB #print vrayCarBase #get flake color RGB vrayCarFlR = cmds.getAttr('%s.flake_colorR' %(selectedShader)) vrayCarFlG = cmds.getAttr('%s.flake_colorG' %(selectedShader)) vrayCarFlB = cmds.getAttr('%s.flake_colorB' %(selectedShader)) vrayCarFl = vrayCarFlR, vrayCarFlG, vrayCarFlB #print vrayCarFl #get coat color RGB vrayCarCoatR = cmds.getAttr('%s.coat_colorR' %(selectedShader)) vrayCarCoatG = cmds.getAttr('%s.coat_colorG' %(selectedShader)) vrayCarCoatB = cmds.getAttr('%s.coat_colorB' %(selectedShader)) vrayCarCoat = vrayCarCoatR, vrayCarCoatG, vrayCarCoatB #print vrayCarCoat #if the base color doesn't equal white or black if vrayCarBase != (0,0,0) and vrayCarBase !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.base_color', destination = False): #Create gamma node. Change color and change gamma to .454 gammaCarBase = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaCarBase + '.value', vrayCarBaseR, vrayCarBaseG, vrayCarBaseB , type = 'double3') cmds.setAttr(gammaCarBase + '.gammaX', float(value)) cmds.setAttr(gammaCarBase + '.gammaY', float(value)) cmds.setAttr(gammaCarBase + '.gammaZ', float(value)) #Connect gamma to base color cmds.connectAttr(gammaCarBase + '.outValue', selectedShader + '.base_color') #if the flake color doesn't equal white or black if vrayCarFl != (0,0,0) and vrayCarFl !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.flake_color', destination = False): #Create gamma node. Change color and change gamma to .454 gammaCarFl = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaCarFl + '.value', vrayCarFlR, vrayCarFlG, vrayCarFlB , type = 'double3') cmds.setAttr(gammaCarFl + '.gammaX', float(value)) cmds.setAttr(gammaCarFl + '.gammaY', float(value)) cmds.setAttr(gammaCarFl + '.gammaZ', float(value)) #Connect gamma to flake color cmds.connectAttr(gammaCarFl + '.outValue', selectedShader + '.flake_color') #if the coat color doesn't equal white or black if vrayCarCoat != (0,0,0) and vrayCarCoat !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.coat_color', destination = False): #Create gamma node. Change color and change gamma to .454 gammaCarCoat = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaCarCoat + '.value', vrayCarCoatR, vrayCarCoatG, vrayCarCoatB , type = 'double3') cmds.setAttr(gammaCarCoat + '.gammaX', float(value)) cmds.setAttr(gammaCarCoat + '.gammaY', float(value)) cmds.setAttr(gammaCarCoat + '.gammaZ', float(value)) #Connect gamma to flake color cmds.connectAttr(gammaCarCoat + '.outValue', selectedShader + '.coat_color') #Surface Shader if shaderType == 'surfaceShader': #get out color RGB outColR = cmds.getAttr('%s.outColorR' %(selectedShader)) outColG = cmds.getAttr('%s.outColorG' %(selectedShader)) outColB = cmds.getAttr('%s.outColorB' %(selectedShader)) outCol = outColR, outColG, outColB #print outColor #get out glow color RGB outGlowR = cmds.getAttr('%s.outGlowColorR' %(selectedShader)) outGlowG = cmds.getAttr('%s.outGlowColorG' %(selectedShader)) outGlowB = cmds.getAttr('%s.outGlowColorB' %(selectedShader)) outGlow = outGlowR, outGlowG, outGlowB #print outGlow #if the out color doesn't equal white or black if outCol != (0,0,0) and outCol !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.outColor', destination = False): #Create gamma node. Change color and change gamma to .454 gammaOutColor = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaOutColor + '.value', outColR, outColG, outColB , type = 'double3') cmds.setAttr(gammaOutColor + '.gammaX', float(value)) cmds.setAttr(gammaOutColor + '.gammaY', float(value)) cmds.setAttr(gammaOutColor + '.gammaZ', float(value)) #Connect gamma to base color cmds.connectAttr(gammaOutColor + '.outValue', selectedShader + '.outColor') #if the out glow color doesn't equal white or black if outGlow != (0,0,0) and outGlow !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.outGlowColor', destination = False): #Create gamma node. Change color and change gamma to .454 gammaOutGlow = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaOutGlow + '.value', outGlow, outGlowG, outGlowB , type = 'double3') cmds.setAttr(gammaOutGlow + '.gammaX', float(value)) cmds.setAttr(gammaOutGlow + '.gammaY', float(value)) cmds.setAttr(gammaOutGlow + '.gammaZ', float(value)) #Connect gamma to base color cmds.connectAttr(gammaOutGlow + '.outValue', selectedShader + '.outGlowColor') #Anisotropic if shaderType == 'anisotropic': #get color RGB aniColR = cmds.getAttr('%s.colorR' %(selectedShader)) aniColG = cmds.getAttr('%s.colorG' %(selectedShader)) aniColB = cmds.getAttr('%s.colorB' %(selectedShader)) aniCol = aniColR, aniColG, aniColB #print aniCol #get ambient color RGB aniAmbColR = cmds.getAttr('%s.ambientColorR' %(selectedShader)) aniAmbColG = cmds.getAttr('%s.ambientColorG' %(selectedShader)) aniAmbColB = cmds.getAttr('%s.ambientColorB' %(selectedShader)) aniAmbCol = aniAmbColR, aniAmbColG, aniAmbColB #print aniAmbCol #get incandescence RGB aniIncColR = cmds.getAttr('%s.incandescenceR' %(selectedShader)) aniIncColG = cmds.getAttr('%s.incandescenceG' %(selectedShader)) aniIncColB = cmds.getAttr('%s.incandescenceB' %(selectedShader)) aniIncCol = aniIncColR, aniIncColG, aniIncColB #print aniIncCol #get specular color RGB aniSpecColR = cmds.getAttr('%s.specularColorR' %(selectedShader)) aniSpecColG = cmds.getAttr('%s.specularColorG' %(selectedShader)) aniSpecColB = cmds.getAttr('%s.specularColorB' %(selectedShader)) aniSpecCol = aniSpecColR, aniSpecColG, aniSpecColB #print aniSpecCol #get reflection color RGB aniReflColR = cmds.getAttr('%s.reflectedColorR' %(selectedShader)) aniReflColG = cmds.getAttr('%s.reflectedColorG' %(selectedShader)) aniReflColB = cmds.getAttr('%s.reflectedColorB' %(selectedShader)) aniReflCol = aniReflColR, aniReflColG, aniReflColB #print aniReflCol #if the diffuse color doesn't equal white or black if aniCol != (0,0,0) and aniCol !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.color', destination = False): #Create gamma node. Change color and change gamma to .454 gammaAniCol = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaAniCol + '.value', aniColR, aniColG, aniColB , type = 'double3') cmds.setAttr(gammaAniCol + '.gammaX', float(value)) cmds.setAttr(gammaAniCol + '.gammaY', float(value)) cmds.setAttr(gammaAniCol + '.gammaZ', float(value)) #Connect gamma to base color cmds.connectAttr(gammaAniCol + '.outValue', selectedShader + '.color') #if the ambient color doesn't equal white or black if aniAmbCol != (0,0,0) and aniAmbCol !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.ambientColor', destination = False): #Create gamma node. Change color and change gamma to .454 gammaAniAmbCol = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaAniAmbCol + '.value', aniAmbColR, aniAmbColG, aniAmbColB , type = 'double3') cmds.setAttr(gammaAniAmbCol + '.gammaX', float(value)) cmds.setAttr(gammaAniAmbCol + '.gammaY', float(value)) cmds.setAttr(gammaAniAmbCol + '.gammaZ', float(value)) #Connect gamma to base color cmds.connectAttr(gammaAniAmbCol + '.outValue', selectedShader + '.ambientColor') #if the incandescence doesn't equal white or black if aniIncCol != (0,0,0) and aniIncCol !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.incandescence', destination = False): #Create gamma node. Change color and change gamma to .454 gammaAniIncCol = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaAniIncCol + '.value', aniIncColR, aniIncColG, aniIncColB , type = 'double3') cmds.setAttr(gammaAniIncCol + '.gammaX', float(value)) cmds.setAttr(gammaAniIncCol + '.gammaY', float(value)) cmds.setAttr(gammaAniIncCol + '.gammaZ', float(value)) #Connect gamma to base color cmds.connectAttr(gammaAniIncCol + '.outValue', selectedShader + '.incandescence') #if the specular color doesn't equal white or black if aniSpecCol != (0,0,0) and aniSpecCol !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.specularColor', destination = False): #Create gamma node. Change color and change gamma to .454 gammaAniSpecCol = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaAniSpecCol + '.value', aniSpecColR, aniSpecColG, aniSpecColB , type = 'double3') cmds.setAttr(gammaAniSpecCol + '.gammaX', float(value)) cmds.setAttr(gammaAniSpecCol + '.gammaY', float(value)) cmds.setAttr(gammaAniSpecCol + '.gammaZ', float(value)) #Connect gamma to spec color cmds.connectAttr(gammaAniSpecCol + '.outValue', selectedShader + '.specularColor') #if the reflection color doesn't equal white or black if aniReflCol != (0,0,0) and aniReflCol !=(1,1,1): #if there is no input connection if not cmds.listConnections(selectedShader + '.reflectedColor', destination = False): #Create gamma node. Change color and change gamma to .454 gammaAniReflCol = cmds.shadingNode('gammaCorrect', asUtility = True) cmds.setAttr(gammaAniReflCol + '.value', aniReflColR, aniReflColG, aniReflColB , type = 'double3') cmds.setAttr(gammaAniReflCol + '.gammaX', float(value)) cmds.setAttr(gammaAniReflCol + '.gammaY', float(value)) cmds.setAttr(gammaAniReflCol + '.gammaZ', float(value)) #Connect gamma to reflection color cmds.connectAttr(gammaAniReflCol + '.outValue', selectedShader + '.reflectedColor') #Run the Script gammaSwatches()
© 2016 Bryanna London