Activity › Forums › Adobe After Effects Expressions › Opacity ON/OFF expression
-
Opacity ON/OFF expression
Posted by Sregier on July 24, 2007 at 5:25 pmI have an animated character that has a separate layer for eyes closed in order to blink. I want to use an expression that would randomly bring the opacity of this layer from 0 to 100 and back down, in order to simulate blinking.
There must be a simple expression for this. Any ideas?
Greg C neumayer replied 5 years, 8 months ago 6 Members · 6 Replies -
6 Replies
-
Lord Scales
July 24, 2007 at 11:39 pmWeel, this expression will not offer you many control, but try this Dan Ebberts script (I changed it for work in Opacity):
holdTime = .5; //time to hold (seconds)
seed = Math.floor(time/holdTime);
seedRandom(seed,true);
Math.round (random())*100More info about the script in: https://www.motionscript.com/mastering-expressions/random-1.html
-
Craig Wall
July 25, 2007 at 7:35 amThere are many more qualified to answer than me, but I’ll give it a shot.
You would use a wiggle expression.
You would set a very low frequency…so that your subject doesn’t look like he/she’s enduring an epileptic fit.
As I understand any value returned that exceeds 100% would still equate to 100% which could work to your advantage…(The opposite would be true, I believe a negative value would return 0) You could use simple multiplication or division to push your opacity to the two extremes 0 and 100.
Alternatively I wonder if you can wiggle a hold on and off.
Here is an adjustable/very flexible wiggle expression
tweak this…
wigfreq = 30; //wiggle frequency
wigamt = 30; //wiggle amount
wigdetail = .025; //detail of noise
wiggle(wigfreq, wigamt, wigdetail)What I have provided but stick around and someone will give you a more succinct and more refined answer.
-
Lord Scales
July 25, 2007 at 6:06 pmMaybe it would be better to create a Checkbox (Effect > Expression Controls > Checkbox Control) and create this expression for the eye’s opacity:
if (thisComp.layer(“Blinking control”).effect(“Checkbox Control”)(“Checkbox”) == 0) 0 else 100
Animate the Checkbox to get the blinking effect.
-
Bruno Meira
March 14, 2012 at 12:22 amits possible to do that with slider control? for control multiple comps? thanks!
-
Jay Mueller
November 9, 2016 at 2:35 pmThanks. This works great for turning on and off render intense layers will setting up the comp.
-
Greg C neumayer
August 21, 2020 at 10:57 pmThis is a pretty old post, but still valuable for expressions. Here’s a script get something to flicker/blink.
If you put the opacity at 50%, it will randomly blink on/off.
If you put two keyframes from 100 to 0%, it will transition with flickering instead of a smooth fade, like a light burning out.
If you don’t use any keyframe and set the opacity to 70%, with a flicker frequency of 100, it nicely approximates an eye blink.Cheers!
-Greg @ Antifreeze Design//--Flicker On
//Make something flicker to 100% opacity instead of fading in
//Adjust this flicker frequency to your taste
flickerFrequency = 150;op = value;
if(op > 0 && op < 100){
reverseAmt=100-transform.opacity;
wiggledAmt=wiggle(flickerFrequency,reverseAmt);
roundedAmt=Math.round((wiggledAmt/100));
roundedAmt*100;
}
//--end Flicker On
Reply to this Discussion! Login or Sign Up