[Bf-blender-cvs] [08aad00a5d5] master: Fix wrong colors when creating a float normal map image in texture paint
Brecht Van Lommel
noreply at git.blender.org
Mon Jul 8 11:06:53 CEST 2019
Commit: 08aad00a5d58ebb388f37172b9d98a8b9b515960
Author: Brecht Van Lommel
Date: Fri Jul 5 14:30:31 2019 +0200
Branches: master
https://developer.blender.org/rB08aad00a5d58ebb388f37172b9d98a8b9b515960
Fix wrong colors when creating a float normal map image in texture paint
===================================================================
M source/blender/blenkernel/intern/image.c
M source/blender/blenkernel/intern/image_gen.c
===================================================================
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index f03ca46b34e..8e04ef2d3ca 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -617,6 +617,7 @@ static ImBuf *add_ibuf_size(unsigned int width,
ImBuf *ibuf;
unsigned char *rect = NULL;
float *rect_float = NULL;
+ float fill_color[4];
if (floatbuf) {
ibuf = IMB_allocImBuf(width, height, depth, IB_rectfloat);
@@ -632,6 +633,15 @@ static ImBuf *add_ibuf_size(unsigned int width,
rect_float = ibuf->rect_float;
IMB_colormanagement_check_is_data(ibuf, colorspace_settings->name);
}
+
+ if (IMB_colormanagement_space_name_is_data(colorspace_settings->name)) {
+ copy_v4_v4(fill_color, color);
+ }
+ else {
+ /* The input color here should ideally be linear already, but for now
+ * we just convert and postpone breaking the API for later. */
+ srgb_to_linearrgb_v4(fill_color, color);
+ }
}
else {
ibuf = IMB_allocImBuf(width, height, depth, IB_rect);
@@ -647,6 +657,8 @@ static ImBuf *add_ibuf_size(unsigned int width,
rect = (unsigned char *)ibuf->rect;
IMB_colormanagement_assign_rect_colorspace(ibuf, colorspace_settings->name);
}
+
+ copy_v4_v4(fill_color, color);
}
if (!ibuf) {
@@ -663,7 +675,7 @@ static ImBuf *add_ibuf_size(unsigned int width,
BKE_image_buf_fill_checker_color(rect, rect_float, width, height);
break;
default:
- BKE_image_buf_fill_color(rect, rect_float, width, height, color);
+ BKE_image_buf_fill_color(rect, rect_float, width, height, fill_color);
break;
}
diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c
index 6f53c351626..bb2c086f02c 100644
--- a/source/blender/blenkernel/intern/image_gen.c
+++ b/source/blender/blenkernel/intern/image_gen.c
@@ -46,11 +46,9 @@ static void image_buf_fill_color_slice(
/* blank image */
if (rect_float) {
- float linear_color[4];
- srgb_to_linearrgb_v4(linear_color, color);
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
- copy_v4_v4(rect_float, linear_color);
+ copy_v4_v4(rect_float, color);
rect_float += 4;
}
}
More information about the Bf-blender-cvs
mailing list