[Bf-blender-cvs] [23272ee0992] master: GPencil: Invert Texture for Line Strokes

Antonioya noreply at git.blender.org
Thu Mar 14 19:54:09 CET 2019


Commit: 23272ee099272e3b6e8c27a50733825168539c3d
Author: Antonioya
Date:   Thu Mar 14 19:53:47 2019 +0100
Branches: master
https://developer.blender.org/rB23272ee099272e3b6e8c27a50733825168539c3d

GPencil: Invert Texture for Line Strokes

Invert the texture of the stroke if the random UV is activated. Before, this parameter only affected to dot mode, but not to line strokes.

The texture is inverted vertically.

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

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 a3780a3dd4f..22096535289 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
@@ -182,24 +182,37 @@ void main(void)
 		EmitVertex();
 	}
 
+	float y_a = 0.0;
+	float y_b = 1.0;
+
+	/* invert uv (vertical) */
+	if (finaluvdata[2].x > 1.0) {
+		if ((finaluvdata[1].y != 0.0) && (finaluvdata[2].y != 0.0)) {
+			float d = ceil(finaluvdata[2].x) - 1.0;
+			if (floor(d / 2.0) == (d / 2.0)) {
+				y_a = 1.0;
+				y_b = 0.0;
+			}
+		}
+	}	
 	/* generate the triangle strip */
 	uvfac = vec2(0.0, 0.0);
-	mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(0, 0) : vec2(finaluvdata[1].x, 0);
+	mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(0, 0) : vec2(finaluvdata[1].x, y_a);
 	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[1].x, 1);
+	mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(0, 1) : vec2(finaluvdata[1].x, y_b);
 	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[2].x, 0);
+	mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(1, 0) : vec2(finaluvdata[2].x, y_a);
 	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[2].x, 1);
+	mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(1, 1) : vec2(finaluvdata[2].x, y_b);
 	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