Effects with the Pixel Bender Toolkit – Part 2: Creating a vintage tone filter
来源:互联网 发布:python 自动化 编辑:程序博客网 时间:2024/04/30 09:15
Requirements
User level
Beginning
Required products
Sample files
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.
Setting up the files
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.
Modifying the red channel of the image
In this section, you'll edit the code slightly to affect the red color value in the input image. Follow these steps:
- Locate the line shown below:
dst = sampleNearest(src,outCoord());
- Immediately after the line shown above, add a new line and type the following code:
dst.r += 0.1;
- After making these changes, the evaluatePixel function will look like this:
void evaluatePixel() { dst = sampleNearest(src,outCoord()); dst.r += 0.1; }
- Click the Run button to run the filter.
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:
- Change the amount added to the red channel from 0.1 to 0.5.
- Click the Run button.
- Save the filter.
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.
Modifying the blue channel of the image
Follow these steps to change the blue channel in the input image:
- Locate the following code; this is the line that modifies the red channel:
dst.r += 0.5;
- Immediately after the line above, add the following line of code:
dst.b -= 0.4;
- Click the Run button to run the filter.
- Save the filter.
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).
Modifying the green channel of the image
Follow these steps to update the values of the green channel in the image:
- Locate the line in the code that modifies the blue channel:
dst.b -= 0.4;
- Immediately after that line of code, add a new line and type in the following code:
dst.g -= 0.1;
- Click the Run button to run the filter.
- Save the filter.
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).
Preparing a filter for Flash Player
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:
- Choose Build > Turn on Flash Player Warnings and Errors. This option enables filter validation for Flash Player when running filters, to help you perform troubleshooting.
- Click the Run button to run the filter.
- Verify that the filter runs successfully without generating any errors.
- Choose File > Export Kernel Filter for Flash Player.
- In the Export dialog box that appears, enter the name for the filter: Exercise2Filter.pbj
- Save the PBJ file in the pixel_bender folder on your desktop.
Note: Flash Player 10 supports a subset of the Pixel Bender language. Be sure to read the Pixel Bender Toolkit documentation for more information.
Where to go from here
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:
- Pixel Bender forum
- Pixel Bender basics for Flash
- Pixel Bender basics for Flex and AIR
- Effects with the Pixel Bender Toolkit – Part 2: Creating a vintage tone filter
- Effects with the Pixel Bender Toolkit – Part 1: Creating a new filter
- Effects with the Pixel Bender Toolkit – Part 8: Controlling the displacement filter with mouse positioning
- Effects with the Pixel Bender Toolkit – Part 7: Improving the displacement filter
- Effects with the Pixel Bender Toolkit – Part 5: Applying a filter to an image in Flash
- Effects with the Pixel Bender Toolkit – Part 6: Modifying Pixel Bender parameters in Flash
- 使用Pixel Bender Toolkit制作特效——创建vintage tone过滤器(Part 2)
- Effects with the Pixel Bender Toolkit – Part 3: Adding parameters to filters
- Effects with the Pixel Bender Toolkit – Part 4: Sampling multiple pixels
- The Pixel Bender 介绍
- Part 2: Creating a Template – A Technical Walkthrough
- 2: Creating A Script( Challenge: Working with the Command Line )
- Inkscape Tutorial Effects: Placing an Image Inside a Shape – Part 2
- 9 Creating a Chain of Effects
- Creating Effects
- Ext on AIR : Pixel Bender
- 2D Or Not 2D – Creating 2D Games With Unity3D Part 3
- Creating 2D Games With Unity3D Part 2
- The deployment identity at the deployment provider is not the same as the original deployment identity
- HDFS添加和删除节点
- JSP的OUT技术整理
- 搭建 Android 2.2 开发环境
- CvSaveImage()保存jpeg时压缩图像的方法
- Effects with the Pixel Bender Toolkit – Part 2: Creating a vintage tone filter
- 改造sql语句方法 将in条件修改
- 汇编里面的PTR是什么意思?
- Thinkphp常用系统变量指导
- IE6/IE7/IE8/Firefox/Chrome/Safari的CSS hack兼容一览表
- 无题
- 几个Vault的案例分析讲座
- java实现ftp文件上传下载
- 写了两个简单的排序函数