[Bf-blender-cvs] [b83692e11a3] greasepencil-refactor: GPencil: Refactor: Replace Stroke Miter break by rounded corners

Clément Foucault noreply at git.blender.org
Tue Jan 7 15:31:36 CET 2020


Commit: b83692e11a3e960692af2662d7b50384b7bd7973
Author: Clément Foucault
Date:   Mon Jan 6 18:39:32 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBb83692e11a3e960692af2662d7b50384b7bd7973

GPencil: Refactor: Replace Stroke Miter break by rounded corners

Also fix stroke ends being twice too long.

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

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

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

diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
index dd6716284b0..08319ecd405 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
@@ -403,7 +403,8 @@ void stroke_vertex()
     float miter_dot = dot(miter_tan, line_adj);
     /* Break corners after a certain angle to avoid really thick corners. */
     const float miter_limit = 0.5; /* cos(60°) */
-    miter_tan = (miter_dot < miter_limit) ? line : (miter_tan / miter_dot);
+    bool miter_break = (miter_dot < miter_limit);
+    miter_tan = (miter_break) ? line : (miter_tan / miter_dot);
 
     vec2 miter = rotate_90deg(miter_tan);
 
@@ -412,13 +413,13 @@ void stroke_vertex()
     strokeThickness = thickness / gl_Position.w;
 
     /* Reminder: we packed the cap flag into the sign of stength and thickness sign. */
-    bool is_stroke_start = (ma.x == -1.0 && x == -1.0 && strength1 > 0.0);
-    bool is_stroke_end = (ma3.x == -1.0 && x == 1.0 && thickness1 > 0.0);
+    bool is_stroke_start = (ma.x == -1.0 && x == -1.0 && strength1 > 0.0) || miter_break;
+    bool is_stroke_end = (ma3.x == -1.0 && x == 1.0 && thickness1 > 0.0) || miter_break;
 
     vec2 screen_ofs = miter * y;
 
     if (is_stroke_start || is_stroke_end) {
-      screen_ofs += line * x * 2.0;
+      screen_ofs += line * x;
     }
 
     gl_Position.xy += screen_ofs * sizeViewportInv.xy * thickness;



More information about the Bf-blender-cvs mailing list