# Sean Dooley # 22 February 2012 # http://www.smdooley.com # http://smdooley.com/Extras/Python/FGScripts/fgwalkthrough.html # http://smdooley.com/Extras/Python/FGScripts/fgscripts.html # - This script is run to set up the building of the FG map to expidite render times. # - The default values for this definition set Maya to create a FG map from the start frame # to the last frame going through every frame. # - You do not need to set the render type to render FG only, my script makes all the necessary # changes for you and resets the render method back at the completion of the script. # ---------------------------------------------------------------------------------------- # If you want to change the root name of the FG map, change the fgRoot when calling fgBake() # This script has commented out some default suggested values for FG sample quality # *** as a suggested place to start. [ lines32-34 ] # ---------------------------------------------------------------------------------------- from pymel.core import * import maya.cmds def fgBake(first=playbackOptions(query=True, min=True), last=playbackOptions(query=True, max=True), incr=1, cam='camera1', fgRoot='fgmap_single_'): maya.cmds.setAttr('mentalrayGlobals.renderMode', 3) # sets Render Mode to "FG Only" maya.cmds.setAttr('miDefaultOptions.finalGatherRebuild', 0) # sets Rebuild to "Off" i = first while i < (last + 1): currentTime(i) print("Rendering FG Point Cloud for Frame: %s" % (i) ) print("FG Map: %s%03d.fgmap" % (fgRoot, i) ) maya.mel.eval('setAttr -type "string" miDefaultOptions.finalGatherFilename "%s%03d.fgmap;"' % (fgRoot, i) ) # maya.cmds.setAttr('miDefaultOptions.finalGatherRays', 150) # maya.cmds.setAttr('miDefaultOptions.finalGatherPresampleDensity', 15) # maya.cmds.setAttr('miDefaultOptions.finalGatherPoints', 100) maya.cmds.Mayatomr(preview=True, camera=cam) i += incr print("Returning render settings to Normal render mode and to Freeze the FG Map rebuild.") maya.cmds.setAttr('mentalrayGlobals.renderMode', 0) # sets Render Mode to "Normal" maya.cmds.setAttr('miDefaultOptions.finalGatherRebuild', 2) # sets Rebuild to "Freeze"