PDA

View Full Version : PreRender Script on every Frame


rs3dcg
10-16-2008, 06:01 PM
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

ZeBoxx2
10-16-2008, 06:12 PM
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.

rs3dcg
10-16-2008, 06:28 PM
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

ZeBoxx2
10-16-2008, 09:42 PM
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.

martinB
10-28-2008, 05:27 PM
Hi Rob :)

Ahh, but thankfully that warning says nothing about #preRenderEval :)

[ ... ]

...and render an animation range to watch the rod flop (please, no obvious jokes ;))


Unfortunately, that seems not to work with mental ray or Vray.
It works with Scanline renderer as advertised.

-- MartinB

ZeBoxx2
10-28-2008, 06:34 PM
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).

Kramsurfer
10-31-2008, 07:59 PM
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()
)

rs3dcg
01-28-2009, 03:42 PM
Thanks guys, finally I got back to the problem and this works!

Thanks so much, Rob

CGTalk Moderation
01-28-2009, 03:42 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.