LayerMacro

Function

This function is a macro of most of the other layering functions, but it allows you the choice to quickly select a different node, operate on specific channels, or change the foreground or background percent. Except for the channel and percent controls, there is no difference between using a normal Over node, and using LayerMacro with operation set to Over. We maintain the older functions because of both compatibility and command-line use. We have also named it the somewhat odd name of Macro because this is a temporary function that will be phased out with a new layering node in a later release.

Parameters
Type
Defaults
Function
clipMode
int
1 Toggles between Foreground (0) and Background resolution (1)
operation string "Over"

The expresssion used for each individual channel.

Possible values are:

Atop - places fg Over bg only inside of bg's mask.
IAdd - adds fg to bg.
IDiv - divides fg by bg.
IMult - multiplies fg by by.
Inside - places fg inside of bg's mask.
ISub - fg minus bg.
ISubA - absolute value of fg minus bg.
Max - takes greater pixel value of fg or bg.
Min - takes lesser pixel value of fg or bg.
Mix - mixes fg and bg by bgPercent. 0 means all fg, 100 means all bg.
Outside - places fg outside of bg's mask.
Over - places fg over bg. Default mode.
Screen - inverts both fg and bg, multiplies them together, and inverts back. This is good for reflections and glows.
Under - places fg under bg.
Xor - performs boolean to keep only non-common elements.
Foreground - returns raw fg.
Background - returns raw bg.
Modified Foreground - returns fg plus modifications of preMultiply, fgOpacity
Modified Background - returns bg plus modifications of bgPercent.

fgOpacity float 100 A fade value applied to the foreground.
bgPercent float 100

A multiplier applied to the background. It operates differently from fgOpacity:

This acts as a fade control on the following operations:
Atop, Inside, Min, Max, Outside, Over, Screen, Under and Xor.

This acts as a gain control. Therefore, if you lower the bgPercent to 0 when in IMult mode, it won't turn the entire image black. This behavior is for the following modes:

IAdd, IDiv, IMult, ISub, ISubA, Mix.

Mix: cross fade control.

 

channels string "rgba" Selects what channels are modified.
preMultiply int 0 Will pre-multiply the foreground RGB by the mask. This may also be performed explictly with a Color - MMult. This is used when you are doing an Over command on un-premultiplied elements.
addMattes int 0 This will add the two mattes together, and is generally used only with Over or Under.
useMatte int 0 This is only in effect when operation is set to Xor to use the matte or not.
ignoreZero int 0 This is active only on IDiv or IMult. When on, it will ignore any pixel in a channel with zero value.


Synopsis

image LayerMacro(
  image Foreground, 
  image Background, 
  int clipMode, 
  string operation,
  float fgOpacity,
  float bgPercent,
  string channels,
  int preMultiply,
  int addMattes,
  int useMatte,
  int ignoreZero

);


Script

image = LayerMacro( 
  Foreground, 
  Background, 
  clipMode, 
  "operation",
  fgOpacity,
  bgPercent,
  "channels",
  preMultiply,
  addMattes,
  useMatte,
  ignoreZero
);


Command Line

shake -layermacro image clipMode "operation" etc

See Also
Atop, IAdd, IDiv, IMult, Inside, ISub, ISubA, Max, Min, Mix, Outside, Over, Screen, Under, Xor