Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Eye-Blink Expression

  • Eye-Blink Expression

    Posted by Scott Brignac on October 6, 2009 at 2:09 am

    I found this post about how to use an expression on the opacity

    https://forums.creativecow.net/thread/227/3939#3945

    But I’d like to modify it some to make it more natural. Can I use an expression slider or add something to the expression to tweak it? I changed the time duration, but it still is too often. I basically want it to be less, but it only speeds it up or slows it down. I need the blinks to be farther apart.

    Any suggestions?

    RP Koop replied 1 year, 4 months ago 9 Members · 40 Replies
  • 40 Replies
  • Dan Ebberts

    October 6, 2009 at 4:16 pm

    Try this one. Set the range of times between blinks with the first two parameters.

    minSeg = 2.0;
    maxSeg = 5.0;
    blinkDur = .5

    seedRandom(index,true)
    segStartTime = -random(minSeg,maxSeg);
    segEndTime = segStartTime;
    i = 1;

    while (time >= segEndTime){
    i += 1;
    seedRandom(i,true);
    segStartTime = segEndTime;
    segEndTime = segEndTime + random(minSeg,maxSeg);
    }

    if (time > segStartTime + blinkDur) 100 else 0

    Dan

  • Scott Brignac

    October 7, 2009 at 3:49 pm

    Thanks so much Dan. Those parameters are great. The only issue now is that the blink is reversed. The expression is on the blink (eyes closed) layer and instead of blinking, the layer is on and his eyes open like a blink.

    What am I missing? The blink duration is .2, so shouldn’t that work?

  • Dan Ebberts

    October 7, 2009 at 3:57 pm

    Ah, OK – try reversing it:

    minSeg = 2.0;
    maxSeg = 5.0;
    blinkDur = .5

    seedRandom(index,true)
    segStartTime = -random(minSeg,maxSeg);
    segEndTime = segStartTime;
    i = 1;

    while (time >= segEndTime){
    i += 1;
    seedRandom(i,true);
    segStartTime = segEndTime;
    segEndTime = segEndTime + random(minSeg,maxSeg);
    }

    if (time > segStartTime + blinkDur) 0 else 100

    Dan

  • Scott Brignac

    October 7, 2009 at 4:28 pm

    Great! Got it. Thanks Dan!

  • Navarro Parker

    June 29, 2012 at 8:00 pm

    Hi Dan! I ran across this today and thought it was really fun.

    Instead of the blink being either 100% or 0% opacity, how would you ramp the opacity so it quickly fades on/off?

  • Dan Ebberts

    June 29, 2012 at 8:25 pm

    Something like this, probably:


    minSeg = 2.0;
    maxSeg = 5.0;
    blinkDur = .25

    seedRandom(index,true)
    segStartTime = -random(minSeg,maxSeg);
    segEndTime = segStartTime;
    i = 1;

    while (time >= segEndTime){
    i += 1;
    seedRandom(i,true);
    segStartTime = segEndTime;
    segEndTime = segEndTime + random(minSeg,maxSeg);
    }

    if (time < segStartTime + blinkDur/2)
    easeOut(time,segStartTime,segStartTime+blinkDur/2,0,100)
    else
    easeIn(time,segStartTime+blinkDur/2,segStartTime+blinkDur,100,0)

    Dan

  • Navarro Parker

    June 29, 2012 at 8:42 pm

    Fantastic!

    And I would mess with “segStartTime+blinkDur/2” to change the speed of the fade in/out, right?

  • Dan Ebberts

    June 29, 2012 at 9:09 pm

    blinkDur sets the duration of the entire blink. If you wanted to adjust the fade time separately, it would be something like this:


    minSeg = 2.0;
    maxSeg = 5.0;
    blinkDur = .25;
    fadeTime = .1;

    seedRandom(index,true)
    segStartTime = -random(minSeg,maxSeg);
    segEndTime = segStartTime;
    i = 1;

    while (time >= segEndTime){
    i += 1;
    seedRandom(i,true);
    segStartTime = segEndTime;
    segEndTime = segEndTime + random(minSeg,maxSeg);
    }

    if (time < segStartTime + blinkDur/2)
    easeOut(time,segStartTime,segStartTime+fadeTime,0,100)
    else
    easeIn(time,segStartTime+blinkDur-fadeTime,segStartTime+blinkDur,100,0)

    Dan

  • Navarro Parker

    June 30, 2012 at 12:59 am

    You knock me out, Dan! Thanks! 🙂

  • Navarro Parker

    July 6, 2012 at 1:23 am

    Ran into a stumper. If I apply the same expression to multiple layers, they all blink in unison. (which is weird, because the seedRandom(index,true) shouldn’t do that)

Page 1 of 4

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