Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions random “popping shapes”

  • Filip Vandueren

    August 14, 2009 at 5:52 pm

    The tricky part here is that you want multiple parameters to be random, but still be in sync:
    everytime the position changes, the scaling has to be triggered.

    Even using seedRandom(x,true) which yields the same random results every time, doesn’t help, because though the results are predictable within 1 expression, they are different for each property even though you use the same seed.
    (Read Dan’s 4page tutorial about random motion to get some background info first: https://www.motionscript.com/mastering-expressions/random-1.html )

    The solution: create your random numbers elsewhere and reuse them for all the properties that need to be in sync.

    I started with a 200*200px solid, and animated a lensflare to flash on and off over the course of 1 second using Flare Brightness and Opacity. It’s important that at 1 second the anim is over.
    I also added a Circle effect with feathering, and set to ‘stencil alpha’ so eventhough the flash becomes super bright, we never see the square sides of the solid. For some reason just adding a feathered Mask looks terrible.

    I then added a Point Control with this expression, adapted from Dan’s tutorial:

    segMin = .2; //minimum segment duration
    segMax = 1.5; //maximum segment duration

    end = 0;
    j = 0;
    while ( time >= end){
    j += 1;
    seedRandom(j,true);
    start = end;
    end += random(segMin,segMax);
    }

    [start,end]

    That point now holds two values: a startTime and an endTime for our random animations.

    Add this expression to the animated properties (Flare Brightness & Opacity):

    rnd=effect("Point Control")("Point");
    t=linear(time,rnd[0],rnd[1],0,1);
    valueAtTime(t);

    You now should have the Flashes Occuring at variable timings between .2 and 1.5 seconds (the values in the first two lines of the previous expression).

    Now we need the variable position, and for this we can use seedRandom like this:

    rnd=effect("Point Control")("Point");
    seedRandom(rnd[0],true);

    random([0,0],[thisComp.width,thisComp.height]);

    By again using a value of the first expression, we know it’s running in sync because it’s seed is changing everytime the flash animation restarts.

    You can use variations of that last expression in other properties as well. For example I added a Color Balance (HLS) and randomized the Hue by changing the last line to:
    random(0,360);

    and random rotation between two values like this:

    rnd=effect("Point Control")("Point");
    seedRandom(rnd[0],true);
    r1=random(360);
    r2=random(360);
    t=linear(time,rnd[0],rnd[1],r1,r2);

    After you’re okay with that single flash, you can just duplicate the layer for more.

    Endresult (over the top 😎 ):

    Comp:
    211_randomflashes.aep.zip

  • Michele Busiello

    August 17, 2009 at 9:33 am

    hi filip!

    your result looks great. but is there any way to get the same effect with shapes (rectangle, ellipses etc.) instead of a lens flare effect ?

  • Filip Vandueren

    August 17, 2009 at 11:29 am

    Of course.
    My first step was animating a lensflare efect with keyframes.
    You just animate a circle effect, or the scale of a shape layer or small solid with a mask. Whatever.
    Just set some keyframes so you have a popping shape over the course of the first second of your comp,

    then follow the other steps.

  • Michele Busiello

    August 17, 2009 at 12:57 pm

    i applied your code to the scale property of a circle-shape layer. but the result is not quite what i expected: the position is changing constantly. thats ok so far. but the scaling of the (circle) layer doesnt’t work.

  • Filip Vandueren

    August 17, 2009 at 5:12 pm

    Did you add keyframes?
    Again: add keyframes between time 0 and 1sec.
    Then apply the 1st expression to a point-control (effects->expression controls->point control),
    then apply the 2nd expression to the circle size.
    then

  • Filip Vandueren

    August 17, 2009 at 5:12 pm

    Did you add keyframes?
    Again: add keyframes between time 0 and 1sec.
    Then apply the 1st expression to a point-control (effects->expression controls->point control),
    then apply the 2nd expression to the circle size.
    then

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