ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Random opacity on specific way

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Alekos Mazzolotti
Random opacity on specific way
on Apr 23, 2020 at 7:21:51 pm

Please, I need help with a very specific expression. I have created this screen that is going to work as part of an intro for a series of videos.



I want to make those green squares randomly sort of flicker, by changing the value of the opacity, but it must always go from 0 to 100 or from 100 to 0, across 1 or 2 seconds, which is not what happens if I just use a regular wiggle expression on the property.

The behavior I need is:

- random interval (1 to 3 seconds)
- opacity goes from 0 to 100 in 1 or 2 seconds (30 fps)
- random interval (1 to 3 seconds)
- opacity goes back from 100 to 0 in 1 or 2 seconds

I have done this manually, by adding certain keyframes and telling them to loopout. As there are too many, you can't notice it's a cycle and it gives the illusion of randomness. But I have to manually create this randomness using keyframes at different points for every layer, which can become an exhaustive processes if I intend to keep this line of work for other screens.

I already have each green square on its own layer. Is there a way to make it more automatic through the use of an expression?


Return to posts index

Dan Ebberts
Re: Random opacity on specific way
on Apr 23, 2020 at 8:21:35 pm

It sounds do-able, but it seems like there's info missing. Maybe a more detailed example would help.

Dan



Return to posts index

Alekos Mazzolotti
Re: Random opacity on specific way
on Apr 24, 2020 at 8:16:06 pm

Sure!

Here, that's what I did manually:



In this example, as I said, there is no real randomness, for I used keyframes and a loopout expression in a manner that created more or less the same effect.

Can I create this behavior via expression?


Return to posts index


Dan Ebberts
Re: Random opacity on specific way
on Apr 24, 2020 at 8:53:40 pm

This is a pretty simple version that might get you started:


minFade = .1;
maxFade = .5;
minHold = .5;
maxHold = 1.5;
minDelay = 1;
maxDelay = 1.5;
seedRandom(index,true);
myFade = random(minFade,maxFade);
myHold = random(minHold,maxHold);
myDelay = random(minDelay,maxDelay);
myStart = random(minDelay);
if (time > myStart){
myPeriod = myFade*2 + myHold + myDelay;
t =(time - myStart)%myPeriod;
if(t < myFade)
linear(t,0,myFade,0,100)
else
linear(t,myFade+myHold,myFade*2+myHold,100,0);
}else
0



Dan



Return to posts index

Alekos Mazzolotti
Re: Random opacity on specific way
on Apr 25, 2020 at 6:19:38 pm

Magnificent!

It worked perfectly. Thanks a whole lot, friend!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]