fix color bleeding
This commit is contained in:
@@ -52,12 +52,15 @@ void main()
|
||||
highp vec2 uv_base = use_fragcoord ? (gl_FragCoord.st / resolution) : uv;
|
||||
highp vec4 base = texture(tex, uv_base);
|
||||
highp vec4 stroke = texture(tex_stroke, uv);
|
||||
|
||||
if (base.a == 0.0)
|
||||
base.rgb = stroke.rgb;
|
||||
|
||||
if (stroke.a == 0.0)
|
||||
{
|
||||
frag = base * vec4(1.0, 1.0, 1.0, alpha);
|
||||
return;
|
||||
}
|
||||
// if (stroke.a == 0.0)
|
||||
// {
|
||||
// frag = base * vec4(1.0, 1.0, 1.0, alpha);
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (use_pattern)
|
||||
{
|
||||
|
||||
42
data/shaders/stroke-dilate.glsl
Normal file
42
data/shaders/stroke-dilate.glsl
Normal file
@@ -0,0 +1,42 @@
|
||||
[[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;
|
||||
}
|
||||
}
|
||||
37
data/shaders/stroke-pad.glsl
Normal file
37
data/shaders/stroke-pad.glsl
Normal file
@@ -0,0 +1,37 @@
|
||||
[[vertex]]
|
||||
|
||||
in vec4 pos;
|
||||
out vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = pos;
|
||||
uv = pos.xy * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
[[fragment]]
|
||||
|
||||
#include "include/ext-fb-fetch.glsl"
|
||||
|
||||
uniform sampler2D tex_bg;
|
||||
uniform mediump vec4 col;
|
||||
|
||||
in highp vec2 uv;
|
||||
#if defined(GL_EXT_shader_framebuffer_fetch)
|
||||
inout highp vec4 frag;
|
||||
#else
|
||||
out highp vec4 frag;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
// sample from the background
|
||||
#if defined(GL_EXT_shader_framebuffer_fetch)
|
||||
highp vec4 bg = frag;
|
||||
#elif defined(GL_ARM_shader_framebuffer_fetch)
|
||||
highp vec4 bg = gl_LastFragColorARM;
|
||||
#else
|
||||
highp vec4 bg = texture(tex_bg, uv);
|
||||
#endif
|
||||
frag = bg.a == 0.0 ? vec4(col.rgb, 0.0) : bg;
|
||||
}
|
||||
@@ -61,8 +61,8 @@ void main()
|
||||
highp vec4 fg = vec4(col.rgb, brush_alpha);
|
||||
|
||||
// early discard
|
||||
if (fg.a == 0.0)
|
||||
discard;
|
||||
// if (fg.a == 0.0)
|
||||
// discard;
|
||||
|
||||
if (use_pattern)
|
||||
{
|
||||
@@ -86,11 +86,14 @@ void main()
|
||||
highp vec4 bg = texture(tex_bg, uv2);
|
||||
#endif
|
||||
|
||||
if (bg.a == 0.0)
|
||||
bg.rgb = col.rgb;
|
||||
|
||||
fg.a *= 1.0-rand(uv2+uv)*noise;
|
||||
|
||||
// no need to go further
|
||||
if (fg.a <= 0.0)
|
||||
discard;
|
||||
// if (fg.a <= 0.0)
|
||||
// discard;
|
||||
|
||||
if (mix_alpha > 0.0)
|
||||
{
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
[[vertex]]
|
||||
|
||||
uniform mat4 mvp;
|
||||
|
||||
in vec4 pos;
|
||||
in vec2 uvs;
|
||||
out vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
uv = uvs;
|
||||
gl_Position = mvp * vec4(pos.xyz, 1.0);
|
||||
}
|
||||
|
||||
[[fragment]]
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D tex_alpha;
|
||||
uniform sampler2D tex_bg;
|
||||
uniform highp float alpha;
|
||||
uniform bool highlight;
|
||||
|
||||
in highp vec2 uv;
|
||||
out highp vec4 frag;
|
||||
|
||||
void main()
|
||||
{
|
||||
highp vec3 rgb = texture(tex, uv).rgb;
|
||||
highp float a = texture(tex_alpha, uv).a;
|
||||
highp vec4 c = vec4(rgb, a);
|
||||
frag = highlight ?
|
||||
vec4(clamp(vec3(0.3) + c.rgb, vec3(0.0), vec3(1.0)), c.a) :
|
||||
texture(tex, uv) * vec4(1.0, 1.0, 1.0, alpha);
|
||||
}
|
||||
@@ -18,7 +18,6 @@ void main()
|
||||
#include "include/blend.glsl"
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D tex_alpha;
|
||||
uniform sampler2D tex_bg;
|
||||
uniform highp float alpha;
|
||||
uniform int blend_mode;
|
||||
@@ -41,7 +40,7 @@ void main()
|
||||
highp vec4 bg = texture(tex_bg, uv);
|
||||
#endif
|
||||
|
||||
highp vec4 fg = vec4(texture(tex, uv).rgb, texture(tex_alpha, uv).a);
|
||||
highp vec4 fg = texture(tex, uv);
|
||||
if (fg.a == 0.0)
|
||||
{
|
||||
frag = bg;
|
||||
|
||||
Reference in New Issue
Block a user