Adverti horiz upsell
Internal Variables in a Simple Color Suppression Macro
Internal Variables in a Simple Color Suppression Macro
mplec, added 2005-09-17 22:22:33 UTC 29,265 views  Rating:
(3 ratings)
Page 4 of 4

So now the SimpleSuppress macro looks like this:

image SimpleSuppress(
  image In = 0,
  string suppress = "g",
  float percent = 100
    string alt_a = (suppress == "r") ? "g" : ( (suppress == "g") ? "r" : "r" );
    string alt_b = (suppress == "r") ? "b" : ( (suppress == "g") ? "b" : "g" );

    Reorder_SUPPRESS = Reorder(In, suppress + suppress + suppress);
    Reorder_Alt_A = Reorder(In, alt_a + alt_a + alt_a);
    Reorder_Alt_B = Reorder(In, alt_b + alt_b + alt_b);

    Max1 = Max(Reorder_Alt_A, Reorder_Alt_B, 1, 100);
    Min1 = Min(Reorder_SUPPRESS, Max1, 1, 100);

    Mix1 = Mix(In, Min1, 1, percent, suppress);
    return Mix1;

To finish it off, let's add a simple radio button widget to the UI.h file to make sure the suppress channel is set to something valid. Put this in your SimpleSuppressUI.h file:

nuxDefRadioBtnCtrl("SimpleSuppress.suppress", 0, 1, 1, "r|red", "g|green", "b|blue");

And there you have it. Start Shake up and feed a ColorWheel into your new SimpleSuppress node to give it a test run and verify that everything's wired up correctly. 

While this is a simple case that wouldn't have suffered too much from implementation with ColorX, more complex cases can show a noticeable improvement in rendering time when implemented with special-purpose nodes rather than ColorX, even more so when used a number of times in a large film-resolution project. You also get the benefit of caching on node outputs so only the operations that have to recompute will do so which can make updates much more interactive.