beautypg.com

Apple Shake 4 Tutorials User Manual

Page 231

background image

Chapter 8

Working With Macros

231

1

Add the formatting for the macro body and declare the macro type and name:

image RotateBlur( )
{
Rotate1 = Rotate(0, -Rotate2.angle, 1, width/2, height/2, 0, 0.5, 0);
Blur1 = Blur(Rotate1, 200, 0, 1, "gauss", xFilter, "rgba");
Rotate2 = Rotate(Blur1, 42.61728, 1, width/2, height/2, 0, 0.5, 0);
}

Next, you need to declare the information that is passed into the macro. You can
potentially change all parameters—the rotate angle, center of rotation, motion blur
parameters, blur filter, and so on. Practically speaking, only the rotate angle and the
blur amount need to be set, giving you two sliders. You must also declare that an
image is passed into the macro to be modified. If you do not have an image, the macro
assumes that you are somehow creating a new image, such as a Ramp or ColorWheel
node. Each time you add an image input variable, an input (connection point) is
created on top of the node in the Node View (so you can plug in an image). Each time
you add a float, string, or int, a new slider or text field is created in the Parameters tab.
When you add these variables, declare the type of variable (again—either image, int,
float, or string), then the name. The names of the parameters should follow that pesky
rule mentioned earlier—the first letter in the parameter name is lowercase.

2

Add the input variables, which later become sliders or image inputs on the node:

image RotateBlur(
image input,
float angle,
float blur
)
{
Rotate1 = Rotate(0, -Rotate2.angle, 1, width/2, height/2, 0, 0.5, 0);
Blur1 = Blur(Rotate1, 200, 0, 1, "gauss", xFilter, "rgba");
Rotate2 = Rotate(Blur1, 42.61728, 1, width/2, height/2, 0, 0.5, 0);
}

3

Plug the variables into the right spot inside the macro body. Instead of the number or
word copied from Shake, use the variable name. These values are later modified with
sliders.

Substitute the variables in the macro body:

image RotateBlur(
image input,
float angle,
float blur
)
{
Rotate1 = Rotate(input, -Rotate2.angle, 1, width/2, height/2, 0, .5, 0);
Blur1 = Blur(Rotate1, blur, 0, 1, "gauss", xFilter, "rgba");
Rotate2 = Rotate(Blur1, angle, 1, width/2, height/2, 0, 0.5, 0);
}