[Bf-blender-cvs] [bfb9680e9e5] blender2.8: GP: Fix problems with stroke Caps

Antonioya noreply at git.blender.org
Mon Dec 10 20:30:01 CET 2018


Commit: bfb9680e9e59c6fcbdce935323eceeee2b5349d3
Author: Antonioya
Date:   Mon Dec 10 20:04:17 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBbfb9680e9e59c6fcbdce935323eceeee2b5349d3

GP: Fix problems with stroke Caps

Now the start cap is done and during drawing the end cap is not set because needs to have a UV calculated and this is not done while drawing.

===================================================================

M	source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl

===================================================================

diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
index f9054b44996..3b99018cedd 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
@@ -45,6 +45,22 @@ float getZdepth(vec4 point)
 	/* in front by default */
 	return 0.000001;
 }
+
+/* check equality but with a small tolerance */
+bool is_equal(vec4 p1, vec4 p2)
+{
+	float limit = 0.0001;
+	float x = abs(p1.x - p2.x);
+	float y = abs(p1.y - p2.y);
+	float z = abs(p1.z - p2.z);
+
+	if ((x < limit) && (y < limit) && (z < limit)) {
+		return true;
+	}
+	
+	return false;
+}
+
 void main(void)
 {
 	float MiterLimit = 0.75;
@@ -143,7 +159,7 @@ void main(void)
 	}
 
 	/* generate the start endcap (alpha < 0 used as endcap flag)*/
-	if ((P0 == P2) && (color_type == GPENCIL_COLOR_SOLID)){
+	if (is_equal(P0,P2) && (color_type == GPENCIL_COLOR_SOLID)){
 		mTexCoord = vec2(2, 1);
 		mColor = vec4(finalColor[1].rgb, finalColor[1].a * -1.0) ;
 		vec2 svn1 =  normalize(sp1 - sp2) * length_a * 4.0;
@@ -183,7 +199,7 @@ void main(void)
 	EmitVertex();
 
 	/* generate the end endcap (alpha < 0 used as endcap flag)*/
-	if ((P1 == P3) && (color_type == GPENCIL_COLOR_SOLID)){
+	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;



More information about the Bf-blender-cvs mailing list