Return to Snippet

Revision: 56678
at April 9, 2012 01:28 by throb


Initial Code
def vrayAddGamma():
	import maya.cmds as cmds	
	import maya.mel as mel
	import time, os
	allFileNodes = cmds.ls(type='file') # look for file nodes
	nonFloatFiles = []
	for curFile in allFileNodes:
		
		cmds.setAttr (curFile + '.filterType', 0) # turn off the damned filtering
		fileName = cmds.getAttr(curFile + '.fileTextureName') # get the filename
		if fileName != '': # test for stupid user
			#print fileName
			fileExt = os.path.splitext(fileName)[1].lower()[1:] # get the extention
			#fileExt = fileExt.lower()[1:]
			#print fileExt
			if fileExt != 'exr' or fileExt != '.hdr': # test for hdr and exr
				nonFloatFiles.append(curFile)
				mel.eval('vray addAttributesFromGroup ' + curFile + ' vray_file_gamma 1') # add the proper vray stuff to the attribs
	time.sleep(5) # have to sleep because maya is a pain in the asssssssssss!!!
	allFileNodes = cmds.ls(type='file') # look for file nodes
	for curFile in nonFloatFiles:
		if cmds.objExists(curFile + '.vrayFileGammaEnable'):
			cmds.setAttr (curFile + '.vrayFileGammaEnable', 1) # make sure the gamma correction is enabled
			cmds.setAttr (curFile + '.vrayFileColorSpace', 2) # set it to sRGB
		else :
			print 'The attribute for VRay is not found in %s' % curFile		

vrayAddGamma()

Initial URL

                                

Initial Description
A function that adds gamma attribs to the image files that are 8 bit in nature (aka not EXR or HDR) so that you can get to a linear workflow easily

Initial Title
Add VRay gamma attributes to all 8 bit file nodes

Initial Tags
python

Initial Language
Python