diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-07-05 15:30:31 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-07-08 12:05:45 +0300 |
commit | 08aad00a5d58ebb388f37172b9d98a8b9b515960 (patch) | |
tree | eb6e600a9f0b6e820a9d6e8def1cde51aaaac2b3 /source/blender/blenkernel | |
parent | f49692f4295b7e4f7f53a18204a907366c3612d6 (diff) |
Fix wrong colors when creating a float normal map image in texture paint
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 14 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image_gen.c | 4 |
2 files changed, 14 insertions, 4 deletions
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; } } |