diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-09-20 13:21:28 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-09-20 13:22:50 +0300 |
commit | 075a2175d5e706025473f7416d3bb89b91cc796c (patch) | |
tree | d4bf68cf45225331e2f1538e8990c08ec6d48587 /source/blender/editors/sculpt_paint | |
parent | f64aa4e0afc71ccadc3fb0faea090a1f42cd7b35 (diff) |
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.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_proj.c | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 83fde4554b3..f5d115442c6 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -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; } |