Sunday, December 7, 2008

The Joy of Displacement Mapping

Displacement mapping is an extremely useful technique to master and include in your digital effects toolbox. By displacement, we typically mean that individual pixels in the processed image are generated from different spatially modulated positions in the image. So you can think of displacement mapping as being a warp process.

A second image is used to define the spatial modulation (or displacement) of the individual pixels. This means that the modulation image's luminance is used to map to another pixel location. This mapping is the warp taking place for that pixel location in the displacement mapping process. A black modulation pixel would perform no mapping, a white modulation pixel would perform the maximum amount of spatial mapping, gray values in between would perform variable displacement from the min to max values specified for the effect.

There are a number of different ways to generate displacement mapping in Studio Artist. There's the Displacement Image Operation, which can be configured to achieve a wide range of different displacement mapping effects. You can also set the current region selection to the image you wish to modulate with, and then use the Selection Modulate options for Interactive Warp to interactively perform displacement mapping of the current canvas layer by the current selection image. You can choose translate and rotate selection modulate interactive warps.

Displacement mapping an image by itself is a useful effect. Using random noise from the Smart texture Ip Op or the Texture Synthesizer as the modulation image is another useful technique. The Texture Synthesizer has a specific Displace Effect Type that performs displacement mapping based on the texture field being generated by the texture synthesizer. The Displacement Ip Op also has Algorithm options that use uniform random noise or the texture synthesizer output as a modulation source among the many different options provided there.

The Smart Displace Ip Op is another effect that performs displacement mapping, and depending on how you configure it's adjustable parameters can achieve a wide range of different effects. There are also a number of different MSG processors that perform different kinds of displacement mapping.

I recently was asked about how i achieved the effect shown in the image above, which is a single frame from a movie test i posted on the Studio Artist User Forum. The face images in the movie appear to be made out of glass or transparent plastic in front of a colored graffiti static background.

This particular effect was actually achieved by temporal displacement mapping, which means that the face image was used to modulate into a range of different frames of a movie which consisted of a stack of graffiti images. So the displacement for a particular output pixel is being generated by movement through time in a movie as opposed to spatial movement. Temporal displacement is one of the many different Temporal Ip Ops available in Studio Artist 4. However, you can achieve a very similar effect in previous versions of Studio Artist using a more typical spatial displacement mapping in a static graffiti image.

One thing to be aware of to make this particular effect work well is to have the faces or other objects in the source movie you are processing be in front of a flat colored static background. This movie is going to be used as the modulation source for the displacement mapping. You can do this by loading your face movie into the source area. The static image you want to use as the background for the glass effect needs to be loaded into the canvas for each frame of the animation.

In version 3.5 you could use a content keyframe in the layer palette to do this. In version 4 you would use a PASeq Content Context action step. In both cases the same static background image will be loaded into the canvas current layer prior to performing the displacement mapping. The displacement mapping will be performed on the static background image in the current layer, and the source of the displacement modulation will be the source (which in our example is the face movie).

The screen snapshot below shows the face movie loaded into the source area and the editable controls for the Displacement Ip Op.

Note that the Canvas is specified for the To Be Displaced option. The Algorithm is the Fixed Angle, Ip Source Modulates Amt. And the Ip Source is set to the Source Image. So these settings specify that the source movie will displacement modulate the canvas image. The output of these displacement settings applied to a static graffiti background image in the current canvas layer is shown below. The effect created makes the source movie frame appear to be rendered as transparent glass in front of the static graffiti background.

You actually can perform a temporal displacement warp in a movie in Studio Artist 3.5. The trick is to load the movie as a pixel indexed background texture in the paint synthesizer. Pixel Indexed movie background textures index the movie for each pixel of the paint nib being rendered (as opposed to once for the entire nib for a normal movie background texture). So you can set the Paint Fill Setup Fill From option to use the background texture to paint with the modulated background texture movie. With a luminance 1D Frame Mod setting you would be modulating the background texture movie using the source luminance.

You can then use the source luminance to frame index the movie. And you can use region fill as brush pen mode with a Full Screen Generator option in the Region as Brush Mode control panel to fill in the entire canvas with a single paint step. This is a useful trick whenever you want to configure the paint synthesizer to generate effects that process the entire canvas in a single paint step.

We've barely scratched the surface of what you can do with displacement mapping. So it's worth the time to explore this technique and learn all the different things you can do with it. I often use subtle amounts of random noise modulated displacement mapping to subtly distress or age a painted canvas as a final post processing step. The best way to get a handle on this effect is to experiment yourself with different processing options and different source modulators.