PDA

View Full Version : Switching lights on/off between frames


jukka.alander
09-09-2008, 04:40 PM
Hello !

I'm trying to create a script that runs before each frame is rendered in an animation that would be rendered on a farm.

Script checks through all lights and sets them on/off depending on a visibility of their parents. It does work when used manually (not as callback).

Here's the code for manual usage:
for i = 1 to lights.count do (
lights[i].on = off

if lights[i].parent.visibility == true then
(
lights[i].on = on
)
)



Problem I'm facing is that it does not work when used as #preRenderFrame callback. The lights do set correctly before the first frame rendered, but not during the animation (thousands of frames) as multiple frames are rendered on a single machine.

This is what I have in prerender script:

callbacks.removescripts id:#swl

skripti = "print currentTime \n"
skripti += "for i = 1 to lights.count do ( \n"
skripti +="lights[i].on = off\n"
skripti +=" if lights[i].parent.visibility == true then (lights[i].on = on) ) \n"

callbacks.addScript #preRenderFrame skripti id:#swl


Besides #preRenderFrame I've tried #preRenderEval. #preRender cannot be used as it is only executed in the beginning of the animation..

I use VRay 1.5 and Max 2009 64-bit.

Any help would be great to have :)

Jukka

ZeBoxx2
09-10-2008, 11:01 PM
It might be that it (light, renderer, etc.) simply doesn't support animation of the on/off state of the light, much like 3ds Max doesn't want you attempting to animate the hidden/unhidden state of a node. Just as the latter has a work-around in animating the visibility instead, you could animate the light's multiplier to get an on/off switch; if you're using any features that may appear independent of the multiplier, you'd have to adjust those as well.

Kameleon
09-11-2008, 09:43 AM
Maybe it would be easier to create a script that keyframes the lights, you run it once, it turns on and off the lights as you desire and then render.

LoneRobot
09-11-2008, 10:02 AM
another option would be to put a script controller in the light multiplier and add the parent as a node, then you could use an if/then/else construct to set the appropriate light multiplier according to the visibility.

CGTalk Moderation
09-11-2008, 10:02 AM
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.