In this post, you will learn how to auto fade in and out based on the layer in and out points in After Effects. Let’s dive right!
Alright, so here we are in After Effects but first let me show you what we will be creating.
Right now I have the Ukramedia logo in my timeline. The logo fades in based on the in and out points of my layer. Let me show you what I am talking about.
So right when I pass my in point, the logo fades in. Then right before I reach the out point, it
fades out.
It does not matter where you place the in or out point. It will do the exact same thing.
So let me show you how to set this up using expressions.
Step 1: Reveal the Opacity
Select the logo in here and then hit T to reveal the opacity.
As you can see the opacity percentage is lit up in red, which means I do have an expression applied.
Step 2: Get Rid of the Expression
ALT + Left Click on a PC or OPT + Left Click on a Mac on the stopwatch icon to get rid of the expression.
Step 3: Create a New Expression
Click on the stopwatch icon again to create a new expression.
Next, click on the Expression Helper -> Interpolation and I am going to select this linear expression: linear(t, tMin, tMax, value1, value2).
Where it says t, I am going to change it to say time like so:
I am going to refer to the time in my timeline from zero to whatever.
linear(time, tMin, tMax, value1, value2).
Basically, this is how it works. tMin is the starting time and tMax is the ending time. tMin is going to give me the value1 and tMax is going to give me the value2.
Now let’s change our starting time tMin to inPoint.
So when I type inPoint, what it does is it gives me the in point of my layer. It is going to be the starting time.
So I want the starting time to be zero. To do that we need to change our value1 to zero like so:
linear(time, inPoint, tMax, 0, value2).
Then at inPoint + .5 seconds, I want the opacity to be at 100%. To do that, I need to change tMax to inPoint + .5 and the value2 needs to be changed to 100. It should look like this:
linear(time, inPoint, inPoint + .5, 0, 100).
Now since the in point is working, we need to fade our logo out.
But first, let’s define our expression that we just did to fadeIn like so:
fadeIn = linear(time, inPoint, inPoint + .5, 0, 100).
Now let’s copy our expressions with the copy keyboard shortcut CTRL+C on a PC or CMD+C on a Mac.
and then paste it below with the keyboard shortcut CTRL+V on a PC or CMD+V on a MAC.
I am going to change the fadeIn to fadeOut.
fadeOut = linear(time, inPoint, inPoint + .5, 0, 100).
I will then change inPoint to outPoint. I will also subtract .5 seconds instead of adding like so:
fadeIn = linear(time, outPoint – .5, outPoint, 0, 100).
Now let’s combine them. In the next line I will say:
FadeIn – fadeOut
It should look like this:
fadeOut = linear(time, inPoint, inPoint + .5, 0, 100).
fadeIn = linear(time, outPoint – .5, outPoint, 0, 100).
FadeIn – fadeOut
Next, I am going to clean this up a little. Instead of saying .5 second in each line, I am just going to create one variable that is going to call for both of them. Let me show you how to do that.
I’m going to place our variable at the very beginning. I will say:
fadeDuration you are going to be .5 seconds like so:
fadeDuration = .5;
and then I will replace the .5 with fadeDuration like so:
fadeDuration = .5;
fadeOut = linear(time, inPoint, inPoint + fadeDuration, 0, 100).
fadeIn = linear(time, outPoint – fadeDuration, outPoint, 0, 100).
FadeIn – fadeOut
and that should do it!
I hope you found this quick tip useful. Make sure to subscribe to our email list for latest After Effects tips.