[Bf-blender-cvs] [c1290a1d1f6] master: GPencil: Fix color management in Vertex Paint tools

Antonio Vazquez noreply at git.blender.org
Thu Mar 12 19:39:16 CET 2020


Commit: c1290a1d1f6beee8e60990d888fdb0a4d1a34e17
Author: Antonio Vazquez
Date:   Thu Mar 12 19:38:51 2020 +0100
Branches: master
https://developer.blender.org/rBc1290a1d1f6beee8e60990d888fdb0a4d1a34e17

GPencil: Fix color management in Vertex Paint tools

The brush is using sRGB and need to be Linear

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

M	source/blender/editors/gpencil/gpencil_vertex_paint.c

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

diff --git a/source/blender/editors/gpencil/gpencil_vertex_paint.c b/source/blender/editors/gpencil/gpencil_vertex_paint.c
index c730d1b493e..9cdea22d45e 100644
--- a/source/blender/editors/gpencil/gpencil_vertex_paint.c
+++ b/source/blender/editors/gpencil/gpencil_vertex_paint.c
@@ -104,6 +104,7 @@ typedef struct tGP_BrushVertexpaintData {
   bGPdata *gpd;
 
   Brush *brush;
+  float linear_color[3];
   eGPDvertex_brush_Flag flag;
   eGP_Vertex_SelectMaskFlag mask;
 
@@ -444,7 +445,7 @@ static bool brush_tint_apply(tGP_BrushVertexpaintData *gso,
       /* Premult. */
       mul_v3_fl(pt->vert_color, pt->vert_color[3]);
       /* "Alpha over" blending. */
-      interp_v3_v3v3(pt->vert_color, pt->vert_color, brush->rgb, inf);
+      interp_v3_v3v3(pt->vert_color, pt->vert_color, gso->linear_color, inf);
       pt->vert_color[3] = pt->vert_color[3] * (1.0 - inf) + inf;
       /* Un-premult. */
       if (pt->vert_color[3] > 0.0f) {
@@ -463,7 +464,7 @@ static bool brush_tint_apply(tGP_BrushVertexpaintData *gso,
       /* Premult. */
       mul_v3_fl(gps->vert_color_fill, gps->vert_color_fill[3]);
       /* "Alpha over" blending. */
-      interp_v3_v3v3(gps->vert_color_fill, gps->vert_color_fill, brush->rgb, inf_fill);
+      interp_v3_v3v3(gps->vert_color_fill, gps->vert_color_fill, gso->linear_color, inf_fill);
       gps->vert_color_fill[3] = gps->vert_color_fill[3] * (1.0 - inf_fill) + inf_fill;
       /* Un-premult. */
       if (gps->vert_color_fill[3] > 0.0f) {
@@ -483,7 +484,7 @@ static bool brush_replace_apply(tGP_BrushVertexpaintData *gso, bGPDstroke *gps,
 
   /* Apply color to Stroke point. */
   if (GPENCIL_TINT_VERTEX_COLOR_STROKE(brush)) {
-    copy_v3_v3(pt->vert_color, brush->rgb);
+    copy_v3_v3(pt->vert_color, gso->linear_color);
     /* If not mix color, full replace. */
     if (pt->vert_color[3] == 0.0f) {
       pt->vert_color[3] = 1.0f;
@@ -492,7 +493,7 @@ static bool brush_replace_apply(tGP_BrushVertexpaintData *gso, bGPDstroke *gps,
 
   /* Apply color to Fill area (all with same color and factor). */
   if (GPENCIL_TINT_VERTEX_COLOR_FILL(brush)) {
-    copy_v3_v3(gps->vert_color_fill, brush->rgb);
+    copy_v3_v3(gps->vert_color_fill, gso->linear_color);
     /* If not mix color, full replace. */
     if (gps->vert_color_fill[3] == 0.0f) {
       gps->vert_color_fill[3] = 1.0f;
@@ -731,6 +732,7 @@ static bool gp_vertexpaint_brush_init(bContext *C, wmOperator *op)
   op->customdata = gso;
 
   gso->brush = paint->brush;
+  srgb_to_linearrgb_v3_v3(gso->linear_color, gso->brush->rgb);
   BKE_curvemapping_initialize(gso->brush->curve);
 
   gso->is_painting = false;



More information about the Bf-blender-cvs mailing list