Hi there,
I am using the following code to create a dynamic reflection of an image:
{
input image4 src;
output pixel4 dst;
parameter float imageheight
<
minValue: 0.0;
maxValue : 1000.0;
defaultValue :300.0;
>;
parameter float fadeheight
<
minValue : 0.0;
maxValue: 1000.0;
defaultValue: 50.0;
>;
parameter float fadealpha
<
minValue : 0.0;
maxValue : 1.0;
defaultValue : 0.5;
>;
void
evaluatePixel()
{
float2 coord = outCoord();
if ( coord[ 1 ] < imageheight ) {
dst = sampleNearest(src, coord );
} else {
float alpha = 1.0 - ( coord[ 1 ] - imageheight ) / fadeheight;
coord[ 1 ] = imageheight - ( coord[ 1 ] - imageheight );
dst = sampleNearest( src, coord );
alpha *= fadealpha;
dst.a *= alpha;
dst.r *= alpha;
dst.g *= alpha;
dst.b *= alpha;
float2 pos = outCoord();
pixel4 color = sampleNearest(src,pos);
color+=0.75*sampleNearest(src, pos+float2(0.5*2, 0))+0.25*sampleNearest(src, pos+float2(2, 0));
color+=0.75*sampleNearest(src, pos-float2(0.5*2, 0))+0.25*sampleNearest(src, pos-float2(2, 0));
color+=0.75*sampleNearest(src, pos+float2(0, 0.5*2))+0.25*sampleNearest(src, pos+float2(0, 2));
color+=0.75*sampleNearest(src, pos-float2(0, 0.5*2))+0.25*sampleNearest(src, pos-float2(0, 2));
dst = color/5.0;
}
}
}
It's working nicely, but I'd really like to blur the output of the reflection slightly to give it a glossy look. I've had a google, but all the results seem incredibly complicated. Is creating a blur effect (similar to the Flash inbuilt filter) very difficult to do in Pixel Bender?
In this instance, I am not able to apply the Flash filter, so it has to be done in Pixel Bender.