Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random opacity that varies over time?

  • Random opacity that varies over time?

    Posted by Geraint Abbott on October 8, 2008 at 11:49 am

    Hey guys,

    Just a quick question – this is probably something very simple, but I can’t get my head around it at the moment.

    I have a layer that is using a the ‘random’ expression to vary it’s opacity. However, I want this random opacity to get ‘less random’ over a set time, until it reaches a point at which it is entirely visible/the opacity is locked at a defined point.

    Does that make sense?

    So basically, at frame 0, the expression will have the effect of:
    random(0,100)

    But by frame 200, the expression will have the effect of:
    random(99,100)

    Or something similar. Is there a way to do this? If possible, I need user-definable variables for the length of transition, as well as adjustable stand and end values for the random-ness. Any help would be most appreciated!

    Many thanks,
    Geraint Abbott.

    Lukasz Pason replied 16 years, 1 month ago 4 Members · 8 Replies
  • 8 Replies
  • Eric Sanderson

    October 8, 2008 at 3:28 pm
    t = Math.exp(time)
    
    random(t,100)

    Try something like this..

  • Eric Sanderson

    October 8, 2008 at 3:32 pm
    t = timeToFrames(time)
    
    random(t,100)

    …or actually even better, this one is more literal, tacking the exact number of the frame up to 100 for the random generator.

  • Eric Sanderson

    October 8, 2008 at 3:38 pm
    t = timeToFrames(time)/2
    
    random(t,100)

    sorry, i just saw the part that you want it to be visible at 200 frames…so just divide the time by 2

  • Geraint Abbott

    October 8, 2008 at 5:22 pm

    That’s pretty cool! Thanks 🙂

    But what if I don’t want the end opacity to be 100%? I’ve tried altering the expression to say something like

    t = timeToFrames(time)/2

    random(t,50)

    And that works fine up to frame 200 – but then it goes rather odd, going more than 50% transparent after that point. I suppose I could just cut the layer and have a second one set permanently at 50% transparency starting at 200 frames in… but it would be nice to keep the number of layers down! Is that possible at all?

    Cheers,
    Geraint.

  • Dan Ebberts

    October 8, 2008 at 6:30 pm

    Try changing it to this:

    t = Math.min(50,timeToFrames(time)/2);
    random(t,50)

    Dan

  • Eric Sanderson

    October 8, 2008 at 6:31 pm
    t = timeToFrames(time)/2
    
    r = random(t,100)
    
    if(t<100){
    r
    }else{
    50}
    
    

    You can use a conditional statement(if/else)..try this.

  • Geraint Abbott

    October 12, 2008 at 7:55 pm

    Spot on!

    Thanks guys, this worked perfectly.

  • Lukasz Pason

    March 12, 2010 at 6:00 pm

    What if you want the opacity to be random but be cued not by random time but a varying number from soundkeys output?

    Motion Designer / DJ / Father
    http://www.lukaszpason.com
    http://www.krop.com/lukasz

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy