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

omino pixel blog

pixels, motion, and scripting
david van brink // Mon 2007.10.22 01:14 // {after effects}


During “art” in the first grade, I drew geometric patterns with a ruler. Mrs Weinhausen told me that real artists don’t use rulers. Unfortunately, I didn’t heed her wisdom, and now I’m stuck with the crutch of tools. And furthermore, I’m terribly lazy!

So, for better or worse, I’m hooked on scripting every little thing I can.

Suppose you want to animate an occasionally flashing light. You could just sprinkle some keyframes around flashing the intensity of a light source.

But I’m too “lazy” for that, so I script it instead. This also allows the whole thing to characterized and changed more easily. Want more flashes? Just change one value in some code, rather than re-sprinkling all the keyframes. (Of course, for complete control, you might want to time and place each flash… but I’m working in broader strokes here.)

Simple Flashing


click for

I did this in After Effects, and this post will discuss it in that context. But I’ve used the same technique in LightWave and it should apply to any moderne software.

Getting the light to flash like that is pretty easy, with the following expression on the Light:Intensity parameter:

x = lightOption.intensity;
if(random(10) < 9)
	x = 0;

So, randomly 1 time out of 10, the light is at full intensity. But there's so much further to go!

Secondary Flash


click for

This one is spiced up by adding a "secondary flash" 1 frame behind the "primary" flash. It's delivered by a second spotlight tinted dull orange. Also it moves around a bit, so the shadows aren't always in the same spot.

I'm not sure what it optically corresponds to... maybe a reflection off some moving objects in the battle zone? The orange kind-of feels like a retinal fade. But regardless, it has more complexity, and so it feels better.

There's two additional expressions involved here. The first is to have the secondary flash track the primary flash, delayed by a frame. The second is to wiggle the position of the second light source.

second lamp intensity: thisComp.layer("simple flash").lightOption.intensity.valueAtTime(time - thisComp.frameDuration) * 0.6
second lamp position: transform.position.wiggle(1,50,3,.5)

Secondary Flash With Fadeout


click for

Now we're getting tricky. And maybe a bit more garish than you'd use in a real project...

This time, the secondary flash takes a few frames to fade out. The idea is simple. If there was a flash one frame ago, issue a secondary flash. If there was a flash two frames ago, issue a dimmer secondary flash. And for three frames back, dimmer still. But implementing this with After Effects expressions turns out to be a bit complicated.

You can write expressions which look at parameters in the past or future, using .valueAtTime(someTime), but an expression can't look at it's own values of the past or future. So the trick is to use a "slider effect". This is an effect which does nothing, but includes a key-frameable slider to be used by other parts of the composition. We actually use two sliders with expressions -- one for the primary flash and one for the secondary. And then more expressions to slave the lamps to the sliders.

I'll just show the fadeout expression here; there's a link at the bottom to download the project to see it in more detail. (Remember, select all layers and press U to see all the expressions.)

x = 0;
f = 1;
for(i = 0; i < 5; i++)  // how many frames back to check
	if(effect("flash")("Slider").valueAtTime(time - i * thisComp.frameDuration) > 0)
		x += f;
	f = f * 0.75;  // fadeout per frame

And a Final Camera Trick


click for

And one last thing. I almost always add just a teeny tiny bit of camera wiggle. Again, I don't know what that means in real-world emulation. Breeze blowing on a tripod? Or animation-stand drift? I just don't know... but I like it. Loosens it up!

Download It!

The After Effects project is completely self-contained and pretty small. Download it!.

And Thanks for Reading...

This is the first post to my new pixel-oriented blog. Like it says in the introduction, I'm a nonprofessional and recreational user of pixels. I can quit any time I want, no really. Any comments or questions are most welcome. Thanks for reading.

Comments are closed.

(c) 2003-2013 omino.com / contact poly@omino.com