Repackaging Core Image Filters To Gain More Juice - Quartz Composer Tutorial

One of the quirks of working with Quartz Composer is that a significant amount of function comes from Apple made Core Image Filters.

While Core Image Filters are called on by Quartz Composer, and load into the app, they aren't actually "part" of the Quartz Composer app bundle. Furthermore, when you adjust your app's hidden preferences, by holding down the option key when you choose preferences, and then checking off the option to see private patches (or by using Kinemecore, and selecting "Show Private Patches"), one gains access to quite a few more CI filters, as well as other useful patches. However, that does not mean that they were designed with QC in mind; far from it. Quartz Composer checks for all available CI Filters at that point, and loads them into the Patch Creator (or Patch Library, if you're using 10.6). That's kind of a recipe for a clusterf... uhm, hodge podge.

These filters, especially the private/hidden filters, can be quirky in the way that they handle their maximum and minimum values. In fact, it can seem quite arbitrary and due to the nature of the code, it may have well been impossible for them to set one consistent "throw" to every filter (eg., every port having consistent available maximum and minimum values).

When choosing the Gamma filter, one can typically enter any high value right into the Power input port. Witness the picture below. (Double Click on it to see a larger view.)



The Gamma patch actually changes it's visual output even at a value as high as 30, and far past. It is still doing something to the visual output. The Gamma patch has processing "oomph" at high Power values, but it's been seemingly arbitrarily lopped off at 3.

If you're "looking" at that value in your Inspector, the second you touch the slider (or if one was to publish the value), this happens:



Maximum value reigns itself in to "3" automatically! Does adjusting the gamma value past 3 still change the visual output? Again, yes. This kind of behavior is typical of many CI filters; many times hidden ones, but public ones like Gamma as well.

Interestingly, this rarely happens to me in the context of editing compositions in this way, since I write directly in the input ports, and don't use inspectors for input. I happened to discover this behavior when publishing to root, and looking at the parameters at that level. Many patches reign themselves in to established values.

All the same, there is an extremely easy workaround; the insert splitter!

Simply create and input splitter from the patch that has irritatingly reigned itself in without asking.



As you can see, since the input is no longer a "slider type", one can put ANY minimum or maximum value in.

By default, when one creates an insert splitter off of a number port, one gets and insert splitter with "nan" as maximum and minimum values. This effectively allows you to do whatever you choose; you aren't reigned in to any limits.




So, on first inspection, with considering the value resetting quirk, one may be inclined to chain duplicate CI filters together to get "more" of the same effect. However, as long as one makes an insert splitter off of that number input, one doesn't have to worry about their values resetting. Many CI filters have throws much further than what Apple has set as the maximum or minimum. A few seconds of time checking out the filter in question will usually show if it has a throw far beyond the accepted maximum, or minimum.

If one desired, one can package the filter in a way that will allow you to always have maximum range available and then reign it in as you see fit. The first step is taking the Gamma with the insert coming off of the Power value, and publishing every input to root. Go ahead and rename the "input" off of the input splitter "Power", to reflect what one typically sees when looking at a Gamma Patch.


Next, one can install it as a new patch into Quartz Composer by installing it in one of your "Library/Graphics/Quartz Composer Patches" folders. Through placing the qtz in a "Quartz Composer Patches" folder, QC will see it, and load it, since by definition, the root of a .qtz file is a QCPatch. One will see it populate Quartz Composer on restart as a Virtual Patch. Don't install it in System/Library/Graphics/Quartz Composer Patches, unless you want it to be available to the whole system (slight chance this could cause problems, and isn't recommended).



Now you have a modded Gamma patch that appears as a single patch without the extra insert splitter; instead of quirkily shifting your maximum value around, the patch has an input that will "stick" to what you give it. If you want to give something a Gamma value of 5, instead of say, the maximum allowable of 3, you don't have chain multiple filters, which often brings down performance.

It seems like I may have written it a million times already in the past few paragraphs, but this definitely applies to other filters. Even without going so far as inserting something like this as a virtual patch, it's handy to note that simply making an insert splitter, at the very least, will lock in your desired value and not let it get reset from grabbing sliders on your Inspectors, or from publishing your values to root, unless you purposely set your own desired maximums and minimum in the Settings panel of one of the insert splitters.

I'm uploading the .qtz for the sake of example. Go ahead and install it as described above to gain access to it in your Patch List/Creator. Better yet, use this principle to save yourself time with your own favorite CI filters, if you find them exhibiting this kind of behavior, instead of driving yourself up a wall wondering what the heck is going on.