
After Effects Tutorial – Auto Fade In and Out
If you create an expression to automatically fade a layer in and out, it can be efficient in the long run. This is because you’ll be able to adjust the beginning and ending times of the layer without having to adjust keyframes.
To get started, create an expression on your layer’s Opacity keyframe. Then, determine how long you want the fade to be. By setting a variable for this time, you can easily change it later if needed. For example, you can do: fadeTime =.33;
This is basically 1/3 of a second, or ~10 frames in a 29.97 composition.
Next, create a variable for the fade in and use the linear expression. The linear expression has been covered by one of my previous tutorials in 2021. It is written:
Linear(var, varMin, varMax, value1, value2)
In our case, the variable will be time because we’re looking at when a layer starts. The varMin is exactly the time the layer starts, which is written as inPoint. The varMax is when the fade should end. In our case that is inPoint+fadeTime that we set previously. Then value1 and value2 are 0 and 100, which is the starting and ending opacity.
Written out, it looks like this:
fadeIn=linear(time,inPoint,inPoint+fadeTime, 0, 100);
Next, we create a variable for the fade out and use another linear expression. Since we are dealing with the layer’s out point, we can use outPoint. The varMax in this instance is when the fade starts, or outPoint-fadeTime. Written out, it looks like this:
fadeOut=linear(time,outPoint,outPoint-fadeTime, 0, 100);
Finally, we combine the two to get the output:
fadeIn-fadeOut;
In entirety, the expression looks like this:
fadeTime =.33;
fadeIn=linear(time,inPoint,inPoint+fadeTime, 0, 100);
fadeOut=linear(time,outPoint,outPoint-fadeTime, 0, 100);
fadeIn-fadeOut;
To change the length of fade, change the numeric value .33 to whatever you desire. You can change the layer’s starting and ending points as desired and the fade will adjust accordingly thanks to the expression.
Enjoying this tutorial? Sign up for the Creative COW Newsletter!
Sign up for the Creative COW newsletter and get weekly updates on industry news, forum highlights, jobs, inspirational tutorials, tips, burning questions, and more! Receive bulletins from the largest, longest-running community dedicated to supporting professionals working in film, video, and audio.
Enter your email address, and your first and last name below!

Responses