标签:style class blog code java http
最近发现pixel bender有两个特殊点:
var width :int = 3; var height:int = 3; var vector:Vector.<Number> = new Vector.<Number>; var counter:int = 1; //利用vector作为input,需要从左上角到右下角,逐行逐行把每个像素的3通道信息,以3个Number形式表示 for (var i:int = 0; i < width; i++) { for (var j:int = 0; j < height; j++) { vector.push(counter, counter, counter); counter++; } } //目的是格式化输出,好看。。。 for (var k:int = 0; k < vector.length; k+=3* width) { var array:Array = new Array(); for (var i2:int = 0; i2 < width ; i2++) { array.push(vector[k+i2*3] + "," + vector[k+1+i2*3] + "," + vector[k+2+i2*3]); } trace(array.join(" ")); } trace ("====================="); var shader:Shader = new Shader( new PbjClass() as ByteArray ); shader.data.src.input = vector; shader.data.src.width = width;//这里必须指定width和height,否则出错 shader.data.src.height = height; var result:Vector.<Number> = new Vector.<Number>(); //这里必须指定width和height,否则出错 var job:ShaderJob = new ShaderJob(shader, result, width, height); job.start(true); //目的是格式化输出,好看。。。 for (var k:int = 0; k < result.length; k+=3* width) { var array:Array = new Array(); for (var i2:int = 0; i2 < width ; i2++) { array.push(result[k+i2*3] + "," + result[k+1+i2*3] + "," + result[k+2+i2*3]); } trace(array.join(" ")); }
1,1,1 2,2,2 3,3,3 4,4,4 5,5,5 6,6,6 7,7,7 8,8,8 9,9,9 ===================== 1,1,1 1,1,1 2,2,2 4,4,4 4,4,4 5,5,5 7,7,7 7,7,7 8,8,8
<languageVersion : 1.0;> kernel test < namespace : "Your Namespace"; vendor : "Your Vendor"; version : 1; > { input image3 src; //注意这里是3,不是4.如果是4的话,就会报错。着色器输入 src 没有足够的数据。因为as代码中初始化输入只是用了3元组 output pixel3 dst; void evaluatePixel() { float2 coord = outCoord(); pixel3 px = sampleNearest(src, coord + float2(-1.0, 0.0)); dst.x = px.x; dst.y = px.y; dst.z = px.z; } }
妙用Pixel bender执行复杂运算/普通数据运算 传递Vector数组,布布扣,bubuko.com
妙用Pixel bender执行复杂运算/普通数据运算 传递Vector数组
标签:style class blog code java http
原文地址:http://www.cnblogs.com/kenkofox/p/3784413.html