像素弯曲器内核内部的主要功能是一个循环,并为内核评估的每个像素回调。这是一个教程的链接,该链接介绍了如何完全按照您的要求进行操作(使用多个输入)。
http://www.adobe.com/devnet/pixelbender/articles/creating_effects_pt09.html#articlecontentAdobe_numberedheader
本质上,它只是归结为定义两个输入:
<languageVersion : 1.0;>
kernel blendy
< namespace : "com.adobe.devnet.pixelbender";
vendor : "Kevin's Filters";
version : 1;
description : "mashes two inputs together";
>
{
input image4 src; //Input image 1 as image4 (RGBA)
input image4 src2; //Input image 2 as image4 (RGBA)
output pixel4 dst; //Single pixel data type/represents single pixel value (RGBA)
void evaluatePixel()
{
dst = sampleNearest(src,outCoord());
}
}
注意,sampleNearest 的两个参数是源图像和要采样的像素的坐标。outCoord() 我相信只是循环中的当前像素。如前所述,每个输入中存在的像素都会调用一次evaluatePixel(据我所知)。这是上述代码的修改版本(来自链接),它同时读取两个输入的值:
<languageVersion : 1.0;>
kernel blendy
< namespace : "com.adobe.devnet.pixelbender";
vendor : "Kevin's Filters";
version : 1;
description : "mashes two inputs together";
>
{
input image4 src; //Input image 1 as image4 (RGBA)
input image4 src2; //Input image 2 as image4 (RGBA)
output pixel4 dst; //Output image
void evaluatePixel()
{
dst = sampleNearest(src2,outCoord()) + sampleNearest(src, outCoord());
}
}
这里有两个视频教程,将详细解释像素如何工作:
http://gotoandlearn.com/play.php?id=83
http://gotoandlearn.com/play.php?id=84
http://www.gotoandlearn.com/play.php?id=95