Creating a Macro


So what is a macro for, anyway? With macros, you can combine common functions into a new function that can be used to humiliate your friends and impress your enemies. You can control what parameters are exposed, and hide the ones that don't need changing. Macros are extremely powerful ways of modifying functions to suit your own needs. In this lesson, you'll build a spiffy macro that allows you to create glows around highlights that mimic photographic auras.

Creating Macros with the MacroMaker

The MacroMaker is an interactive tool to help you create new nodes by recombining previously existing nodes. Shake's scripting language is basically C-like, meaning you have access to an entire programming language to manipulate your scripts. Because the MacroMaker can't account for all possibilities, you should think of it as a tool for helping you get started in using Shake's language: Use the MacroMaker to build the initial files, and then modify those files to customize your macros.

Note

If you need to open the premade script for this lesson, you must first complete the macro exercise for the script to function properly.


Building the Glow Tree

Before the macro can be made, we must first build the Glow tree.

1.

Highlight the neon clip and select a LumaKey node from the Key tab.

As you recall from earlier lessons, LumaKey creates a key in the alpha channels based on overall luminance. It will be used here to isolate the highlights from the neon sign.

2.

Activate the matteMult parameter.

3.

Add a Blur node from the Filter tab and set the Pixels parameter to 40.

4.

Select a Brightness node from the Color tab and set the value to 1.2.

5.

From the Layer tab, insert a Screen function.

The Screen function mimics the effect of exposing two film negatives together. It's particularly handy for reflections and luminescent elements, as it preserves the highlights.

6.

Connect another output from the neon clip to the second input of Screen1.

We have achieved glow.

Now that you have something that would be a pain in the neck to re-create, it seems like a good idea to make a macro.

7.

Drag over all the nodes except the neon node.

8.

Click Shift-M (or, using the right mouse menu, Macro > MakeMacro).

This will bring up the MacroMaker.

Creating the Macro

The top part of the window allows you to enter the name of the macro and the tab it will go in. By default, the macro is called UserMacro, and it will create a new tab called User.

1.

Change the Macro Name to Glow and press Enter.

The next line tells Shake where to store the macro. "User directory" means your local user directory. Macros stored here will be available to you only on the local machine.

2.

Make sure "User directory" is selected.

"Shake directory" means in your ShakeDirectory/include/startup directory. This will be available to everybody who opens Shake using that specific version in that specific directory. "Macro's output is" tells you what node is going to be spit out of the new macro. Shake usually makes a good guess on this, but you may need to specify it explicitly if you have selected multiple branches. In this example, Screen1 is the proper output.

The next box contains the list of parameters you want to add, the names you want to give the variables, and the default values you want to supply.

Let's go through the various nodes and change some of the values.

3.

Expand the Blur1 parameters and do the following: Change the Float xPixels parameter name to glowSize and the default value to 20, and make sure the Visibility button is on.

4.

Expand the Brightness1 parameters and do the following: Change the Float Value parameter name to glowBrightness and the default value to 1, and make sure the Visibility button is on.

5.

Expand the LumaKey1 parameters and do the following: Change the Float loVal parameter name to glowLowVal and the Float hiVal parameter name to glowHiVal, and make sure the Visibility buttons are on.

6.

Click OK when you're ready. You should have a new tab named User with a button called Glow in it.

Test the Macro

1.

Delete all nodes connected to the neon clip.

2.

Right-click the Glow icon on the User tab and choose Create.

3.

Connect the neon clip to both inputs of Glow1.

You should see four controls in the Parameter workspace.

4.

Adjust the various parameters to see their effect.

If you want to see the guts of Glow, you can expand the internal nodes that make up the macro.

5.

Highlight Glow1, right-click Node View, and choose Macro > Show Macro Internals.

6.

Drag the corners of the window to make it larger, and use the mouse buttons to reposition the nodes so that you can see them.

The nodes that make up the macro appear in the form of a tree.

7.

Close the macro window by clicking the minimize button at top right.

How to Add an Icon to the Interface

Now, I'll show you how to create a button in the user interface and attach a function to it. We're going to use the output of Glow1 to build ourselves an icon. The icons for the tabs have three qualities:

  • They measure 75x40 pixels.

  • They have no alpha channel.

  • They are saved in your icons directory as TabName.Name.nri.

Let's get started.

1.

Select Color from the Image tab and set the Res parameters to 75x40.

The Color node sets the resolution.

2.

Select an AddText node from the Layer tab.

3.

Set the fontScale to 30, type Glow in the text field, and press Enter.

4.

Change the second position parameter to 25.

5.

Add Glow from the User tab after AddText1.

6.

Connect AddText1 to both inputs of Glow2.

7.

Set the glowSize to 25 and the glowBrightness to 2.

It's looking good.

The alpha channel should be removed, so let's add a SetAlpha node.

8.

On the Color tab, add a SetAlpha node after Glow2 and set the alpha parameter to 0.

That's it. Just render it using a FileOut node from the Image tab.

9.

Select SetAlpha1 and insert a FileOut node.

10.

When the File Browser comes up, create an icon directory in UserDirectory/nreal (if you don't already have one) by using the Create Folder button in the File Browser.

11.

Type icons for the folder name and click OK.

12.

Save the image as User.Glow.nri (TabName.MacroName.nri) in the icon directory you just created.

The .nri extension stands for Nothing Real icon. (Nothing Real was the company that originally created Shake.)

13.

Right-click the FileOut node you just created and choose Render > Render FileOut Nodes from the pop-up menu.

14.

When the Render Parameters window opens, set the timeRange to 1 and click Render.

We now have the two elements that we need: the macro and the icon. We now want to place the icon into the interface. To do that, quit Shake so that you can make the necessary user interface code modifications.

15.

Quit Shake.

16.

Open the TextEdit program, located in the Applications folder.

17.

Choose File > Open and go to your UserDirectory/nreal/include/startup/ui directory.

18.

Double-click GlowUI.h.

The GlowUI.h file looks like this:

The second line tells what tab the macro will go intoin this case the User tab. The third line adds the function. The first occurrence of Glow is calling the icon file that we just created. It assumes you have matched the tab name with the filename. The next occurrence of Glow is the actual function, followed by its default values.

The @ before Glow on the third line is used if you don't want an icon; it is the default behavior when using the MacroMaker. All we need to do is remove the @, and your new icon will show up in the interface.

19.

On the third line, remove the @ before Glow and save the file.

20.

Open Shake and go to the User tab.

You will no doubt see your new icon:

Wipe that silly grin off your face.




Apple Pro Training Series. Shake 4. Professional Compositing and Visual Effects
Apple Pro Training Series. Shake 4. Professional Compositing and Visual Effects
ISBN: 321256093
EAN: N/A
Year: 2005
Pages: 156

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net