2009-11-14 72 views

回答

2

以下.pbk几乎可以做到。您可以查看评论,看看如何加深模糊效果。

<languageVersion : 1.0;> 
kernel NewFilter 
< namespace : "Your Namespace"; 
    vendor : "Your Vendor"; 
    version : 1; 
    description : "your description"; 
> 
{ 
    input image4 src1; 
    input image4 src2; 
    output pixel4 dst; 

    void 
    evaluatePixel() 
    { 
     float2 pos = outCoord(); 

     // based on the current whiteness of pixel in src2 blur by a percentage. 
     float4 val = sampleNearest(src2,pos); 
     float percent = val[0]; 

     // this takes into account only the closest level of pixels to make the blur more in depth 
     // you can add the next 16 or even the 24 after that. 
     float4 pix = sampleNearest(src1,pos); 
     float4 pixNE = sampleNearest(src1,float2(pos.x+1.0, pos.y+1.0)); 
     float4 pixE = sampleNearest(src1,float2(pos.x+1.0, pos.y)); 
     float4 pixSE = sampleNearest(src1,float2(pos.x+1.0, pos.y-1.0)); 
     float4 pixS = sampleNearest(src1,float2(pos.x, pos.y-1.0)); 
     float4 pixSW = sampleNearest(src1,float2(pos.x-1.0, pos.y-1.0)); 
     float4 pixW = sampleNearest(src1,float2(pos.x-1.0, pos.y)); 
     float4 pixNW = sampleNearest(src1,float2(pos.x-1.0, pos.y+1.0)); 
     float4 pixN = sampleNearest(src1,float2(pos.x, pos.y+1.0)); 

     float4 result; 
     // the result is the whiteness percentage of the original pixel averaged with the surrounding pixels. 
     // if you added more of the surrounding pixels you can consider them in the weighted average also and get a deeper blur. 
     result[0] = percent*pix[0]+(1.0-percent)*(pixNE[0]+pixE[0]+pixSE[0]+pixS[0]+pixSW[0]+pixW[0]+pixNW[0]+pixN[0])/8.0; 
     result[1] = percent*pix[1]+(1.0-percent)*(pixNE[1]+pixE[1]+pixSE[1]+pixS[1]+pixSW[1]+pixW[1]+pixNW[1]+pixN[1])/8.0; 
     result[2] = percent*pix[2]+(1.0-percent)*(pixNE[2]+pixE[2]+pixSE[2]+pixS[2]+pixSW[2]+pixW[2]+pixNW[2]+pixN[2])/8.0; 
     result[3] = pix[3]; 

     dst = result; 
    } 
} 
+0

它不起作用,因为如果你看看他们的来源,你会看到 - 他们使用2个过滤器vert和hor做模糊,2次比较blur map到原始 - 疯狂),并且btw他们的公式只是从0到6只有确切的数字1 2 3 4 5 6所以它不会为我工作( – Rella 2009-11-24 03:41:17

+0

我的文章已被编辑,以反映使用像素弯曲机所需的模糊效果的一种可能的实现。即使这种方法总是看周围的像素每个像素即使不模糊它们,像素弯曲机的性能优势也应该补偿额外的工作。 – dennisjtaylor 2009-12-01 17:20:18

3

您可以在其原始上绘制模糊图像(Alpha通道更改为模糊值图)以模拟效果。

由于Flash中的像素弯曲器不支持循环,因此很难创建出色的模糊滤镜。

+0

那么混合使用AS3和PB怎么样?可能吗? – Rella 2009-11-15 14:48:11

+0

怎么做多次(pb过滤器与as3成环),比方说5,然后用像素混合器将它们堆叠在一起? – bgw 2009-11-16 00:50:49

+0

或者你可以将图像分隔成一个网格,并相应地模糊每一块。 – bgw 2009-11-16 00:52:21

3

我在这里这样的效果的非常古老的像素预折弯机版本(包括AS2源)http://www.quasimondo.com/archives/000564.php

它的工作原理与模糊半径从0提高创建几个模糊的位图(或铅丹你选择的半径)到最大半径。您做得越模糊,质量就越好。使用paletteMap过滤器可以为每个模糊图层创建遮罩,使得每个连续图层之间存在渐变重叠。然后使用其蒙版在下一个图层上绘制每个模糊图层。

这第二个混合阶段我可能现在宁愿与像素弯曲。