Fix T39704: Texture painting fails with different float image working space

This was rather a TODO item related on supporting the proper painting color
space, but added a small tweaks which will make things working for now in
most of the situation (assuming the default view of display is ivnertible,
as it is to be expected to be anyway).

Shouldn't give much overhead since the conversion processors are cached in
the color management code.

And for the note: no, projection painting does not requite such a tweak
because viewport works in sRGB space anyway.
This commit is contained in:
Sergey Sharybin 2014-04-14 14:08:10 +06:00
parent 0d38f21cbc
commit e6ff0ec73d
Notes: blender-bot 2023-02-14 10:48:34 +01:00
Referenced by issue #39704, Texture painting fails with different float image working space
1 changed files with 14 additions and 6 deletions

View File

@ -233,6 +233,9 @@ static ImBuf *brush_painter_imbuf_new(BrushPainter *painter, int size)
Scene *scene = painter->scene;
Brush *brush = painter->brush;
const char *display_device = scene->display_settings.display_device;
struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device);
rctf tex_mapping = painter->tex_mapping;
rctf mask_mapping = painter->mask_mapping;
struct ImagePool *pool = painter->pool;
@ -258,8 +261,9 @@ static ImBuf *brush_painter_imbuf_new(BrushPainter *painter, int size)
if (brush->imagepaint_tool == PAINT_TOOL_DRAW) {
copy_v3_v3(brush_rgb, brush->rgb);
if (use_color_correction)
srgb_to_linearrgb_v3_v3(brush_rgb, brush_rgb);
if (use_color_correction) {
IMB_colormanagement_display_to_scene_linear_v3(brush_rgb, display);
}
}
else {
brush_rgb[0] = 1.0f;
@ -278,7 +282,7 @@ static ImBuf *brush_painter_imbuf_new(BrushPainter *painter, int size)
BKE_brush_sample_tex_3D(scene, brush, texco, rgba, thread, pool);
/* TODO(sergey): Support texture paint color space. */
if (!use_float) {
linearrgb_to_srgb_v3_v3(rgba, rgba);
IMB_colormanagement_display_to_scene_linear_v3(rgba, display);
}
mul_v3_v3(rgba, brush_rgb);
}
@ -326,6 +330,9 @@ static void brush_painter_imbuf_update(BrushPainter *painter, ImBuf *oldtexibuf,
Scene *scene = painter->scene;
Brush *brush = painter->brush;
const char *display_device = scene->display_settings.display_device;
struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device);
rctf tex_mapping = painter->tex_mapping;
rctf mask_mapping = painter->mask_mapping;
struct ImagePool *pool = painter->pool;
@ -348,8 +355,9 @@ static void brush_painter_imbuf_update(BrushPainter *painter, ImBuf *oldtexibuf,
if (brush->imagepaint_tool == PAINT_TOOL_DRAW) {
copy_v3_v3(brush_rgb, brush->rgb);
if (use_color_correction)
srgb_to_linearrgb_v3_v3(brush_rgb, brush_rgb);
if (use_color_correction) {
IMB_colormanagement_display_to_scene_linear_v3(brush_rgb, display);
}
}
else {
brush_rgb[0] = 1.0f;
@ -369,7 +377,7 @@ static void brush_painter_imbuf_update(BrushPainter *painter, ImBuf *oldtexibuf,
BKE_brush_sample_tex_3D(scene, brush, texco, rgba, thread, pool);
/* TODO(sergey): Support texture paint color space. */
if (!use_float) {
linearrgb_to_srgb_v3_v3(rgba, rgba);
IMB_colormanagement_display_to_scene_linear_v3(rgba, display);
}
mul_v3_v3(rgba, brush_rgb);
}