diff options
author | Antonioya <blendergit@gmail.com> | 2019-03-14 21:53:47 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2019-03-14 21:54:07 +0300 |
commit | 23272ee099272e3b6e8c27a50733825168539c3d (patch) | |
tree | c91b15652cad97a44eef7dcb87f0553b8fb74b9b | |
parent | 81a03e17f759316bb40fa4bd416bc2d8d3131bb6 (diff) |
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.
-rw-r--r-- | source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl | 21 |
1 files changed, 17 insertions, 4 deletions
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(); |