ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Eye-Blink Expression

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Scott Brignac
Eye-Blink Expression
on Oct 6, 2009 at 2:09:25 am

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

http://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?


Return to posts index

Dan Ebberts
Re: Eye-Blink Expression
on Oct 6, 2009 at 4:16:25 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



Return to posts index

Scott Brignac
Re: Eye-Blink Expression
on Oct 7, 2009 at 3:49:47 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?


Return to posts index


Dan Ebberts
Re: Eye-Blink Expression
on Oct 7, 2009 at 3:57:14 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



Return to posts index

Scott Brignac
Re: Eye-Blink Expression
on Oct 7, 2009 at 4:28:08 pm

Great! Got it. Thanks Dan!


Return to posts index

Connor Ryan
Re: Eye-Blink Expression
on Jul 12, 2012 at 3:04:23 pm

How could you use this expression, but make the character randomly blink twice? Thanks for your help.


Return to posts index


Dan Ebberts
Re: Eye-Blink Expression
on Jul 12, 2012 at 3:20:52 pm

I guess you could change the start of the while() loop to this:

while (time >= segEndTime && i <= 3){

Dan



Return to posts index

Navarro Parker
Re: Eye-Blink Expression
on Jun 29, 2012 at 8:00:27 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?


Return to posts index

Dan Ebberts
Re: Eye-Blink Expression
on Jun 29, 2012 at 8:25:09 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



Return to posts index


Navarro Parker
Re: Eye-Blink Expression
on Jun 29, 2012 at 8:42:44 pm

Fantastic!

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


Return to posts index

Dan Ebberts
Re: Eye-Blink Expression
on Jun 29, 2012 at 9:09:42 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



Return to posts index

Navarro Parker
Re: Eye-Blink Expression
on Jun 30, 2012 at 12:59:27 am

You knock me out, Dan! Thanks! :)


Return to posts index

Navarro Parker
Re: Eye-Blink Expression
on Jul 6, 2012 at 1:23:19 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)


Return to posts index

Dan Ebberts
Re: Eye-Blink Expression
on Jul 6, 2012 at 2:08:11 am

Each one is different for me. The only thing I can think of is that maybe you have the expression inside a precomp and you've duplicated the precomped layer.

Dan



Return to posts index

Navarro Parker
Re: Eye-Blink Expression
on Jul 6, 2012 at 6:07:24 pm

Ah! I see the problem -- I had my minSeg and maxSeg set to the same amount of time. That's what made them all blink in unison.


Return to posts index

Lewis Snook
Re: Eye-Blink Expression
on Apr 18, 2016 at 5:04:59 pm

Hi Dan,

This expressions of yours works great for me, up until I add in the fade part. As soon as I add in that part; the eye switches to fade-blinking on at random intervals, but is default set to off. I don't suppose you know how I can fix this?


Return to posts index

Lewis Snook
Re: Eye-Blink Expression
on Apr 18, 2016 at 5:10:06 pm

Never mind I have fixed it!


Return to posts index

wyclef chron
Re: Eye-Blink Expression
on Dec 3, 2014 at 3:55:13 pm

This is a great script!


Return to posts index

Ariel Guerchicoff
Re: Eye-Blink Expression
on Sep 29, 2015 at 8:03:11 pm

Thank you very much Dan, handy!


Return to posts index

diep lehung
Re: Eye-Blink Expression
on Oct 17, 2016 at 3:40:55 pm

Hi Dan.
I'm sorry if dig this topic up since it was long time ago. It is still very helpful to me.
This expression is working perfectly. I'm just wondering whether we can approaching differently without loop "while"?.
After adding lot of expression in my project, it is very slow to calculate. I'm trying to eliminate all of "while" method in the expression to reduce calculation time.


Return to posts index

Dan Ebberts
Re: Eye-Blink Expression
on Oct 17, 2016 at 4:01:39 pm

The only way I can think of to get rid of the while loop would be to be to chop the time into fixed, blink-sized chunks, and define some probability for a blink occurring in any given chunk. I'm not sure that it would seem as random, but it might work better for long comps.

Dan



Return to posts index

Lewis Snook
Re: Eye-Blink Expression
on Dec 22, 2016 at 8:37:21 am

Yeah, I've been using this expression for a while. It's great until you have a longer comp, then it can really slow down the render times and for some reason the expression takes longer to calculate the longer it is used.
So for my purposes, is there a way to make this random effect without the looping calculation (I don;t quite understand the above answer), or would I have to use an expression that has this effect (I don;t quite understand the above answer):

every 3 seconds it decides whether to blink or not.
still keeping in the fadeTime and blinkDur

And will this get rid of the loop factor that the 'while" expression brings?

Thanks


Return to posts index

Dan Ebberts
Re: Eye-Blink Expression
on Dec 22, 2016 at 5:04:19 pm

Something like this maybe:


segDur = 3; // blink once in every 3-second period
blinkDur = .25;
fadeTime = .1;
seg = Math.floor(time/segDur);
seedRandom(seg,true);
tStart = random(segDur-blinkDur);
t = time - seg*segDur;
if (t < tStart + blinkDur/2)
easeOut(t,tStart,tStart+fadeTime,0,100)
else
easeIn(t,tStart+blinkDur-fadeTime,tStart+blinkDur,100,0);



Dan



Return to posts index

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