[Closed] Vertex paint AO baker – always fails on first run
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 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.
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?
Rick
I wrote a tool also myself to do that. And yes that command from what i’ve used and searched is broken.
If you just need to assign AO check out this plugin
http://www.zhangy.com/main/index.php?module=documents&JAS_DocumentManager_op=viewDocument&JAS_Document_id=27
Can use your GPU if you have an 8series or higher nvidia, and is bloody fast and easy to use.
After some testing today I might have tracked it down to our custom shaders.
That link is very useful though, thanks for that!
It’s a known bug in max. VertexPaint modifier doesn’t really update “Lighting Model” till user presses “assign” button. It’s why “AssignVertexColors.ApplyNodes” doesn’t work for first use.
So, if the button must be pressed just do it …
fn pressAssignVColor = if getCommandPanelTaskMode() == #modify and iskindof (modpanel.getCurrentObject()) VertexPaint do
(
name = "Assign"
if (win = windows.getChildHWND #max "Assign Vertex Colors") != undefined do
(
if (bt = windows.getChildHWND (UIAccessor.GetParentWindow win[1]) name) != undefined do
(
UIAccessor.PressButton bt[1]
)
)
)
Sorry to bring this old thread up, but I can’t get that last function to work. Even when the current modifier is an Vertex Paint, and I run the function, it just gets undefined and does nothing.
I’m running max 2010, not sure if that matters?
thanks!
I tested my function on max 2010. It works.
fn pressAssignVColor = if getCommandPanelTaskMode() == #modify and iskindof (modpanel.getCurrentObject()) VertexPaint do
(
name = "Assign"
if (win = windows.getChildHWND #max "Assign Vertex Colors") != undefined do
(
if (bt = windows.getChildHWND (UIAccessor.GetParentWindow win[1]) name) != undefined do
(
UIAccessor.PressButton bt[1]
format "pressed: %
" bt
)
)
)
after running the function you have to see at least printed line in Listener (pressed: #(…)).
After calling the function I get,
pressAssignVColor()
undefined
OK
in the listener
I have a box, with a VertexPaint applied, with the mod panel open. I copy and pased your function, then right after did pressAssignVColor();. Am I calling it wrong? I also tried just evaluating the function without the pressAssignVColor();, and it did nothing… Sorry if this is a noob mistake…
-Matt
I need to see print. Run debug version:
fn pressAssignVColor =
(
format "modify mode: %
" (getCommandPanelTaskMode() == #modify)
format "vertex paint: %
" (iskindof (modpanel.getCurrentObject()) VertexPaint)
if getCommandPanelTaskMode() == #modify and iskindof (modpanel.getCurrentObject()) VertexPaint do
(
name = "Assign"
if (win = windows.getChildHWND #max "Assign Vertex Colors") != undefined do
(
if (bt = windows.getChildHWND (UIAccessor.GetParentWindow win[1]) name) != undefined do
(
UIAccessor.PressButton bt[1]
)
)
format "rollout: %
button: %
" win bt
)
ok
)
This is odd… So I tried it, and that worked :D. But then it only worked a few times, then stopped working, and now it just says
pressAssignVColor()
modify mode: true
vertex paint: true
rollout: undefined
button: undefined
OK
OK
Even when the mod panel is open and whatnot. Do I need to set those variables to undefined after for the keys or something to fix it?
Ok… after reading and testing some stuff from the windows Structure section, I found out that it didn’t work because you are using #Max, which only works if my command panel is docked in the main window. But I work with my off in my other screen, and that’s why it wasn’t working…
So I have to see if I can modify it to fix that.