[Bf-blender-cvs] [41bd3c185bd] greasepencil-object: GPencil: Apply Layer Tint to Vertex Color

Antonio Vazquez noreply at git.blender.org
Tue Nov 5 11:04:51 CET 2019


Commit: 41bd3c185bd4a6c3d262e1b3ed9d2dc5295f0978
Author: Antonio Vazquez
Date:   Tue Nov 5 11:04:42 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rB41bd3c185bd4a6c3d262e1b3ed9d2dc5295f0978

GPencil: Apply Layer Tint to Vertex Color

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

M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M	source/blender/draw/engines/gpencil/gpencil_engine.h

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 73e7d43b295..5e5c1dc4682 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -141,6 +141,7 @@ void gpencil_get_point_geom(GpencilBatchCacheElem *be,
                             bGPDstroke *gps,
                             short thickness,
                             const float ink[4],
+                            const float tintcolor[4],
                             const int alignment_mode,
                             const bool onion)
 {
@@ -175,7 +176,9 @@ void gpencil_get_point_geom(GpencilBatchCacheElem *be,
     CLAMP(alpha, GPENCIL_STRENGTH_MIN, 1.0f);
     /* Apply the mix color. */
     if (!onion) {
-      interp_v3_v3v3(mix_color, ink, pt->mix_color, pt->mix_color[3]);
+      float mixtint[3];
+      interp_v3_v3v3(mixtint, pt->mix_color, tintcolor, tintcolor[3]);
+      interp_v3_v3v3(mix_color, ink, mixtint, pt->mix_color[3]);
     }
 
     ARRAY_SET_ITEMS(col, mix_color[0], mix_color[1], mix_color[2], alpha);
@@ -231,6 +234,7 @@ void gpencil_get_stroke_geom(struct GpencilBatchCacheElem *be,
                              bGPDstroke *gps,
                              short thickness,
                              const float ink[4],
+                             const float tintcolor[4],
                              const bool onion)
 {
   bGPDspoint *points = gps->points;
@@ -261,7 +265,9 @@ void gpencil_get_stroke_geom(struct GpencilBatchCacheElem *be,
     /* Apply the mix color. */
     copy_v4_v4(mix_color, ink);
     if (!onion) {
-      interp_v3_v3v3(mix_color, ink, pt->mix_color, pt->mix_color[3]);
+      float mixtint[3];
+      interp_v3_v3v3(mixtint, pt->mix_color, tintcolor, tintcolor[3]);
+      interp_v3_v3v3(mix_color, ink, mixtint, pt->mix_color[3]);
     }
 
     /* first point for adjacency (not drawn) */
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index a71f5f5627c..43b6a0c2c9f 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -996,8 +996,10 @@ static void gpencil_add_fill_vertexdata(GpencilBatchCache *cache,
       if (cache->is_dirty) {
         const float *color;
         if (!onion) {
-          /* Apply the mix color of the fill. */
-          interp_v3_v3v3(tfill, tfill, gps->mix_color_fill, gps->mix_color_fill[3]);
+          /* Apply the mix color of the fill and layer tint. */
+          float mixtint[3];
+          interp_v3_v3v3(mixtint, gps->mix_color_fill, tintcolor, tintcolor[3]);
+          interp_v3_v3v3(tfill, tfill, mixtint, gps->mix_color_fill[3]);
 
           color = tfill;
         }
@@ -1078,7 +1080,7 @@ static void gpencil_add_stroke_vertexdata(GpencilBatchCache *cache,
     if ((gps->totpoints > 1) && (gp_style->mode == GP_STYLE_MODE_LINE)) {
       /* create vertex data */
       const int old_len = cache->b_stroke.vbo_len;
-      gpencil_get_stroke_geom(&cache->b_stroke, gps, sthickness, ink, onion);
+      gpencil_get_stroke_geom(&cache->b_stroke, gps, sthickness, ink, tintcolor, onion);
 
       /* add to list of groups */
       if (old_len < cache->b_stroke.vbo_len) {
@@ -1096,7 +1098,8 @@ static void gpencil_add_stroke_vertexdata(GpencilBatchCache *cache,
     else {
       /* create vertex data */
       const int old_len = cache->b_point.vbo_len;
-      gpencil_get_point_geom(&cache->b_point, gps, sthickness, ink, alignment_mode, onion);
+      gpencil_get_point_geom(
+          &cache->b_point, gps, sthickness, ink, tintcolor, alignment_mode, onion);
 
       /* add to list of groups */
       if (old_len < cache->b_point.vbo_len) {
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index de56ebb3851..d9daef28893 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -427,12 +427,14 @@ void gpencil_get_point_geom(struct GpencilBatchCacheElem *be,
                             struct bGPDstroke *gps,
                             short thickness,
                             const float ink[4],
+                            const float tintcolor[4],
                             const int follow_mode,
                             const bool onion);
 void gpencil_get_stroke_geom(struct GpencilBatchCacheElem *be,
                              struct bGPDstroke *gps,
                              short thickness,
                              const float ink[4],
+                             const float tintcolor[4],
                              const bool onion);
 void gpencil_get_fill_geom(struct GpencilBatchCacheElem *be,
                            struct Object *ob,



More information about the Bf-blender-cvs mailing list