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.
First apply a Color - Brightness node to the car_bg image to start creating the spotlight effect.
Do one of the following steps:
Create a RGrad and drag its output to the M input knot on the side of the Brightness node.
or
You now have a RGrad attached as your mask input for the Brightness node:
nuiAddMaskCommand("QuickShape","QuickShape();"); |
![]() |
![]() |
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.
:
![]() |
![]() |
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.
Therefore, use Layer - SwitchMatte to copy the Alpha channel from IAdd1 to KeyMix1
Invert the mask in the SwitchMatte parameters (since Atop only composites where there is white in the background Alpha mask)
Turn off matteMult
Put the woman image Atop the SwitchMatte node:
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:
Create a Text node and scale the text so that it fills the frame.
Now create a Ramp, and ensure the alpha1 parameter is set to 0.
Attach a Blur node and crank it up to 200 pixels and mask it off with the Ramp. It should look bad, rather like this. You can see that the right side of the image merely mixes the completely blurred image with the non-blurred image:
![]() |
![]() |
Instead, switch the Blur to IBlur (select Blur1 in the Node View and Ctrl+click on IBlur) and take the Ramp from the mask input into IBlur1's second image input.
Set the blur value to 200 pixels:
![]() |
![]() |
The right side is blurred to 200 pixels, the middle is blurred to 100 pixels, and the left edge has no blur at all.