[Bf-blender-cvs] [e6ff0ec] master: Fix T39704: Texture painting fails with different float image working space

Sergey Sharybin noreply at git.blender.org
Mon Apr 14 10:10:49 CEST 2014


Commit: e6ff0ec73da5fa82873ea75f4915b7cf8410c454
Author: Sergey Sharybin
Date:   Mon Apr 14 14:08:10 2014 +0600
https://developer.blender.org/rBe6ff0ec73da5fa82873ea75f4915b7cf8410c454

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.

===================================================================

M	source/blender/editors/sculpt_paint/paint_image_2d.c

===================================================================

diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index 19f2673..c15d481 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -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);
 				}




More information about the Bf-blender-cvs mailing list