[Bf-blender-cvs] [51db1be8582] greasepencil-object: GPencil: More test to textured strokes

Antonioya noreply at git.blender.org
Fri Mar 8 10:25:03 CET 2019


Commit: 51db1be85827230b1ec24f799faeda43db4ead70
Author: Antonioya
Date:   Fri Mar 8 10:24:54 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rB51db1be85827230b1ec24f799faeda43db4ead70

GPencil: More test to textured strokes

Now, the UV is inverted by section (a full texture width) and not by point.

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

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 ac518c770a5..5cbeff1c7f5 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
@@ -182,36 +182,40 @@ void main(void)
 		EmitVertex();
 	}
 
-	/* generate the triangle strip */
+	float uv_x1 = finaluvdata[1].x;
+	float uv_x2 = finaluvdata[2].x;
+	/* normalize UVs */
+	if (uv_x2 > 1.0) {
+		float d = ceil(uv_x2) - 1.0;
+		uv_x1 = uv_x1 - d;
+		uv_x2 = uv_x2 - d;
+	}
 
-	/* invert uv if random values */
-	int a, b;
-	if (finaluvdata[1].y <= 0.0) {
-		 a = 1;
-		 b = 2;
+	/* invert uv if random angle (angles equal to 0 keep unchanged) */
+	if ((finaluvdata[1].y > 0.0) || (finaluvdata[1].y < 0.25)) {
+		float t = uv_x2;
+		uv_x2 = uv_x1;
+		uv_x1 = t;
 	}
-	else {
-		 a = 2;
-		 b = 1;
-	}	
 	
+	/* generate the triangle strip */
 	uvfac = vec2(0.0, 0.0);
-	mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(0, 0) : vec2(finaluvdata[a].x, 0);
+	mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(0, 0) : vec2(uv_x1, 0);
 	mColor = finalColor[1];
 	gl_Position = vec4((sp1 + length_a * miter_a) / Viewport, getZdepth(P1), 1.0);
 	EmitVertex();
 
-	mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(0, 1) : vec2(finaluvdata[a].x, 1);
+	mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(0, 1) : vec2(uv_x1, 1);
 	mColor = finalColor[1];
 	gl_Position = vec4((sp1 - length_a * miter_a) / Viewport, getZdepth(P1), 1.0);
 	EmitVertex();
 
-	mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(1, 0) : vec2(finaluvdata[b].x, 0);
+	mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(1, 0) : vec2(uv_x2, 0);
 	mColor = finalColor[2];
 	gl_Position = vec4((sp2 + length_b * miter_b) / Viewport, getZdepth(P2), 1.0);
 	EmitVertex();
 
-	mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(1, 1) : vec2(finaluvdata[b].x, 1);
+	mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(1, 1) : vec2(uv_x2, 1);
 	mColor = finalColor[2];
 	gl_Position = vec4((sp2 - length_b * miter_b) / Viewport, getZdepth(P2), 1.0);
 	EmitVertex();



More information about the Bf-blender-cvs mailing list