Bake Light and Shadows with python

Bake Light and Shadows with python

mfontan9
Participant Participant
804 Views
2 Replies
Message 1 of 3

Bake Light and Shadows with python

mfontan9
Participant
Participant

Hi all,

I would like to bake the Ambient Occlusion to vertices with python, I probably missing something cause once I execute it, it just erases my previous Ambient Occlusion and keep it blank.

 

the code:

def bakeAO():
    node_ptrs = vrNodeService.getSelectedNodes()
    
    # illuminationBakeSettings
    illuminationBakeSetting_ptr = vrdIlluminationBakeSettings()
    
    illuminationBakeSetting_ptr.setAmbientOcclusionMaximumDistance(3000.0)
    illuminationBakeSetting_ptr.setAmbientOcclusionMinimumDistance(1.0)
    illuminationBakeSetting_ptr.setAmbientOcclusionWeight(vrBakeTypes.AmbientOcclusionWeight.Uniform)
    illuminationBakeSetting_ptr.setColorBleeding(False)
    illuminationBakeSetting_ptr.setDirectIlluminationMode(vrBakeTypes.DirectIlluminationMode.AmbientOcclusion)
    illuminationBakeSetting_ptr.setIndirectIllumination(False)

    # textureBakeSettings
    textureSetting_ptr = vrdTextureBakeSettings()
    
    vrBakeService.bakeToTexture(node_ptrs, illuminationBakeSetting_ptr, textureSetting_ptr, replaceTextureBake=True)

bakeAO()

 

the default settings I tried to reproduce:

 

the settings intended...the settings intended...

 

Thank you for your help.

0 Likes
Accepted solutions (1)
805 Views
2 Replies
Replies (2)
Message 2 of 3

michael_nikelsky
Autodesk
Autodesk
Accepted solution

The old vertex baking is currently not exposed in the new python API, you will have to use the vrAmbientOcclusion Module of the Python V1 API. The BakeService currently is only for texture baking.



Michael Nikelsky
Sr. Principal Engineer
0 Likes
Message 3 of 3

mfontan9
Participant
Participant

Alright, it's confusing, but you saved my day!
Thank you @michael_nikelsky !

0 Likes