I did a user group presentation yesterday on getting started with Pixel Bender. I’m pretty new to Pixel Bender, having played around with it a little bit over the course of only the last couple months. Nevertheless, I’m pretty pleased with the results of my experimentation, and I think this is largely due to two things.
First, there’s the relative ease of entry into filter writing - the basic concepts driving Pixel Bender are pretty straightforward, but don’t limit you at all. So while you can use PB to craft some really impressive effects, you can also do some pretty neat things when you’re first starting out and still in more a learning mode.
Second, Pixel Bender provides a satisfying and immediate sense of feedback. Because you have an image in front of you as you’re working on a filter, you get an immediate visual sense of how things are going. As a result, even the screw-ups - bugs in PB code can result in some pretty whacky unintended results - are motivating. I’ve written a couple of filters that I’ll probably end up putting on-line, but I have a lot more filters sitting on my hard drive that I’ve saved precisely because I made a mistake in the code somewhere. I’m saving them so I can go back and figure out what I did, because at some point in the future I may want to do intentionally what I did unintentionally.
That said, here are two of the demos from last night. The first is a comparison of execution speed of Conway’s Game of Life, first as a straight AS3 implementation, and then offloading the heavy lifting to a Pixel Bender filter. It’s a pretty good example of the speed gains Pixel Bender can provide when used for data processing.
Here’s the non-Pixel Bender version (roll over it to start it going, roll off to stop). The number in the top-right corner is the average time required to calculate the next generation of automata:
[SWF]/wp-content/uploads/Life.swf, 550, 500[/SWF]
And here’s the same version with the Life logic implemented via Pixel Bender (again, roll over to start, off to stop):
[SWF]/wp-content/uploads/LifeBender.swf, 550, 500[/SWF]
The second demo is a more straightforward visual effect. I wanted to create a “vacuum” effect, which could be animated in Flash (and/or After Effects, although I haven’t played around with the After Effects/Pixel Bender integration yet). This produced some spectacular mis-steps, I must say. You can see the working version of this below (the ship gets clip if you try the negative vacuum strength because it reaches the bounds of the image). Use the sliders underneath the image to play around with the shader parameters. As you can imagine, it’s dead simple to animate this in an ENTER_FRAME event listener.
[SWF]/wp-content/uploads/vacuum.swf, 550, 400[/SWF]
So all in all, I’m finding this pretty encouraging. I’m glad I finally took the time to dig into Pixel Bender a little bit. Now all I need to do is find more time to keep at it - and read a book or two on vector mathematics.