From 765b1c6b53da655d55af18f883d91fd1238fb773 Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Mon, 18 Oct 2021 14:52:06 +0200 Subject: Fix T79005: Vertex color conversion operators changing the colors CD_PROP_COLOR vertex data is stored in scene linear while legacy vertex colors are srgb, so both operators also need to do this conversion Reviewed By: sergey Maniphest Tasks: T79005 Differential Revision: https://developer.blender.org/D8320 --- source/blender/editors/sculpt_paint/sculpt.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source/blender/editors/sculpt_paint') diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 7bde864e73f..95be866adf1 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -30,6 +30,7 @@ #include "BLI_gsqueue.h" #include "BLI_hash.h" #include "BLI_math.h" +#include "BLI_math_color.h" #include "BLI_math_color_blend.h" #include "BLI_task.h" #include "BLI_utildefines.h" @@ -8684,10 +8685,12 @@ static int vertex_to_loop_colors_exec(bContext *C, wmOperator *UNUSED(op)) for (int j = 0; j < c_poly->totloop; j++) { int loop_index = c_poly->loopstart + j; MLoop *c_loop = &loops[c_poly->loopstart + j]; - loopcols[loop_index].r = (char)(vertcols[c_loop->v].color[0] * 255); - loopcols[loop_index].g = (char)(vertcols[c_loop->v].color[1] * 255); - loopcols[loop_index].b = (char)(vertcols[c_loop->v].color[2] * 255); - loopcols[loop_index].a = (char)(vertcols[c_loop->v].color[3] * 255); + float srgb_color[4]; + linearrgb_to_srgb_v4(srgb_color, vertcols[c_loop->v].color); + loopcols[loop_index].r = (char)(srgb_color[0] * 255); + loopcols[loop_index].g = (char)(srgb_color[1] * 255); + loopcols[loop_index].b = (char)(srgb_color[2] * 255); + loopcols[loop_index].a = (char)(srgb_color[3] * 255); } } @@ -8751,6 +8754,7 @@ static int loop_to_vertex_colors_exec(bContext *C, wmOperator *UNUSED(op)) vertcols[c_loop->v].color[1] = (loopcols[loop_index].g / 255.0f); vertcols[c_loop->v].color[2] = (loopcols[loop_index].b / 255.0f); vertcols[c_loop->v].color[3] = (loopcols[loop_index].a / 255.0f); + srgb_to_linearrgb_v4(vertcols[c_loop->v].color, vertcols[c_loop->v].color); } } -- cgit v1.2.3