topical media & game development
graphic-shader-sharpen.pbj / pbk
<languageVersion: 1.0;>
kernel sharpen
< namespace : "com.rphelan";
vendor : "Ryan Phelan";
version : 1;
description : "Applies a sharpen effect to an image."; >
{
parameter float amount
<
minValue:0.0;
maxValue:20.0;
defaultValue:1.0;
>;
parameter float radius
<
minValue:0.0;
maxValue:1.0;
defaultValue:0.1;
>;
input image4 src;
output float4 dst;
void
evaluatePixel()
{
// Obtain the input pixel coordinate
float2 coord = outCoord();
// Obtain the input pixel color
float4 inputColor = sampleLinear(src, coord);
// Start with the original color
dst.rgb = inputColor.rgb;
// Offset the color by the surrounding pixels
float2 hOffset = float2(radius, 0.0);
float2 vOffset = float2(0.0, radius);
float4 left = sampleLinear(src, coord - hOffset) * amount;
float4 right = sampleLinear(src, coord + hOffset) * amount;
float4 top = sampleLinear(src, coord - vOffset) * amount;
float4 bottom = sampleLinear(src, coord + vOffset) * amount;
dst.rgb += (top.rgb);
dst.rgb -= (bottom.rgb);
dst.rgb += left.rgb;
dst.rgb -= right.rgb;
// set the alpha value equal to the alpha of the input
dst.a = inputColor.a;
}
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.