[Bf-blender-cvs] [5cb2861420c] master: Fix Cycles incorrect result when compressing some 8 bit log colorspace images

Brecht Van Lommel noreply at git.blender.org
Wed Mar 11 13:02:06 CET 2020


Commit: 5cb2861420c733a3fa2d73593d820d9bddc7fd85
Author: Brecht Van Lommel
Date:   Wed Mar 11 11:37:31 2020 +0100
Branches: master
https://developer.blender.org/rB5cb2861420c733a3fa2d73593d820d9bddc7fd85

Fix Cycles incorrect result when compressing some 8 bit log colorspace images

Don't clamp and do premultiply after color space conversion.

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

M	intern/cycles/kernel/svm/svm_image.h
M	intern/cycles/render/colorspace.cpp

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

diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h
index 90f1a7845c7..63939a049a5 100644
--- a/intern/cycles/kernel/svm/svm_image.h
+++ b/intern/cycles/kernel/svm/svm_image.h
@@ -30,10 +30,6 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y,
 
   if ((flags & NODE_IMAGE_ALPHA_UNASSOCIATE) && alpha != 1.0f && alpha != 0.0f) {
     r /= alpha;
-    const int texture_type = kernel_tex_type(id);
-    if (texture_type == IMAGE_DATA_TYPE_BYTE4 || texture_type == IMAGE_DATA_TYPE_BYTE) {
-      r = min(r, make_float4(1.0f, 1.0f, 1.0f, 1.0f));
-    }
     r.w = alpha;
   }
 
diff --git a/intern/cycles/render/colorspace.cpp b/intern/cycles/render/colorspace.cpp
index 2e5b53057c0..97a9ba3f012 100644
--- a/intern/cycles/render/colorspace.cpp
+++ b/intern/cycles/render/colorspace.cpp
@@ -283,7 +283,7 @@ inline void processor_apply_pixels(const OCIO::Processor *processor,
       for (size_t x = 0; x < width; x++, i++) {
         float4 value = cast_to_float4(pixels + 4 * (y * width + x));
 
-        if (!(value.w == 0.0f || value.w == 1.0f)) {
+        if (!(value.w <= 0.0f || value.w == 1.0f)) {
           float inv_alpha = 1.0f / value.w;
           value.x *= inv_alpha;
           value.y *= inv_alpha;
@@ -302,14 +302,16 @@ inline void processor_apply_pixels(const OCIO::Processor *processor,
       for (size_t x = 0; x < width; x++, i++) {
         float4 value = float_pixels[i];
 
-        value.x *= value.w;
-        value.y *= value.w;
-        value.z *= value.w;
-
         if (compress_as_srgb) {
           value = color_linear_to_srgb_v4(value);
         }
 
+        if (!(value.w <= 0.0f || value.w == 1.0f)) {
+          value.x *= value.w;
+          value.y *= value.w;
+          value.z *= value.w;
+        }
+
         cast_from_float4(pixels + 4 * (y * width + x), value);
       }
     }



More information about the Bf-blender-cvs mailing list