Fix T78201: Paint color not matching the UI and color picker
authorPablo Dobarro <pablodp606@gmail.com>
Mon, 29 Jun 2020 16:44:13 +0000 (18:44 +0200)
committerPablo Dobarro <pablodp606@gmail.com>
Tue, 30 Jun 2020 17:13:45 +0000 (19:13 +0200)
The color picker and brush->rgb values are in srgb, but sculpt vertex
colors works in linear, so they need to be converted.

Reviewed By: sergey

Maniphest Tasks: T78201

Differential Revision: https://developer.blender.org/D8111

source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/sculpt_paint/sculpt_paint_color.c

index 3098a0bfcb8acf07efc8c07300ad11048d2b94f8..d414d6d8f0f47b1b45962d1da47a4cb51b4a055c 100644 (file)
@@ -74,6 +74,8 @@
 
 #include "DEG_depsgraph.h"
 
+#include "IMB_colormanagement.h"
+
 #include "WM_api.h"
 #include "WM_message.h"
 #include "WM_toolsystem.h"
@@ -8134,7 +8136,10 @@ static int sculpt_sample_color_invoke(bContext *C,
     return OPERATOR_CANCELLED;
   }
 
-  BKE_brush_color_set(scene, brush, active_vertex_color);
+  float color_srgb[3];
+  copy_v3_v3(color_srgb, active_vertex_color);
+  IMB_colormanagement_scene_linear_to_srgb_v3(color_srgb);
+  BKE_brush_color_set(scene, brush, color_srgb);
   BKE_brush_alpha_set(scene, brush, active_vertex_color[3]);
 
   WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
index 191d18cb54315385dab1434e41fac425323c3b00..9b38def6b7b136dc6ac5bdfaf59f0b106c193e50 100644 (file)
@@ -44,6 +44,8 @@
 
 #include "DEG_depsgraph.h"
 
+#include "IMB_colormanagement.h"
+
 #include "WM_api.h"
 #include "WM_message.h"
 #include "WM_toolsystem.h"
@@ -132,6 +134,7 @@ static void do_paint_brush_task_cb_ex(void *__restrict userdata,
 
   float brush_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
   copy_v3_v3(brush_color, BKE_brush_color_get(ss->scene, brush));
+  IMB_colormanagement_srgb_to_scene_linear_v3(brush_color);
 
   BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
   {