Knowing how to create a mask is essential in After Effects, but sometimes you might want to take it a step further. We can use a gradient like the one above to set the transparency of an image. The darker parts will be more see through while the lighter parts will remain the same.
(For all the engineers out there, think of how a reed switch works. As a magnet gets closer, the circuit will close. In this case, as the gradient gets darker, the image will become more transparent.)
For this tutorial, I'm going to refer to the image above. Our aim here is to fade out the image on the left using a mask so it blends better into the right side of the image. Let's get started, hmm?
Open After Effects CS5 and create a new comp. Insert the image that you want to fade.
Now go to layer > new > solid and create a solid colour of your choice.
Then go to the effects panel, type search for 'ramp,' and then drag the effect onto the solid. This converts the solid into a gradient with a new effects panel on the left side.
Tweak your gradient's settings in the effect panel. The shape of the gradient will determine how your image fades out. I want my image to only start fading out at the right edge, so I kept most of the gradient white.
Line up your gradient with the image that you want to fade out. You may have to duplicate a few layers if things get complicated.
Place your solid above the image that you want to fade out and then hide the solid. Next, select the bottom image, go to the TrkMat dropdown menu, and select "Luma Matte (X)," where X is the name of your gradient.
If you can't find the TrkMat dropdown menu, click on the Toggle Switches/Modes button.
The gradient mask should be working by this point, but maybe you'd like to improve the fading. We're going to use an additional mask with feathering to help us achieve this.
Select your solid with the gradient, and press 'g'. Start drawing a shape that you want your fade-out to follow. I wanted the image to fade out on the right edge, so I drew my mask around this point. You may need to invert the mask so the image shows up properly.
When you're satisfied with your mask, use the twirldown menu to view the mask's properties. By playing around with the feathering settings, you can tweak how the fadeout appears in the final image. If you want the fadeout to happen at a different point, just drag the mask around.
Using gradient masks is a technique that you will probably find yourself using more than once. Remember that it can be used with footage, too. Say for instance you wanted to make footage of smoke fade out after a certain point. Well, a gradient mask is perfectly suited for this goal.
Anyway, this concludes my second After Effects CS5 tutorial. Hope it helps!