Deprecated: Assigning the return value of new by reference is deprecated in /public/sites/www.borisvanschooten.nl/blog/wp-settings.php on line 646
Deprecated: Assigning the return value of new by reference is deprecated in /public/sites/www.borisvanschooten.nl/blog/wp-settings.php on line 661
Deprecated: Assigning the return value of new by reference is deprecated in /public/sites/www.borisvanschooten.nl/blog/wp-settings.php on line 668
Deprecated: Assigning the return value of new by reference is deprecated in /public/sites/www.borisvanschooten.nl/blog/wp-settings.php on line 675
Deprecated: Assigning the return value of new by reference is deprecated in /public/sites/www.borisvanschooten.nl/blog/wp-settings.php on line 711
Deprecated: Function set_magic_quotes_runtime() is deprecated in /public/sites/www.borisvanschooten.nl/blog/wp-settings.php on line 18
Warning: Cannot modify header information - headers already sent by (output started at /public/sites/www.borisvanschooten.nl/blog/wp-settings.php:646) in /public/sites/www.borisvanschooten.nl/blog/wp-content/plugins/wp-codebox/wp-codebox.php on line 34
Warning: Cannot modify header information - headers already sent by (output started at /public/sites/www.borisvanschooten.nl/blog/wp-settings.php:646) in /public/sites/www.borisvanschooten.nl/blog/wp-content/plugins/wp-codebox/wp-codebox.php on line 35
/** Reflection filter by Boris van Schooten.
* http://www.borisvanschooten.nl/
*/
kernel Reflection <
namespace : "borisvanschooten";
vendor : "Boris van Schooten";
version : 1;
description : "Apple style reflection effect";
> {
input image4 src;
output pixel4 dst;
parameter float4 topcol <
minValue:float4(0.0,0.0,0.0,0.0);
maxValue:float4(1.0,1.0,1.0,1.0);
defaultValue:float4(0.8,0.8,0.8,1.0);
description:"Gradient color top.";
>;
parameter float4 botcol <
minValue:float4(0.0,0.0,0.0,0.0);
maxValue:float4(1.0,1.0,1.0,1.0);
defaultValue:float4(0.4,0.4,0.4,1.0);
description:"Gradient color bottom.";
>;
parameter float4 bgcol <
minValue:float4(0.0,0.0,0.0,0.0);
maxValue:float4(1.0,1.0,1.0,1.0);
defaultValue:float4(0.0,0.0,0.0,1.0);
description:"Background color = color to replace.";
>;
parameter int imgheight <
minValue:1;
maxValue:8192;
defaultValue:480;
description:"Image (gradient) height.";
>;
parameter float reflectpos <
minValue:1.0;
maxValue:8192.0;
defaultValue:340.0;
description:"Vertical position of reflection.";
>;
parameter float reflectheight <
minValue:1.0;
maxValue:8192.0;
defaultValue:110.0;
description:"Height of reflection.";
>;
parameter float intensity <
minValue:0.0;
maxValue:1.0;
defaultValue:0.5;
description:"Intensity of reflection.";
>;
void evaluatePixel() {
float2 c = outCoord();
dst = sampleNearest(src, c);
// only modify pixels of background colour
if (distance(dst,bgcol) < 0.01 ) {
float pos = c.y / float(imgheight);
// gradient colour
float4 col = (1.0-pos)*topcol + pos*botcol;
// create reflection
if (c.y >= reflectpos
&& c.y < reflectpos+reflectheight ) {
// source pixel of reflection
float4 mirsrc = sampleNearest(src,
float2(c.x, 2.0*reflectpos-c.y) );
// only reflect if source pixel not background colour
if (distance(mirsrc,bgcol) >= 0.01 ) {
float dist = (1.0-intensity)
+ intensity*(c.y - reflectpos) / reflectheight;
col = (1.0-dist)*mirsrc + col;
}
}
dst = col;
}
}
}