Cross posting from the maxscript forum on CG Talk
I've written a script that takes lighting from a skylight and bakes ambient occlusion in the (any) vertex colour channel of a mesh.
I can't seen a problem with the script, however when I first run it I always get a pure black bake on the mesh UNLESS I manually assign the bake using the Assign Vertex Colours tool in the tool panel. After this the script works perfectly. I only need to do this once per max session, I can then load any model that I want, rebuild my lighting, pretty much do anything in max and the scripted assign vertex colours works.
The (stripped down) command to assign the colours is simple enough:
AssignVertexColors.ApplyNodes $ vertexPaint:$.modifiers[#VertexPaint]
Can anyone help me understand why I need to manually run the bake once per session? Is it just a max foible?
Replies
http://www.scriptspot.com/3ds-max/pits-peaks
the order of things is something like this:
hope that snippet gets you further
I don't bake to a texture, I bake the AO into a vertex colour channel.
I think it's just an initialisation thing, because after I manually assign the vertex colours once to any mesh in the scene the script works perfectly after that, and works until I next open max.