GP: Fix unreported pixel glitches
There was a problem in the caps start and in some situations, the pixel was wrong. Also changed the way the caps are detected because use the alpha in negative was a hack that maybe will not work with all drivers.
This commit is contained in:
parent
80ffa73b3f
commit
16b0a74228
|
@ -3,7 +3,7 @@ uniform sampler2D myTexture;
|
|||
|
||||
in vec4 mColor;
|
||||
in vec2 mTexCoord;
|
||||
in float uvfac;
|
||||
in vec2 uvfac;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
|
@ -17,10 +17,9 @@ out vec4 fragColor;
|
|||
void main()
|
||||
{
|
||||
vec4 tColor = vec4(mColor);
|
||||
/* if alpha < 0, then encap (only solid mode ) */
|
||||
if ((mColor.a < 0) && (color_type == GPENCIL_COLOR_SOLID)) {
|
||||
vec2 center = vec2(uvfac, 1.0);
|
||||
tColor.a = tColor.a * -1.0;
|
||||
/* if uvfac[1] == 1, then encap (only solid mode ) */
|
||||
if ((uvfac[1] == 1.0) && (color_type == GPENCIL_COLOR_SOLID)) {
|
||||
vec2 center = vec2(uvfac[0], 1.0);
|
||||
float dist = length(mTexCoord - center);
|
||||
if (dist > 0.50) {
|
||||
discard;
|
||||
|
|
|
@ -12,7 +12,7 @@ in vec2 finaluvdata[4];
|
|||
|
||||
out vec4 mColor;
|
||||
out vec2 mTexCoord;
|
||||
out float uvfac;
|
||||
out vec2 uvfac;
|
||||
|
||||
#define GP_XRAY_FRONT 0
|
||||
#define GP_XRAY_3DSPACE 1
|
||||
|
@ -64,7 +64,7 @@ bool is_equal(vec4 p1, vec4 p2)
|
|||
void main(void)
|
||||
{
|
||||
float MiterLimit = 0.75;
|
||||
uvfac = 0;
|
||||
uvfac = vec2(0.0, 0.0);
|
||||
|
||||
/* receive 4 points */
|
||||
vec4 P0 = gl_in[0].gl_Position;
|
||||
|
@ -158,26 +158,32 @@ void main(void)
|
|||
length_b = finalThickness[2];
|
||||
}
|
||||
|
||||
/* generate the start endcap (alpha < 0 used as endcap flag)*/
|
||||
/* generate the start endcap */
|
||||
if (is_equal(P0,P2) && (color_type == GPENCIL_COLOR_SOLID)){
|
||||
mTexCoord = vec2(2, 1);
|
||||
mColor = vec4(finalColor[1].rgb, finalColor[1].a * -1.0) ;
|
||||
vec4 cap_color = finalColor[1];
|
||||
|
||||
mTexCoord = vec2(2.0, 1.0);
|
||||
mColor = cap_color;
|
||||
vec2 svn1 = normalize(sp1 - sp2) * length_a * 4.0;
|
||||
uvfac = vec2(0.0, 1.0);
|
||||
gl_Position = vec4((sp1 + svn1) / Viewport, getZdepth(P1), 1.0);
|
||||
EmitVertex();
|
||||
|
||||
mTexCoord = vec2(0, 0);
|
||||
mColor = vec4(finalColor[1].rgb, finalColor[1].a * -1.0) ;
|
||||
mTexCoord = vec2(0.0, 0.0);
|
||||
mColor = cap_color;
|
||||
uvfac = vec2(0.0, 1.0);
|
||||
gl_Position = vec4((sp1 - (length_a * 2.0) * miter_a) / Viewport, getZdepth(P1), 1.0);
|
||||
EmitVertex();
|
||||
|
||||
mTexCoord = vec2(0, 2);
|
||||
mColor = vec4(finalColor[1].rgb, finalColor[1].a * -1.0) ;
|
||||
mTexCoord = vec2(0.0, 2.0);
|
||||
mColor = cap_color;
|
||||
uvfac = vec2(0.0, 1.0);
|
||||
gl_Position = vec4((sp1 + (length_a * 2.0) * miter_a) / Viewport, getZdepth(P1), 1.0);
|
||||
EmitVertex();
|
||||
}
|
||||
|
||||
/* generate the triangle strip */
|
||||
uvfac = vec2(0.0, 0.0);
|
||||
mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(0, 0) : vec2(finaluvdata[1].x, 0);
|
||||
mColor = finalColor[1];
|
||||
gl_Position = vec4((sp1 + length_a * miter_a) / Viewport, getZdepth(P1), 1.0);
|
||||
|
@ -198,23 +204,25 @@ void main(void)
|
|||
gl_Position = vec4((sp2 - length_b * miter_b) / Viewport, getZdepth(P2), 1.0);
|
||||
EmitVertex();
|
||||
|
||||
/* generate the end endcap (alpha < 0 used as endcap flag)*/
|
||||
/* generate the end endcap */
|
||||
if (is_equal(P1,P3) && (color_type == GPENCIL_COLOR_SOLID) && (finaluvdata[2].x > 0)){
|
||||
mTexCoord = vec2(finaluvdata[2].x, 2);
|
||||
mColor = vec4(finalColor[2].rgb, finalColor[2].a * -1.0) ;
|
||||
uvfac = finaluvdata[2].x;
|
||||
vec4 cap_color = finalColor[2];
|
||||
|
||||
mTexCoord = vec2(finaluvdata[2].x, 2.0);
|
||||
mColor = cap_color;
|
||||
uvfac = vec2(finaluvdata[2].x, 1.0);
|
||||
gl_Position = vec4((sp2 + (length_b * 2.0) * miter_b) / Viewport, getZdepth(P2), 1.0);
|
||||
EmitVertex();
|
||||
|
||||
mTexCoord = vec2(finaluvdata[2].x, 0);
|
||||
mColor = vec4(finalColor[2].rgb, finalColor[2].a * -1.0) ;
|
||||
uvfac = finaluvdata[2].x;
|
||||
mTexCoord = vec2(finaluvdata[2].x, 0.0);
|
||||
mColor = cap_color;
|
||||
uvfac = vec2(finaluvdata[2].x, 1.0);
|
||||
gl_Position = vec4((sp2 - (length_b * 2.0) * miter_b) / Viewport, getZdepth(P2), 1.0);
|
||||
EmitVertex();
|
||||
|
||||
mTexCoord = vec2(finaluvdata[2].x + 2, 1);
|
||||
mColor = vec4(finalColor[2].rgb, finalColor[2].a * -1.0) ;
|
||||
uvfac = finaluvdata[2].x;
|
||||
mTexCoord = vec2(finaluvdata[2].x + 2, 1.0);
|
||||
mColor = cap_color;
|
||||
uvfac = vec2(finaluvdata[2].x, 1.0);
|
||||
vec2 svn2 = normalize(sp2 - sp1) * length_b * 4.0;
|
||||
gl_Position = vec4((sp2 + svn2) / Viewport, getZdepth(P2), 1.0);
|
||||
EmitVertex();
|
||||
|
|
|
@ -40,6 +40,6 @@ void main()
|
|||
stroke_color.b = srgb_to_linearrgb(stroke_color.b);
|
||||
}
|
||||
|
||||
FragColor = stroke_color;
|
||||
gl_FragDepth = stroke_depth;
|
||||
FragColor = clamp(stroke_color, 0.0, 1.0);
|
||||
gl_FragDepth = clamp(stroke_depth, 0.0, 1.0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue