picture home | art | events | music | rack extensions | downloads | pixel blog

omino pixel blog

pixels, motion, and scripting
entries for category "after effects"
david van brink // Wed 2010.04.21 07:41 // {after effects pixel bender}

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.

download: ==> omino glass 32 <== a pixel bender filter Other chromatic aberrations of interest, from some of my favorite blogs: ae-tuts
maltaannon
satya meka

4 comments
rs // Tue 2010.05.4 01:231:23 am

Superb, thank you!

Harry Frank // Thu 2010.06.3 17:055:05 pm

Love it! I mention it in my next episode of RGTV and in a new preset I am posting for Red Giant People.

Thonbo // Fri 2010.07.2 01:251:25 am

ill try this out in flash at some point, this is great – ive been a great fan of the displacementmap filter and this add a serious take to that category

ill even try to add some lines of code to make you able to designate the starting point of the filtermap (mappoint) this is very usefull for lens effects

david van brink // Fri 2010.07.2 08:288:28 am

^ I’d love to see where you take it!

I havent tried it in Flash. (It might be necessary to restructure somewhat, I think there’s some limitations to do with function definitions in Flash vs AE Pixel Bender.)

oh, i dont know. what do you think?


david van brink // Tue 2009.08.4 17:40 // {after effects extendscript}

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!)

oh, i dont know. what do you think?


david van brink // Mon 2009.07.6 18:00 // {after effects}

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.

1 comments
Todd Kopriva // Wed 2009.08.12 23:3011:30 pm

Here’s a link to the feature-request form:
http://www.adobe.com/go/wish

oh, i dont know. what do you think?


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.

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
// https://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

2 comments
human.bin // Sun 2009.08.16 17:115:11 pm

oh my god man!

do you think this thing would work realtime in flash trough pixelbender?

AndrewYY // Tue 2009.09.1 15:343:34 pm

And to think, Maltaannon is selling this exact thing, just with more parameters.

oh, i dont know. what do you think?



Deprecated: Function the_block_template_skip_link is deprecated since version 6.4.0! Use wp_enqueue_block_template_skip_link() instead. in /home/polyomino/omino.com/pixelblog/wp-includes/functions.php on line 6114

0.0291s
(c) 2003-2023 omino.com / contact poly@omino.com