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; } }