AE: Omino Stamp, a Pixel Bender Filter

Early this month, we visited the San Jose Museum of Quilts and Textiles, featuring patterns and clothing by the Hawaiian designer Alfred Shaheen. Great stuff! Yeah, I have a closet full of Hawaiian shirts.

alfred_shaheen_print.jpg

(Show show goes til August 8, worth visiting. On the first Friday of the month, many of the galleries on First Street in San Jose, CA are open late, definitely a nice night out.)

Since I adore repetition, and halftoning, I got to wondering if I could recreate some of the patterns programmatically. The “Omino Stamper” filter runs in After Effects and attempts to do this.

download ==> omino_stamp.pbk, an After Effects filter.

The idea is pretty simple: draw a “stamp image” in a pattern which can be affected by the source image. It’s a little bit like a particle effect, but more mechanical.

Here’s the controls and few examples, which look nothing like Hawaiian shirts.

stamper_screenshot.png

A quick rundown:

  • The pattern- settings adjust the stamping grid
  • The stamp- settings adjust orientation and size of the stampimage image
  • The stampOverlaps setting controls how many nearby stamps are computed for each pixel; slows down the render a bit but is necessary for closely-spaced stamping. (If you see missing corners and such, increase this setting. (Those of you familiar with Pixel Bender will immediately apprehend why this is so. :)
  • The affectsStampSizeAmount, affectsStampColorAmount, and affectsStampRotationAmount settings control the halftoning features of the filter.

Here’s a basic stamp:

Next, we adjust the bricking a little, to make it less square-y:

And let the color of the underlying image affect the stamp color:

How about affect the rotation, instead of the color? Kinda wild:

Or back to basics, let the underlying image affect the stamping-size:

Here’s a festive little animation playing with the effect a bit, and does include a Tiki god or two.

WKJwCt0ik_E

click for
http://www.youtube.com/v/WKJwCt0ik_E&hl=en_US&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999

download ==> omino_stamp.pbk, an After Effects filter.

Enjoy!

AE: Short-take, Rain

Easy Rain

Here’s a cute one. Nothing deep or advanced, but it was fun. It’s a way to get a very simple and cheap “rain” in After Effects.

  1. Take a tiny bit of Noise, and blur it in one direction with Fast Blur.
  2. This makes very, very dim “streaks”. Use Threshold to make them visible again.
  3. Fast Blur it a little in both directions to make the edges smooth again.
  4. Rotate the whole layer, for angled rain.

Easy peasy!

rain1.mp4

click for
http://omino.com/pixelblog/wp-content/uploads/2010/06/rain1.mp4

Here’s the AE setup for it. Trivial! Small adjustments of the parameters can get all sorts of interesting results.

What about CC Rain?

Well you know, apart from the joy (cussedness) of doing it the hard way… CC Rain makes relatively slow well-defined rain streaks. Depending what look you like, combining CC Rain with the more random movement described above is pretty nice, too.

rain2.mp4

click for
http://omino.com/pixelblog/wp-content/uploads/2010/06/rain2.mp4

If you like, here’s the self-contained tiny AE project. ==> just_rain.aep

Omino Plugins Link Revision

Just an administrative note. I’ve got a set of free After Effects plugins available. The old web-page links were a bit confused, especially with respect to which ones work on After Effects CS3 and CS4, and which are for After Effects CS5.

The new link is http://omino.com/pixelblog/omino-ae-plugins/, and also appears as a “Page” in the blog nav column, and should be much clearer.

AE: Omino Spindala, a Pixel Bender Filter

download ==> omino_spindala_32.pbk, an After Effects filter.

Always doing things the hard way. Needed a wheel with some symmetry, like so:

How else to do it than by drawing a circle with some blobs, and then treating it with… a handwritten pixel bender kernel:

I started describing its controls, but wouldn’t it be more fun to just try it out? Below is a slightly reduced version of the Pixel Bender kernel running in Flash.

Give it a spin! Try the parameters, or click Scramble a few times, or Go, to let it choose random parameters.

spindala_for_flash.swf

click for
http://omino.com/pixelblog/wp-content/uploads/2010/05/spindala_for_flash.swf

There’s no shortage of vaguely-trippy image manglers, these days, but that’s no reason not to indulge.

AE: Omino Staragon, A Pixel Bender Filter

download: ==> omino staragon 32 <== a pixel bender filter

Just recently, Dale Bradshaw posted a rounded-rect pixel bender plugin. Pretty nifty!

It got me thinking, What about other rounded-corner polygons? It was a bit of a puzzle. As with all Pixel Bender plugins, the question is, What color is this pixel? How does a given pixel know if it’s inside a rounded-corner pentagon or not?

hex_and_star.png

I stuck to regular and stellated polygons to start. One solution goes like so:

  • Divide the plane into pie-slices, one for each edge of the polygon.
  • For each point, decide which slice you’re in.
  • Decide if you’re inside or outside the edge.
  • For the rounding… decide which corner you’re nearest
  • Are you in the arc of that corner? If so, decide if you’re inside the rounding-radius.

pentagon_pie.jpg

Well, that was a bit of obsessive fun. Here’s a screen shot, including the parameter controls:

And here’s a little demo of it.

6swtGElxOzs

click for
http://www.youtube.com/v/6swtGElxOzs&hl=en_US&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999

download: ==> omino staragon 32 <== a pixel bender filter

AE: Omino Glass, A Pixel Bender Filter

download: ==> omino glass 32 <== a pixel bender filter

There was a flurry of interest in "chromatic aberration" a while back, like here. I’d actually played with it a bit, simulating lens-effects, but only now have gotten around to weighing in on it.

The implementations I’ve seen work by splitting out your RGB and moving them around a little bit independently.

Here’s my weigh-in: Come on, people! The spectrum has more than three colors!

I find that five to seven is about right. I’ve implemented this combined with refraction into a pixel bender plugin.

omino_glass_title_card.jpg

Refraction happens when a ray of light changes its direction as it passes from one substance to another, if they have aaah, varying, that is, if they have different, um, refractive indexes. And that’s how aaah magnifying glasses work. See.

It looks like this.

The blue lines are rays of light moving up, or cast-sight-rays going down. It’s all very technical.

But I’ve got this Pixel Bender filter, right?

The filter takes in two images: a bump map (the refracting surface) and an image to view through the refraction. Here’s a bump map:

ripples.jpg

And here’s a source image:

Those chairs are known as “Chadwick Modular Seating”, from Herman Miller, designed by Don Chadwick, who later designed the Aeron chair, and that room hasn’t been that empty for, like, six years, after my girlfriend moved in and filled it up with shoes and stuff. So anyway.

And here’s the image, through the omino_glass Pixel Bender filter:

Now the fun part. Chromatic aberration happens when different colors are refracted by different amounts. Here’s the same image with just a touch of chromatic aberration applied:

Livens it up a little bit, yes?

The “flat” parts of the image, under the non-sloping parts of the bump map, appear undistored, and uncolored. But the distorted parts of the image have their colors splayed out a bit.

That’s chromatic aberration, comma, simulated.

By the way, you can get this effect in After Effects using CC Glass and overlaying multiple tinted copies, with slightly different settings for Height, and adding them back together. But that’s a lot of layers and settings to juggle; my pixel bender filter does it all in one at 32bpc instead of 8.

Here’s a test grid set with no basic refraction, and lots of chromatic aberration. This leaves the central green portion of the spectrum centered on the original image.test_grid.jpg

The inset image is the bump map.

We can see how omino_glass breaks the spectrum up into seven regions. It’s arbitrary, but I like the look.

And here’s a little demo showing the filter in motion, animated in After Effects, out on the ‘Tube.



click for
content

download: ==> omino glass 32 <== a pixel bender filter

Other chromatic aberrations of interest, from some of my favorite blogs:
ae-tuts
maltaannon
satya meka

AE: Scripting Notes

Just a quick note about a bug and an optimization when scripting After Effects CS4 (and probably earlier versions, too).

addProperty() bug

When adding several effects, each addition invalidates the object variable references to earlier ones. Here’s a code fragment which shows the problem and the solution.

var comp = app.project.activeItem;
var layer = comp.layers.addNull();
layer.name = "null_layer";

var slider1 = layer.Effects.addProperty("Slider Control");
slider1.name = "s1";

var slider2 = layer.Effects.addProperty("Slider Control");
slider2.name = "s2";

// At this point, slider2 is valid, but slider1 is mysteriously not!
// Any action or reference to slider1 will cause an "invalid object" error
//
// What can we do?
//
// Fortunately, they have names by which we can recover them

slider1 = layer.Effects.property("s1");
slider2 = layer.Effects.property("s2");

// Now they're both good to go.

setValueAtTime() Gets very slow!

If you do a whole lot of setValueAtTime() calls to set keyframes, the script will run very slowly. Fortunately, you can just call setValuesAtTimes(), the plural form, to set many at once, which is much more efficient! Makes the minutes seem like seconds, Captain.

// this will be very slow, if myData has more than a few dozen items
for(var i = 0; i < myData.length; i++)
	prop.setValueAtTime(myData[i].t,myData[i].v);

// but if we build up our arrays first...
var timesArray = new Array();
var valuesArray = new Array();
for(var i = 0; i < myData.length; i++)
{
	timesArray.push(myData[i].t);
	valuesArray.push(myData[i].v);
}
// and set them all at once
prop.setValuesAtTime(timesArray,valuesArray);

// it will go lickity-split!

(Thanks creative cow thread!)

AE: Feature Wishes

After Effects is just about my favorite software application. Very elegant model, and a clean & responsive UI.

But I think I can articulate two well-considered features that would boost its utility quite generally.

Feature Request 1: Foldering

When working with many layers, it would often be nice to group several of them together. To do this, I’d like to create a folder for them. This would help manage the grouped layers visually, and collapse to reduce them to a single line item.

You’d be able to apply effects to the folder. Maybe it’s called “groups”.

This is very similar to a precomp, of course, but you can work on the keyframes locally, instead of switching up and down the tree or using a split view.

Feature Request 2: Exportable Rigging Properties

Precomping is great, but it still doesn’t let you “rig” and “instance”. In my particular case, I’ve got two “claws” animated. They’re identical, but need to animate differently. Today, I need to duplicate the layers (either in the comp, or as separate precomps). Which is a shame, because I’d like to fiddle with the claw design, maybe later, and have my changes affect both!

So, this feature lets you expose a keyframable property on the comp, so that when it’s nested you can control it from the parent comp.

You can, if you’re overly clever, use Time Remapping to accomplish this a little bit. But I’d rather see clearly named “rigging” properties on my comp, itself, to animate.

(You could imagine also being able to add rigging properties to a folder, or maybe even any layer. This would be the same functionality as the “Slider” effect, but maybe tidier.)

As well as sliders and checkboxes, you could export “layer” properties, which pipe in a layer of the parent into the child comp. This lets you create an effect out of a comp. Presets can do this, a little bit, but in a flat, non-tweakable non-instanceable fashion.

I’ve heard one AE developer refer to a variation on this idea as a “Capsule”. The idea he described would require (I think?) you to save a comp into a separate file, before being able to reuse it. I think one of the brilliant project features of After Effects is that you get multiple timelines within one project. I like the One Big File workflow! (I wish 3d apps had this; as far as I know, they all work only on a single timeline per document.)

Miscellany

It would be nice to drop in a “reference” layer, that could repeate a different layer within the same comp to a different layer order. This would need to be post effects to be useful. It would let you perform different treatments on the same source… again, without a precomp.

It would also let your manage a folder, and still retain flexibility on its layer order.

To conclude…

After Effects is already quite strong in terms of “instancing”. That’s practically its main power. But it fails for purposes much beyond “tidiness”. “Rigging Properties” addresses this key omission.

Photoshop recently got “foldering”, and lets you set transfer mode and transparency on a group of layers. This is grand! I want it for After Effects.

AE: Projecting a Movie Onto a Complex Surface

projection_frame.jpg

This is a rendering simulating an image projected onto a simple 3d scene. There’s nothing too exotic about it, except that the projection was done in 2d, in After Effects.

And… here’s a moving sequence of the same scene. With old family movies.

stage_demo_640_dt-desktop.m4v

click for
http://omino.com/pixelblog/wp-content/uploads/2009/05/stage_demo_640_dt-desktop.m4v

The usual way you’d do this is by rendering a movie, taking it into your 3d program, and projecting it onto a scene through a light source.

For my current project, I needed this effect, but wanted a way to work in After Effects. I did this for workflow reasons: my projection content was all AE authored. But it also turns out to save render time. More than a little.

The trick was to render the scene in 3d as a coordinate-map, in Red and Green. I used Modo, and the projection mode is called “Front Projection”, from a spotlight or camera. I projected a red-green ramp onto the scene.

gradient.png

But we’re going to use the red and green values as a projection function. Changing the shader to use unattenuated (“luminous” @ 1W/steradian in modo) accomplishes this. We’re rendering geometry, not optics.

Then, I wrote a simple Pixel Bender kernel to use the red and green pixel values as coordinates to draw from the source projected image.


// by david van brink / poly@omino.com / 2009
// http://omino.com/pixelblog/
kernel rg_projection
<  namespace : "omino";    vendor : "omino";    version : 1;
   description : "uses red/green from one image to map another"; >
{
    input image4 src; // Red-green mapping image
    input image4 ref; // image to project
    output pixel4 dst;

    parameter float imageXSize;
    parameter float imageYSize;
    parameter float imageXOffset;
    parameter float imageYOffset;

    void
    evaluatePixel() {
        pixel4 a = sampleLinear(src,outCoord());
        float r = a.r * imageXSize + imageXOffset;
        float g = a.g * imageYSize + imageYOffset;

        dst = sampleLinear(ref,float2(r,g));
    }
}

To test the Pixel Bender kernel, I ran a reference grid through the red-green ramp.

test_grid_gamma.pngtest_grid_no_gamma.pngtest_grid_no_gamma_better_gradient.png

The first one shows gamma correction on the ramp image in After Effects. Under “Interpret Footage”, be sure to turn on “Preserve RGB”.

The second one reveals that Photoshop’s default ramp is some sort of s-shaped modified linear function. Creating a custom gradient with more stops along the way helped get the third, which is Good Enough. I went back and redid the scene with the improved red-green gradient.

gradient_settings.png

And of course, use 32-bit color throughout. 16-bit works ok, too. 8-bit showed definite Squarifying in the projection, though.

To reintroduce the optical nature of the projection, back in After Effects it’s multiplied by a normally rendered image and, because I still think it’s pretty neat idea, an ambient occlusion pass as well.

stage_ambient_occlusion.jpg

stage_grid_projected.jpg

And there you have it! 3d projections done all in 2d.


Download the AE Project

AE: Fake Spotlights

Here’s another variation on additive lighting tricks…

This one is a little experiment using After Effects’ spotlights on still images which have been rendered with similarly-located light sources.

Here’s one of the several still images.

And here’s a short movie showin a little more of the procedure, and some results.

spotlights.mp4

click for
http://omino.com/pixelblog/wp-content/uploads/2009/04/spotlights.mp4

« Previous entries Next Page » Next Page »