Files
panopainter/data/shaders/stroke-dilate.glsl
2019-07-21 00:27:34 +02:00

43 lines
705 B
GLSL

[[vertex]]
uniform mat4 mvp;
in vec4 pos;
in vec2 uvs;
out vec2 uv;
void main()
{
gl_Position = mvp * vec4(pos.xy, 0.0, 1.0);
uv = uvs;
}
[[fragment]]
uniform sampler2D tex_bg;
in highp vec2 uv;
out highp vec4 frag;
void main()
{
highp vec4 bg = texture(tex_bg, uv);
if (bg.a == 0.0)
{
highp vec4 sum = vec4(0.0);
for (int y = -1; y <= 1; y++)
{
for (int x = -1; x <= 1; x++)
{
highp vec4 c = textureOffset(tex_bg, uv, ivec2(x, y));
sum += vec4(c.rgb * c.a, c.a);
}
}
frag = sum.a > 0.0 ? vec4(sum.rgb / sum.a, 0.0) : bg;
}
else
{
frag = bg;
}
}