
Adobe
Pixel Bender is a graphics processing engine supported by Adobe Flash Player 10, Adobe After Effects, and Adobe Photoshop. The language is based on fragment shader languages, such as OpenGL Shading Language (GLSL), used to optimize pixel drawing operations in 3D rendering. In Flash Player, you can use Pixel Bender programs to create filters, blends, area fills, and line fills.
Pixel Bender effects can be applied to any display object, including images, vector graphics, and even digital video. The execution speed is extremely fast; effects that would have taken seconds per frame to execute in ActionScript can now be achieved in real time:
Pixel Bender programs, called kernels, are written and compiled using the Adobe Pixel Bender Toolkit. The compiled bytecode produced by the toolkit can be loaded into a Shader object and used by your SWF content. The Pixel Bender Toolkit is installed automatically when you install Flash CS4 Professional.
Documentation for using Pixel Bender in Adobe Flash CS4 Professional is available in the Programming ActionScript 3.0 chapter: Working with Pixel Bender shaders and in the ActionScript Component and Language Reference in the Shader class section. This documentation contains a detailed description of the objects you can use with Pixel Bender in Flash CS4. Documentation on the Pixel Bender language is available from the Help menu of the Pixel Bender Toolkit.
If you want to see what's possible, as well as learn some new tricks, I recommend reviewing examples of Pixel Bender programs. In addition to the examples provided in this article, you can find a public repository of kernels hosted by Adobe at the Pixel Bender Exchange. The authors of these kernel programs have kindly agreed to share them with the wider Flash developer community. Perhaps your kernel will be the next one posted? There is also a forum for discussing Pixel Bender programming.
To make the most of this article, you need the following software and files:
The examples in this article include the following projects:
The SWF content for the examples are displayed in this article. To examine the examples more closely, download the sample files and open the files in the Pixel Bender Toolkit and Flash CS4 Professional.
General experience building applications with Flash CS3 Professional or ActionScript is suggested. The examples in this article were built with Flash CS4 Professional. The code is located in Frame 1 of the layer named code. The objects to which the shaders are applied, as well as any controls, are located in the layer named "display." If you are not using Flash CS4, you can adapt the sample code by providing your own display objects and controls in ActionScript or Adobe Flex.
Charles Ward is a technical writer who enjoys figuring out new technologies. In a previous (professional) life he helped create groundbreaking computer games like Falcon 3.0 and 4.0, and Star Trek: A Final Unity. When he's not writing, Charles enjoys freediving and playing with his children.