When I use custom shader as a blend mode and apply a BlurFilter, black border appears. Without filter it works fine.
Here is a shader code.
kernel NewFilter
< namespace : "my.test";
vendor : "Im";
version : 1;
description : "Invert Luminance Blend Mode";
>
{
input image4 background;
input image4 foreground;
output pixel4 dst;
void
evaluatePixel()
{
pixel4 bg = sampleNearest(background, outCoord());
pixel4 fg = sampleNearest(foreground, outCoord());
float lum = bg.r * 0.299 + bg.g * 0.587 + bg.b * 0.114;
dst.rgb = fg.rgb + 1.0 - lum;
dst.a = fg.a;
}
}
How I apply shader and filter
[Embed(source = "InvertLuminance.pbj", mimeType = "application/octet-stream")]
var InvertLuminanceClass:Class;
...
highlighter = new Sprite();
highlighter.mouseEnabled = false;
highlighter.mouseChildren = false;
var shader:Shader = new Shader(new InvertLuminanceClass());
highlighter.blendShader = shader;
highlighter.blendMode = BlendMode.SHADER;
highlighter.filters = [new BlurFilter(1.9, 1.9, BitmapFilterQuality.HIGH)];
addChild(highlighter);
This issue appears with any shader as a blend mode. Can anybody help me with fixing this black pixels?
Thanks!