[Bf-blender-cvs] [765b1c6b53d] master: Fix T79005: Vertex color conversion operators changing the colors
Pablo Dobarro
noreply at git.blender.org
Mon Oct 18 15:01:44 CEST 2021
Commit: 765b1c6b53da655d55af18f883d91fd1238fb773
Author: Pablo Dobarro
Date: Mon Oct 18 14:52:06 2021 +0200
Branches: master
https://developer.blender.org/rB765b1c6b53da655d55af18f883d91fd1238fb773
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
===================================================================
M source/blender/editors/sculpt_paint/sculpt.c
===================================================================
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);
}
}
More information about the Bf-blender-cvs
mailing list