Need help with offsetting a random expression

Hello Hivemind,

I have an expression written, albeit sloppily, that is animating a neon flickering light turning on over 10 frames. It’s attached to the transparency channel of a gmask multiplied by the mask of the letters that then feed into various glows. I’m trying to offset where the flicker begins but I’m having a bit of trouble getting the syntax right.

What I have so far is:


I like what it’s giving me and I can stretch out how long the flicker takes by changing that ‘10’ up or down depending. To alter where it starts though I’ve probably gone way to complicated with:

if(frame < 25 || frame >= 25 , 100 , (truerand(50,100)-((frame-1)*10))

But that doesn’t work the way I would anticipate. Any help would be awesome. Cheers!

Welcome to the Forum, Scott! @Sinan have you seen anything like this?

Hey Scott
I would create an animation channel under an axis - named axis_control - to turn the effect on/off and multiply this value with your main expression so keeping your main expression but
( truerand(50,100)-((frame-1)*10) ) * axis_control.position.x

Would this help keeping things under control and simpler to understand?

Let us know

1 Like

Ah also you could also insert the control axis value into:
( frame - axis_control.position.x ) but this complicates things if you want interactive control over time as the actual value of “frame” is changing every frame.

You could drop a mux node downstream of the mask and use the slip function to adjust the start of the effect.

OR . . . .
Rather than put your rand expression in the transparency channel, create a control center. I often use the matchbox “variables” for things like this. In the var01 box, enter your rand expression. In the transparency for the mask enter the expression eval(Variables.Variables.var01, frame-(Variables.Variables.var02+1)). Whatever value you put in var02 will be the start frame of the effect. Although the mux solution I outlined above is quick and dirty, it assumes that the only animation in the mask is the transparency. With the Variables solution, the slipping of the effect only affects the transparency and not any other animation functions. You could even swap out the “10” in your rand expression for var03 and use that as a controller for your duration. Note to @fredwarren : Variables.Variables.var## is WAY too verbose. We need to come up with some better expressions management and application.

Completely agree. This is why I create an axis called axis_control instead of using the rather long naming conventions of the “variable” matchbox…

I don’t see how you can avoid it. You need to point to <node_name>_<channel_hierarchy> to make sure it points to the appropriate channel and works…

I just hate the whole “dummy axis” concept. There should be an Expressions node that is just a list of expressions and the names by which they are refered to.

1 Like

We can’t avoid it. That’s why we need an overhaul of the expressions.

Another way to trigger your random function is to check for a change in a channel you want to watch for. So if the flicker should be on while an object is moving, say in the x direction you can check to see if there is a delta value there.

Let’s say you want to have the flicker on when there is a horizontal movement in axis2. Using @ytf 's variables matchbox :

your_transparency_channel =
truerand (0, 50) * Variables1.Variables.var01

Variables1.Variables.var01 =
if ( axis.position.x - eval ( axis.position.x, frame -1 ) , 1, 0 )

The last expression in human speech is:
Please check if ( the current value of the moving axis - minus its value in the frame just before it ) is zero, return 1 if there is change, and return 0 if there is no change.

So when there is movement there, your flicker will turn on…

1 Like

All good options.

Thanks guys, I’ll give it all a try. Would like to skip a mux as easy as it would be, it’s not going to teach me more about how to manipulate expressions.