[Bf-blender-cvs] [8358cc79639] master: Fix wrong alpha for scene linear byte images during texture painting

Brecht Van Lommel noreply at git.blender.org
Mon Jul 18 17:50:19 CEST 2022


Commit: 8358cc79639c9ee797c5de9f5496032016e945d2
Author: Brecht Van Lommel
Date:   Mon Jul 18 17:31:19 2022 +0200
Branches: master
https://developer.blender.org/rB8358cc79639c9ee797c5de9f5496032016e945d2

Fix wrong alpha for scene linear byte images during texture painting

Make the update logic consistent with the case where the initial texture is
created. Also fixes a wrong assert.

Thanks Clément for spotting this.

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

M	source/blender/blenkernel/intern/image_gpu.cc
M	source/blender/imbuf/intern/colormanagement.c

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

diff --git a/source/blender/blenkernel/intern/image_gpu.cc b/source/blender/blenkernel/intern/image_gpu.cc
index 6edb9e1b24c..6506b40b603 100644
--- a/source/blender/blenkernel/intern/image_gpu.cc
+++ b/source/blender/blenkernel/intern/image_gpu.cc
@@ -737,11 +737,11 @@ static void gpu_texture_update_from_ibuf(
   }
   else {
     /* Byte image is in original colorspace from the file, and may need conversion. */
-    if (IMB_colormanagement_space_is_data(ibuf->rect_colorspace) ||
-        IMB_colormanagement_space_is_scene_linear(ibuf->rect_colorspace)) {
+    if (IMB_colormanagement_space_is_data(ibuf->rect_colorspace)) {
       /* Non-color data, just store buffer as is. */
     }
-    else if (IMB_colormanagement_space_is_srgb(ibuf->rect_colorspace)) {
+    else if (IMB_colormanagement_space_is_srgb(ibuf->rect_colorspace) ||
+             IMB_colormanagement_space_is_scene_linear(ibuf->rect_colorspace)) {
       /* sRGB or scene linear, store as byte texture that the GPU can decode directly. */
       rect = (uchar *)MEM_mallocN(sizeof(uchar[4]) * w * h, __func__);
       if (rect == nullptr) {
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index b95ec1cd92b..b62bdd5521d 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -2213,10 +2213,11 @@ void IMB_colormanagement_imbuf_to_byte_texture(unsigned char *out_buffer,
                                                const struct ImBuf *ibuf,
                                                const bool store_premultiplied)
 {
-  /* Byte buffer storage, only for sRGB and data texture since other
+  /* Byte buffer storage, only for sRGB, scene linear and data texture since other
    * color space conversions can't be done on the GPU. */
   BLI_assert(ibuf->rect && ibuf->rect_float == NULL);
   BLI_assert(IMB_colormanagement_space_is_srgb(ibuf->rect_colorspace) ||
+             IMB_colormanagement_space_is_scene_linear(ibuf->rect_colorspace) ||
              IMB_colormanagement_space_is_data(ibuf->rect_colorspace));
 
   const unsigned char *in_buffer = (unsigned char *)ibuf->rect;



More information about the Bf-blender-cvs mailing list