Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Randomly fade up/down opacity of masks in a layer

  • Randomly fade up/down opacity of masks in a layer

    Posted by Jeff Crowe on September 23, 2020 at 7:33 pm

    So I have a basic expression that will change opacity according to a slider control. Basically as written below, as the master slider traverses 20%-30%, the layer or mask this is applied to will fade up from 0%-100%.


    transComplete = effect(“Mask Fade Controls”)(“Transition Completion”);

    linear(transComplete, 20, 30, 0, 100)

    So that works as expected, however what I’d ultimately like to do is apply this to a bunch of masks on a layer, where each one will get a random start point for its fade so that they all fade up at random times. So my first attempt at that looks like this…

    start = random(1,90);

    transComplete = effect(“Mask Fade Controls”)(“Transition Completion”);

    linear(transComplete, start, start + 10, 0, 100)

    Now if I apply this expression to all of my masks, then move the slider control back and forth between 0-100 it works just as expected. However, if I then try to keyframe the 0-100 values of the slider over time, then all of my masks flicker on/off. My assumption is because the expression is being read every frame on playback and the start variable is resetting to a new value each time through the random function. Is my thinking correct there?

    If so, I need to find a way to randomize a value once, but then keep that value constant throughout the rest of playback.

    Jeff Crowe replied 5 years, 7 months ago 3 Members · 3 Replies
  • 3 Replies
  • Trent Armstrong

    September 23, 2020 at 7:37 pm

    I’m not sure I fully understand what you’re looking for, but seedRandom() will help you set your randomness at the start of the timeline and keep that value through the duration.

    Something like this:

    seedRandom(index, true);

    r = random(0, 100);

  • Matt Volp

    September 23, 2020 at 7:44 pm

    Yeah.

    seedRandom(a,b)

    takes two arguments. a is the seed itself and b is ‘timeless’.

    If you set timeless = true, the expression won’t reevaluate every frame – I think this is what you need.

    So in summary, try this:

    seedRandom(index,true);
    start = random(1,90);
    transComplete = effect(“Mask Fade Controls”)(“Transition Completion”);
    linear(transComplete, start, start + 10, 0, 100);
  • Jeff Crowe

    September 23, 2020 at 7:47 pm

    Yeah, I may have been a bit convoluted in my description above, but that fixed it for me.

    Thanks.

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