Displacement mapping is one of the lesser-known techniques in Adobe After Effects that can create all sorts of fascinating and practical distortion effects with your footage. In this tutorial, we're going to introduce to the basics of displacement mapping and show you how to get started with it.
We're going to be working with two simple elements: our macProVideo.com logo and some stock footage of rippling pool water. The idea here is to create the illusion of the logo painted on the bottom of the pool and being distorted by the motion of the water, just as it would be in real life. So, after importing the logo and footage files into a new project, begin by creating a new composition the size and length of the pool footage by just dragging the water footage clip onto the 'Create A New Composition' button at the bottom of the Project window:
Next we want to just drop the macProVideo.com logo (which I've prepared with an alpha channel so it has a transparent background) on top of the water layer in the Pool composition and center it, either by dragging it directly into the Comp window, or into the Layer window in the Timeline.
At this point, the logo doesn't look like it's underwater, but rather floating on the water's surface. So, next we're going to apply a Blending Mode to the logo so it interacts with the water image and looks like it's at the bottom of the pool. When you apply a Blending Mode to a layer, the pixels in that layer interact with the pixels in the layer immediately below it to create new colors and transparencies in the pixels in the upper layer. There are many different Blending Modes, and many different ways the two layers can interact with each other. For now, all you need to know is that a Blending Mode will help us integrate the logo layer with the water in such a way that the logo will appear to be below the water's surface, while still remaining visible.
So, to apply the Blending Mode, click the 'Toggle Switches/Modes' button at the bottom of the Layer window to display the Modes column, then click the 'Blending Modes' popup menu next to the Logo layer to show the various Modes. The ones we're interested in are in the Additive category, the third group in the list, and specifically we're going to choose Color Dodge:
The Additive modes tend to make the brighter pixels of the two layers visible, while retaining the color of the upper layer to varying degrees. In this case, Color Dodge seems to maintain the original color of the logo well, while allowing the brighter pixels of the water ripples to show through, creating the illusion of the logo being below the water surface. Of course, you should try the other Additive modes, and even modes in other categories, both just to see what they look like and to determine if one of them might work better with your particular logo. Here's what the Color Dodge mode looks like.
Now that we have our logo in place and properly blended, we're going to displace it so it look like the water ripples are distorting the image. Displacement mapping works by taking the brightness (or luminance) values of the pixels in one layer'"called the displacement map'"and using those values to physically shift, or displace, the position of the pixels in the affected layer. Greater luminance values create a greater shift than lower values, as you'd expect. In our case, we want to use the luminance of the water layer to distort the logo layer: as the water moves, the shifting luminance values will make the logo appear as if it's being distorted by the water, as it would in reality.
So, with the logo layer selected, choose Effect > Distort > Displacement Map. By default, the Displacement Map effect uses the layer to which it's applied as the Map layer, which doesn't do us much good. Instead, we want to use the water layer, so click on the Displacement Map Layer menu in the 'Effect Controls' window and choose the water layer. We also want to set the water layer's luminance for both the Horizontal and Vertical displacement, and we want to increase the maximum displacement to 20 or so, for a little greater distortion (you should of course tweak all these settings to see how they affect the final image). Your Displacement Map effect settings should look like this:
Your logo movie should look something like this:
And that's basically how it works. Now, as you can see, this is a pretty cool effect, but the logo itself is rather rough-edged, and doesn't much look like it's underwater. That's because the water layer has a lot of contrast and abrupt transitions between its bright and dark pixels, which tends to create that roughness in the displaced image. There's an easy way to fix that though, which we'll do next.
To fix the rough edges, we need to use a softer version of the water layer as our displacement map, which we'll do by blurring it. But we don't want to blur the visible water layer, so we'll blur a copy and use that for our map instead. Duplicate the water layer in the Timeline by selecting it and typing Command-D.
Next, select the upper of the two existing water layers in the Layer window and choose Effect > Blur & Sharpen > Gaussian Blur. Set the Blurriness to 20 or so to soften the water nicely.
Now at this point if we use this blurred layer as the displacement map, we won't actually see any difference in the final image. That's because the blurred layer needs to be pre-composed, or virtually rendered, before the Displacement Map effect will "see" the blur. So, select the blurred layer, and choose Layer > Pre-compose. In the Pre-compose dialog, call the new composition WaterDisplaceMap (or anything appropriate to distinguish it from the original water layer), and choose the option to 'Move all attributes into the new composition'.
Now, we don't actually want to see the blurred image, so turn off its visibility by clicking the eyeball button next to its name in the Layer window; as long as it's pre-composed, it doesn't have to be visible for the Displacement Map effect to use it. Then select the logo layer again and set the WaterDisplaceMap layer as the Displacement Map Layer in the Effect Controls window. You'll see a much smoother and more realistic distortion effect on the logo that follows the water ripples:
And there you have it. Experiment with reducing the opacity of the logo layer a little to make it look a little more underwater, try different Blending Modes on the logo, or apply a little blur to defocus the logo slightly. And as always, have fun!