About Compositing |
Shake's compositing nodes are located in the Layer menu. The primary nodes are Over, KeyMix, and Layer.
To demonstrate these nodes, the following elements are used:
Foreground (with mask) | Foreground Alpha (part of Foreground) | Background |
![]() |
![]() |
![]() |
The Over node places a foreground with an Alpha channel over a background.
The foreground RGB channels should be premultiplied by the Alpha channel.
Tree with Over node | Result |
![]() |
![]() |
If the image is not premultiplied, (see About Color Corrections), it can be done before the Over node with a Color - MMult, or inside the Over node itself with the preMultiply toggle.
The Layer node is identical to the other nodes, except that you can toggle between different compositing modes. Because the node will automatically be named "Layer" by default, you cannot quickly scan your tree to determine the operation type.
KeyMix, the last primary node, inputs a foreground and background and
mixes them through a third input image the mask. You can select which
channel of the third image works as the mask. You can also invert the mask and
control its intensity.
![]() |
![]() |
![]() |
As mentioned, a successful Over composite requires an Alpha channel for the foreground, and foreground RGB channels that are premultipled by that Alpha channel. 3D-rendered elements are almost always premultiplied. Scanned elements or other 2D-generated plates require an added Alpha channel (also called the matte or mask channel), which is then used to premultiply that image with the Color - MMult node. To get the necessary Alpha channel, you have several options:
In this example, the mask is drawn using the QuickShape node and copied
in as the Alpha channel for the bus with SwitchMatte. Because no color
corrections have been done, use the preMultiply toggle in SwitchMatte
to premultiply the foreground.
Tree with SwitchMatte | Bus (no Alpha) | QuickShape |
![]() |
![]() |
![]() |
Background | Premultiplied result of SwitchMatte | Over result |
![]() |
![]() |
![]() |
The bus is color corrected n this example, so preMultiply
is off in the SwitchMatte, and on in the Over.
You could also insert a Color - MMult node between Mult1
and Over2.
![]() |
![]() |
In the following example, MDiv and MMult are added
because a 3D-rendered element is color corrected. Again, you can alternatively
omit the MMult, and activate preMultiply in the Over
node.
Color Correcting | Result |
![]() |
![]() |
For an example of color correcting premultiplied elements, see the Blimp Tutorial.
|
Shake has a set of mathematical and Boolean layering operators as well. IAdd, IDiv, IMult, ISub, and ISubA add, divide, multiply, or subtract two images together. The second subtracting node, ISubA, returns the absolute value of the image. If you place a dark grey image in the first input (value .2, .2, .2) and then a white image (1, 1, 1), it will return a light grey image (.2 - 1 = -.8, take the absolute value of, returning .8, .8, .8). This is a quick way of comparing two images. The more flexible tool for generating difference mattes is the Layer - Common node, is used to isolate common or different elements between two images. The other mathematical operators are Min and Max, which return the lower or higher values of two images respectively. The Boolean operators Inside, Outside and Xor are also useful for masking images. The Inside node places the foreground image only inside of the background Alpha, Outside places the foreground outside of the background Alpha, and Xor only reveals areas that don't have a common Alpha area.
Shake contains several effect operators: ZCompose for Z-based compositing; Screen, which is used to composite light elements and preserve highlights; and Atop to place something only on the foreground. Atop is used, for example, to put a smoke element on a CG character that matches smoke in the background plate.
You can easily composite elements of any resolution. With the compMode toggle in each Layer node, you can choose foreground or background resolution as the output resolution. This applies to all layering commands. An element comped over a different sized background is a way to set your output resolution. For more information on setting resolution, jump to About Resolution.
As outlined in About Channels, you
can easily combine 1, 2, 3, 4, or 5-channel images, for example a luminance
image with an Alpha channel (2 channels) over a 5-channel image with an Over
command.
If you were stuck on a desert island and had only one Layer node, it would have to be LayerX, since it can be used to mimic all of the other functions. The math for most of the operators is included, both in general notation and in LayerX syntax. The LayerX syntax only has the expression for the red channel. You can easily extrapolate the additional equations for the other channels (for example, change r to g for the green channel).
A = foreground RGBA
B = background RGBA
Aa = foreground Alpha
Ba = background Alpha
Shake Layer Function | Commonly Used for | Math | LayerX syntax |
Atop | Add effects to foreground elements, like smoke over a CG character to match the background | A*Ba+(B*(1-Aa)) |
r2+(r*a*a2) |
Common | Difference masks | ||
IAdd | Fire effects, adding mattes together | A+B | r+r2 |
IDiv | A/B | r2==0?1:r/r2 | |
IMult | Masking elements | A*B | r*r2 |
Inside | Masking elements | A*Ba | r*a2 |
ISub | A-B | r-r2 | |
ISubA | Find the difference between elements | absolute(A-B) | fabs(r-r2) |
KeyMix | Mix two images through a third mask | A*(1-M*C)+ (B*M*C) | M stands for the percentage mix. |
Layer | Duplicate most other Layer operations | ||
Max | Combine Masks | If (A > B) then A, else B |
r>r2?r:r2 |
Min | If (A < B) then A, else B | r<r2?r:r2 or min(r,r2) |
|
Mix | Cross-fade | A*(1-Mix)+(B*Mix) | r*(1-mix)+r2*mix |
Outside | Mask elements | A*(1-Ba) | r*(1-a2) |
Over | Primary compositor | A + (B*(1-Aa)) | r+(1-a)*r2 |
Screen | Add reflections and light elements without losing highlight detail | 1-(1-A)*(1-B) | 1-(1-r)*(1-r2) |
Under | A reverse of Over | B + (A*(1-Ba)) | r2+r*(1-a2) |
Xor | Find areas that are mutually exclusive | A*(1-Ba) + B*(1-Aa) | r*(1-a2) + r2*(1-a) |
ZCompose | Z-depth composite |
If(Aa == 1) then If (Az == Bz) then ((A + (B*(1-Aa))) + B + (A*(1-Ba)) ) / 2 else If(Az < Bz) then A else B else A + (B*(1-Aa))Or in other words, if foreground Alpha doesn't equal 1, an Over is performed. Otherwise, if the Z values are not equal, the lower Z is taken. If the Z values are the same, the result is a 50 percent mix of an Over and an Under. |