Fix T49391: Texture paint is not aware of disabled color management
There might be some extra missing points here, but it's all rather a TODO than a real bug and can be tweaked further once issues are actually discovered.
This commit is contained in:
parent
f64aa4e0af
commit
075a2175d5
Notes:
blender-bot
2023-02-14 08:39:23 +01:00
Referenced by issue #49391, Texture Paint color space chaos
|
@ -371,6 +371,8 @@ typedef struct ProjPaintState {
|
|||
*/
|
||||
const MLoopUV **dm_mloopuv;
|
||||
const MLoopUV **dm_mloopuv_clone; /* other UV map, use for cloning between layers */
|
||||
|
||||
bool use_colormanagement;
|
||||
} ProjPaintState;
|
||||
|
||||
typedef union pixelPointer {
|
||||
|
@ -1623,7 +1625,12 @@ static ProjPixel *project_paint_uvpixel_init(
|
|||
unsigned char rgba_ub[4];
|
||||
float rgba[4];
|
||||
project_face_pixel(lt_other_tri_uv, ibuf_other, w, rgba_ub, NULL);
|
||||
srgb_to_linearrgb_uchar4(rgba, rgba_ub);
|
||||
if (ps->use_colormanagement) {
|
||||
srgb_to_linearrgb_uchar4(rgba, rgba_ub);
|
||||
}
|
||||
else {
|
||||
rgba_uchar_to_float(rgba, rgba_ub);
|
||||
}
|
||||
straight_to_premul_v4_v4(((ProjPixelClone *)projPixel)->clonepx.f, rgba);
|
||||
}
|
||||
}
|
||||
|
@ -1632,7 +1639,12 @@ static ProjPixel *project_paint_uvpixel_init(
|
|||
float rgba[4];
|
||||
project_face_pixel(lt_other_tri_uv, ibuf_other, w, NULL, rgba);
|
||||
premul_to_straight_v4(rgba);
|
||||
linearrgb_to_srgb_uchar3(((ProjPixelClone *)projPixel)->clonepx.ch, rgba);
|
||||
if (ps->use_colormanagement) {
|
||||
linearrgb_to_srgb_uchar3(((ProjPixelClone *)projPixel)->clonepx.ch, rgba);
|
||||
}
|
||||
else {
|
||||
rgb_float_to_uchar(((ProjPixelClone *)projPixel)->clonepx.ch, rgba);
|
||||
}
|
||||
((ProjPixelClone *)projPixel)->clonepx.ch[3] = rgba[3] * 255;
|
||||
}
|
||||
else { /* char to char */
|
||||
|
@ -4359,7 +4371,12 @@ static void do_projectpaint_draw(
|
|||
if (ps->is_texbrush) {
|
||||
mul_v3_v3v3(rgb, texrgb, ps->paint_color_linear);
|
||||
/* TODO(sergey): Support texture paint color space. */
|
||||
linearrgb_to_srgb_v3_v3(rgb, rgb);
|
||||
if (ps->use_colormanagement) {
|
||||
linearrgb_to_srgb_v3_v3(rgb, rgb);
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(rgb, rgb);
|
||||
}
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(rgb, ps->paint_color);
|
||||
|
@ -4957,11 +4974,21 @@ static void paint_proj_stroke_ps(
|
|||
/* handle gradient and inverted stroke color here */
|
||||
if (ps->tool == PAINT_TOOL_DRAW) {
|
||||
paint_brush_color_get(scene, brush, false, ps->mode == BRUSH_STROKE_INVERT, distance, pressure, ps->paint_color, NULL);
|
||||
srgb_to_linearrgb_v3_v3(ps->paint_color_linear, ps->paint_color);
|
||||
if (ps->use_colormanagement) {
|
||||
srgb_to_linearrgb_v3_v3(ps->paint_color_linear, ps->paint_color);
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(ps->paint_color_linear, ps->paint_color);
|
||||
}
|
||||
}
|
||||
else if (ps->tool == PAINT_TOOL_FILL) {
|
||||
copy_v3_v3(ps->paint_color, BKE_brush_color_get(scene, brush));
|
||||
srgb_to_linearrgb_v3_v3(ps->paint_color_linear, ps->paint_color);
|
||||
if (ps->use_colormanagement) {
|
||||
srgb_to_linearrgb_v3_v3(ps->paint_color_linear, ps->paint_color);
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(ps->paint_color_linear, ps->paint_color);
|
||||
}
|
||||
}
|
||||
else if (ps->tool == PAINT_TOOL_MASK) {
|
||||
ps->stencil_value = brush->weight;
|
||||
|
@ -5112,7 +5139,9 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int
|
|||
ps->normal_angle_inner__cos = cosf(ps->normal_angle_inner);
|
||||
|
||||
ps->dither = settings->imapaint.dither;
|
||||
|
||||
|
||||
ps->use_colormanagement = BKE_scene_check_color_management_enabled(CTX_data_scene(C));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue