[Closed] PreRender Script on every Frame
Since PreRender Scripts are only excuted once before rendering,
what could I do to run a script before every frame of an
animation gets calculated?
I’m using a buggy modifier, which doesn’t update correctly
in animations (only evaluated at the beginning of the render)…
Thanks, Rob
what modifier is that?
Anyway… look into the topic of “Callbacks” / “General Event Callbacks”. There are callbacks for #preRender, #preRenderFrame, #preRenderEval, etc. #preRenderEval may be the one you’re looking for, as it runs -before- the scene is evaluated.
Hi Richard,
nice to hear from you!
The MaxScript doc states: “Warning: You cannot change an object’s mesh
in a #preRenderFrame, #postRenderFrame, or any of the #beginRendering
callbacks”
It’s the Hairtrix in conjunction with its Hair Shells Modifier. I wanted
to switch one of the Hair Modifiers off and on to force re-evaluation.
Any other idea?
Best, Rob
Hi Rob
Ahh, but thankfully that warning says nothing about #preRenderEval
Try the following code…
callbacks.removeScripts id:#test
myCylinder = Cylinder smooth:on heightsegs:20 capsegs:1 sides:18 height:100 radius:20 mapcoords:on pos:[0,0,0] name:"CylinderZ"
addModifier myCylinder (Bend bendAngle:120)
callbacks.addScript #preRenderEval "$CylinderZ.modifiers[1].enabled = not $CylinderZ.modifiers[1].enabled" id:#test
…and render an animation range to watch the rod flop (please, no obvious jokes ;))
There is a possibility that the modifier in question doesn’t like being turned off and on, but that’s something you’ll find out quickly enough – but in theory, almost everything is fair game in #preRenderEval except for renderer settings, I believe.
Unfortunately, that seems not to work with mental ray or Vray.
It works with Scanline renderer as advertised.
– MartinB
Much the same for the Brazils, so no free grins here. It should point to something not being quite ‘correct’ in the third party renderers, but that callback order stuff is scary and not exactly as well-documented as it should be.
Some things are just not meant to be animated, it would seem %)
The original question may still be resolvable if there’s another way to force the modifier to re-evaluate itself beyond toggling it on/off, and just using a script controller to effect that change (although that can mean it lags a frame behind).
Are you rendering over a farm or on a local box… it’s ugly, but you could toggle that and call a Render() then move to the next frame… It’s old school, but it’ll work…
You can use the SneakerNet distribution and selected frame ranges for multiple machines.
myCylinder = Cylinder smooth:on heightsegs:20 capsegs:1 sides:18 height:100 radius:20 mapcoords:on pos:[0,0,0] name:"CylinderZ"
addModifier myCylinder (Bend bendAngle:120)
for i= 100 to 110 do
(
SliderTime = i
$CylinderZ.modifiers[1].enabled = not $CylinderZ.modifiers[1].enabled
Render()
)
Thanks guys, finally I got back to the problem and this works!
Thanks so much, Rob