About Masks

Masking is closely related to keying. Consider keying as the process of pulling a matte, typically from a greenscreen or a bluescreen. Masking can be thought of as applying a matte to a layer or operation. There is a special section on keying – see About Keying.

There are two primary ways to consider masks in Shake. You can mask an effect, such as a color correction, or you can mask a layer so the area outside (or inside) the mask turns black. This section discusses, with a tutorial-like example, these techniques. It also discusses special cases like Filters.

bg.jpg woman_pre.iff
sign_mask2.iff car_mask.iff

 

In this process, these four elements create:

 

Not that it's an amazing masterpiece that you'd hang up on your wall next to your black velvet Elvis portrait or anything, but it helps to demonstrate both concepts of masking.

 

Masking an Effect

You can use the side input of a node to mask an effect. This applies the affect of a node only in there area where the mask exists.

Do one of the following steps:

or

 

You now have a RGrad attached as your mask input for the Brightness node:



To add your own nodes into the mask list, add a line similar these in a ui.h file:

nuiAddMaskCommand("QuickShape","QuickShape();");
nuiAddMaskCommand("QuickPaint","QuickPaint(0);");

"Huh? What's a ui.h file?"

 

 

 

 

You now have a dark background with a light spot:

 

When Not to Use a Mask

Mask inputs are useful for color corrections and transforms. They should not be used for Layer nodes. The logic is completely opposite of what you think it should be. Really. As the following example shows, even with color and transform nodes, masks should be used with caution.

 

When you apply a deep blue color, you get something like this:

 

However, there are several problems with this approach:

So, you should try a different approach:

 

This ameliorates all of the above problems. The following illustration shows the difference between the two renders. Notice that there is no blue ring around the soft part of the mask area in the right image.

 

 

:

 

 

 

 

 

Using images without an Alpha channel

A masked image doesn't need an Alpha channel. For example, JPEG files don't contain Alpha channels. If you use an image with no Alpha channel as the mask, you get no effect, since there is no mask and therefore has a value of 0.

Instead, switch the mask channel to R, G, or B in the Mask subtree to select a different channel. If you want the luminance of the image, apply a LumaKey to your mask image and leave the channel at A, or a Monochrome and select R,G, or B.

 

 

Masking a Layer

The other type of masking is to use an image as a holdout matte to cut holes in an image. The typical functions to use are Layer - Inside and Outside. Inside puts the first image only where you see white Alpha in the second image, and Outside puts the first image only where you see black in the second image's Alpha.

For example, you don't want the sign to get the brightening effect since it is in the foreground. Mask the brightened image with the sign_mask, in effect to punching a hole in the light mask with the sign mask. You can do this with Outside, so the light mask is Outside of sign_mask:

 

Outside1 KeyMix1

 

 

There is a matte line between the two masks:

 


 

Now, you can put the woman Outside of the new mask IAdd1, but you already did that sort of technique with the sign, so try a different approach. In this case, use Atop, which is similar to Over, except the foreground only appears where there is an Alpha channel on the background image.

 

If the image looks wrong, ensure that SwitchMatte1's matteMult is turned off and that invert is turned on.

 

 

Masking Filters

Filters have special masked versions of the node that not only masks off an effect, but also changes the amount of filtering based on the intensity of the second image. These take the same name as the normal Filter node preceded by an I, for example, Blur and IBlur. This is much more convincing than using the mask input.

As an example:

 

 

The right side is blurred to 200 pixels, the middle is blurred to 100 pixels, and the left edge has no blur at all.