AREA forums upgrade
Read more about the planned upgrade of our forums
  • 1/3
You are here: Forum Home / Autodesk® Maya® / Lighting - Rendering / [solved] Baking Self-Exclusive Ambient Occlusion to Texture Map
IMPORTANT ANNOUNCEMENT ABOUT AREA FORUMS
  RSS 2.0 ATOM  

[solved] Baking Self-Exclusive Ambient Occlusion to Texture Map
Rate this thread
 
64986
 
Permlink of this thread  
avatar
  • Total Posts: 74
  • Joined: 15 November 2010 10:46 AM

Hey guys,

I’m trying to bake my ambient occlusion as a texture map file, exactly like “Batch Bake (mental ray)” does, except excluding itself, just like “Id Nonself” does on a “mib_amb_occlusion” node.

However the command associated with “Batch Bake” seems to be using a “textureBakeSet” node which does not have any “self excluding” option.

Any ideas?

Thanks,
Kim.



Replies: 0
avatar

Got it, using “Light and Color” as “Color Mode” in the “Mental Ray Baking Options”, instead of “Occlusion” which uses some other temporary ambient occlusion shader.

I had a “Error: Invalid Color Mode” at one point but restarting Maya seems to a have fixed that. Also my ambient occlusion shader is highlighted red as if hinting that it is not working, but that didn’t matter—I am guessing this is just a warning for MentalRay nodes used in MayaSoftware render layers.

Since I’m feeling kind of foolish, here is a relevant code snipet, used to automatically generate an ambient occlusion texture file using a bake preset and a mib occlusion preset:

#
# create shading nodes
lMaterialNode cmds.shadingNode"surfaceShader"asShader True )
lOcclusionNode cmds.shadingNode"mib_amb_occlusion"asShader True )

# assign shading nodes
cmds.selectlDstMeshreplace True )
mel.eval( "hyperShade -assign %s;" %( lMaterialNode ) )
cmds.connectAttrlOcclusionNode +".outValue"lMaterialNode +".outColor" )

# load presets on shading nodes
mel.eval( "applyAttrPreset \"%s\" \"%s\" %s;" %( lOcclusionNode"mib_amb_occlusion"1.0 ) )
mel.eval( "optionVar -iv useBakeSetOverride 1;" 
mel
.eval( "optionVar -intValue textureBakeBakeAlpha 0;" 
mel
.eval( "optionVar -intValue v_mrBakeShadows 1;" 
mel
.eval( "applyPresetToNode \"\" \"convertBakeSetOptionVarToNode()\" \"convertNodeToOptionVarAndDeleteNode\" \"textureBakeSet\" 1;" )

# get pre-bake lightmap project output folder file name list
lOutputFolderPath cmds.workspaceTruedir True ) +"lightMap\\"
lFileNameList os.listdirlOutputFolderPath )

# bake lightmap
lBakeSet mel.eval( "$tmp = convertBakeSetOptionVarToNode()" )
mel.eval( "convertLightmapSetup -camera persp -sh -bakeSetOverride " +lBakeSet +" -ignoreDefaultBakeSet -showcpv;" )

# get post-bake lightmap project output folder file name list 
lFileNameList [lFileName for lFileName in os.listdirlOutputFolderPath ) if not lFileNameList.countlFileName )]
lFileName 
lFileNameList[0]
lFilePath 
lOutputFolderPath +lFileName


# get lightmap file path
print "lFilePath == %s (%s)" %( lFilePathos.path.existslFilePath ) )


Replies: 0