Well, I had this really nice explanation and quick tutorial about how I create my macros, but of course, mozilla crashes on me, and I lose it all!! So now I'm writing this in a text doc before I submit the post, so this will be complete.
I'm not sure how much more shake scripting you have tried since your last post, but here's how I create mine.. Macros are just bundled scripts, so you can cut and paste nodes from shake into a text document, and you'll see what the actual node is doing! For example, let's say we wanted to create a macro that blurs successively and uses one slider to control all of them. A quick way to do this is attach several blurs in a row in shake and hit Create Macro. How boring and simple. Let's do it the hard way.
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.