I’m currently reading through a couple of tutorials on how to create a water effect I want. One of them starts with a blur function which is pretty easy to understand in concept but I wanted to see the result. So I wrote the formula in hydra.
kernel Blur{ void evaluatePixel(in image4 src, out pixel4 dst){ float2 coord = outCoord(); float4 source = sampleNearest(src,coord); float4 source1 = sampleNearest(src,float2(coord.x+1.0,coord.y)); float4 source2 = sampleNearest(src,float2(coord.x-1.0,coord.y)); float4 source3 = sampleNearest(src,float2(coord.x,coord.y+1.0)); float4 source4 = sampleNearest(src,float2(coord.x,coord.y-1.0)); float4 final = (source+source1+source2+source3+source4)*0.2; dst = final; } }
The code gets the pixel of the current pixel along with the top, right, bottom, left and then divides by 5 to find the average.
Flash already has an inbuilt blur filter but this was just to see the maths.
Loops are not supported when Hydra is used within flash, so I can’t think of a way that you could increase the blur via a parameter at the moment.