View Full Version : Another Flickering Light Question
06-15-2007, 05:28 PM
Hi Guys, I know this supject has been dicussed here several times, But i got an question concerning it. I want to make a volume light that is flickering. So i used the rand function to create the flicker:
volumeLightShape1.intensity = rand(0,5)
The problem I have now is, that the frequency of the flicker is way to high since it changes the value every frame.
Is there a way to change it so, the rand-function changes the value for example every 5th frame.
I'm not very familiar to MEL so I don't know how I could script this
Help would be appreciated
06-15-2007, 07:21 PM
Quick and Dirty MEL Script:
int $step = 5;
float $AnimStart = `playbackOptions -q -min`;
float $AnimStop = `playbackOptions -q -max`;
float $OrigRange = ($AnimStop - $AnimStart) + 1;
for ($i=0; $i < $OrigRange; $i+=$step)
setAttr directionalLightShape1.intensity (rand(0,1));
In Step you can set the frameoffset..
// Done a mistake...I'm skipping the time as well so forget the script..
// to much stuff in my brain....ughh..
06-18-2007, 07:02 AM
well, you could always check out noise instead of rand, it produced a smooth transition between random values.
06-18-2007, 08:27 AM
Thank you both very much for your replies.
Don't know about noise. It seems to generate value and keeps the same all the time.
06-18-2007, 08:56 PM
Here, try this -
volumeLightShape1.intensity = noise(time)*2.5+2.5;
noise is much like sine cosine and tangent, it's from -1 to 1, so if you multiply it by 2.5 and add 2.5 it will be out of 0 and 5, it will smoothly move from one number to another. You can always multiply time by something to make the flicker move much faster or slower if you want.
06-18-2007, 09:46 PM
In my website you got a script that might help out.
3D+ => Maya => MEL => "*Light Flicker"
06-21-2007, 07:19 PM
Hi Guys, thank you again for your quick replies. I'm going to try it as soon as I'm back at my office.
06-21-2007, 07:19 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.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.