11 January 2010
Some familiarity with ActionScript 3.
Beginning
In this article, you will change a Pixel Bender filter to make it modify the colors of the source image to produce a vintage tone effect. After editing and updating the filter, you'll export the new filter for use in Adobe Flash projects. This is the second installment in this series of articles about using the Pixel Bender Toolkit to create visual effects with bitmap images.
In the previous section, you learned how to work within the Pixel Bender IDE to create a new filter, run it, and save it. In this section, you'll learn about creating a more complicated filter by writing code that controls the color values of the loaded image.
If you've been following along with Part 1 of this article series, open the filter that you created in the previous section. Otherwise, download and uncompress the sample files provided, and open the file named Exercise2FilterA.pbk.
The text displayed in the edit window will look similar to the following code example:
<languageVersion : 1.0;>
kernel Part2Filter
< namespace : "com.adobe.devnet.pixelbender";
vendor : "Kevin's Filter Factory";
version : 1;
description : "Playing around with pixels";
>
{
input image4 src;
output pixel4 dst;
void evaluatePixel()
{
dst = sampleNearest(src,outCoord());
}
}
Note: If you entered your own values for the strings in the previous section, your code may differ slightly.
The image in the preview window looks like Figure 1.
In this section, you'll edit the code slightly to affect the red color value in the input image. Follow these steps:
dst = sampleNearest(src,outCoord());
dst.r += 0.1;
void evaluatePixel()
{
dst = sampleNearest(src,outCoord());
dst.r += 0.1;
}
When you preview the image, the red channel is slightly accentuated (see Figure 2).
Choose File > Save Filter to save the filter. Name it Exercise2.pbk and save it in the pixel_bender folder on your desktop.
If you'd like to create a more dramatic effect, try the following:
After trying this experiment, the image displays the pixels with a strong red cast (see Figure 3).
Note: The default new kernel takes a four-channel image and creates a four-channel image as a result. The channels are red, green, blue, and alpha (the transparency information). Each channel is represented as a floating-point number between 0.0 and 1.0.
Follow these steps to change the blue channel in the input image:
dst.r += 0.5;
dst.b -= 0.4;
The image in the preview window appears with a noticeable reduction in the blue channel. This effect, combined with the accentuation of the red channel, results in a yellowish cast to the image (see Figure 4).
Follow these steps to update the values of the green channel in the image:
dst.b -= 0.4;
dst.g -= 0.1;
When you preview the image, the green channel in the image should be slightly reduced. This effect, combined with the modifications to the other color channels, creates a vintage-tone effect on the image (see Figure 5).
In this section, you'll learn how to set up the filter to play back in Flash Player 10. It is important to note that earlier versions of Flash Player do not support the display of filters created with the Pixel Builder Toolkit. Be sure you have Flash Player 10 (or later) installed on your machine.
Follow these steps:
Note: Flash Player 10 supports a subset of the Pixel Bender language. Be sure to read the Pixel Bender Toolkit documentation for more information.
After familiarizing yourself with the Pixel Bender interface, continue with Part 3 in this series, where you'll learn how to add parameters to filters.
Check out the following resources to learn more about working with the Pixel Bender Toolkit:
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.
Tutorials & Samples |
| 04/10/2012 | Fast Fourier Transform (FFT) in Pixel Bender? |
|---|---|
| 04/19/2012 | Shader works in toolkit, not in Flash |
| 04/12/2012 | Pixel Bender removed from AE CS6 !? |
| 03/22/2012 | Load an HDR image into Pixel Bender Toolkit |