Tip of the Week - Macros

| Category: Tip of the Week | | Comments (0) | Views: 0

This week I'll be going in depth with Shake macro creation. If you're not familiar with Shake's macros, variables, or expressions, don't be dissuaded! It took me a little while to learn what I know now. Keep experimenting! Read on to see how I create macros, and how you can start to create your own as well! I originally posted a quick howto over on VFXTalk in this thread over two years ago, but everything listed should still be relevant.

User created macros, of which there are many, help artists quickly create an effect or look. In Nuke, macros are called gizmos, but aside from different names, they are similar in function. I'll be creating a macro for Shake 2.5, for the ease of you Windows users! The same techniques should be compatible in Shake 4.1 as well, with minimal changes. I will post a .shk script and the .h files at the end of the tip. You can also see other macros over at FXshare.com. Many of the macros and plugins listed are used in production houses already.

For this example, I'm going to create a glow macro, which takes in an image, and allows the user to adjust the falloff of the glow and color intensity. I've created this tool from scratch before, and have continuously updated it until development ceased when I left Tippett. The glow macro that I'm creating today will not have as many functions as the one I created for Tippett (the tool I created for them is pretty swank, and took several months of tweaking and updating to meet the artists' production standards). Many of the functions were added upon requests from comp artists there who liked the tool and it proved useful in production..

The name for the macro that I'm creating will be called DG_Glow. If you are familiar with Shake's naming conventions, you'll realise that we need two .h files, one called DG_Glow.h, and another called DG_GlowUI.h. The UI.h file is the user interface file which will describe what buttons are available in the shake interface. The UI file also calls the regular .h to do any of the image calculations. The format is MacroName.h and MacroNameUI.h. Case sensitivity is important if you want your macro to work across software platforms! dg_glow is not the same as DG_Glow. I really dislike using Shake's built in Macro creation tool, but for beginners, it's an easy way to get started. For you advanced folks that like more control, we're going to build this glow macro in a text editor and save it out as an ascii file. If you haven't already done it go through the Shake documentation and follow their procedure to create a macro, then come back and see the macro creation here.

For any node in shake, you can find out its script equivalent by simply copying the node, and pasting it into a text editor. It'll magically give you it's text based options! Cool. But first off, I'm going to build exactly what I want my macro to do in shake using nodes. Here's how it's laid out.

By cutting and pasting a blur node into a text document, we find this:
Code:

Blur14 = Blur(0, 0, xPixels, 0, "gauss", xFilter, "rgba"); // User Interface settings SetKey( "nodeView.Blur14.t", "0", "nodeView.Blur14.x", "2039.14282", "nodeView.Blur14.y", "537.5575" );

We can get rid of the User Interface settings, since we won't need them:
Code:

Blur14 = Blur(0, 0, xPixels, 0, "gauss", xFilter, "rgba");

We'll set up our macro this way, which I'll call multiblur.h with its corresponding UI called multiblurUI.h.
Code:

image multiblur( image In=0 ) { Blur1 = Blur(In, 0, xPixels, 0, "gauss", xFilter, "rgba"); return Blur1; }

As you can see I've replaced our Blur filein node with our image In and am returning our Blur1 result. We'll need to control our macro, so I'll put in a slider.
Code:

image multiblur( image In=0 shift=0 ) { Blur1 = Blur(In, shift, xPixels, 0, "gauss", xFilter, "rgba"); return Blur1; }


But how do we control our slider? We use our multiblurUI.h script!
Code:

nuiPushMenu("Tools"); nuiPushToolBox("Filter"); nuiToolBoxItem("@multiblur",multiblur()); nuiPopToolBox(); nuiPopMenu(); nuiDefSlider("multiblur.shift",0,3000,0.1);

Our slider is set up to go from 0 to 3000, via 0.1 increments. But our shift control only controls one blur! We need it to control several! So I'll add a couple more blurs in our multiblur.h file.
Code:

image multiblur( image In=0 shift=100 ) { Blur1 = Blur(In, shift, xPixels, 0, "gauss", xFilter, "rgba"); Blur2 = Blur(Blur1, shift*2, xPixels, 0, "gauss", xFilter, "rgba"); Blur3 = Blur(Blur2, shift*4, xPixels, 0, "gauss", xFilter, "rgba"); Blur4 = Blur(Blur3, shift*8, xPixels, 0, "gauss", xFilter, "rgba"); Blur5 = Blur(Blur4, shift*16, xPixels, 0, "gauss", xFilter, "rgba"); return Blur5; }

Save both these files out to the respective locations so that they'll work with shake, usually /nreal/include/startup and /nreal/include/startup/ui/, and you should be good to go!
If you're still interested in more advance macro creation, I can always do a longer tutorial with other nodes and other commands.

Leave a comment