Fix T64578: Cycles clamps HDR colors for 16bit integer image with colorspace
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 14 May 2019 09:22:07 +0000 (11:22 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 14 May 2019 09:22:07 +0000 (11:22 +0200)
intern/cycles/render/image.cpp

index 9f2a5e5..cf1c5fb 100644 (file)
@@ -186,6 +186,15 @@ void ImageManager::metadata_detect_colorspace(ImageMetaData &metadata, const cha
      * due to quantization in common cases. */
     metadata.compress_as_srgb = (metadata.type == IMAGE_DATA_TYPE_BYTE ||
                                  metadata.type == IMAGE_DATA_TYPE_BYTE4);
+
+    /* If colorspace conversion needed, use half instead of short so we can
+     * represent HDR values that might result from conversion. */
+    if (metadata.type == IMAGE_DATA_TYPE_USHORT) {
+      metadata.type = IMAGE_DATA_TYPE_HALF;
+    }
+    else if (metadata.type == IMAGE_DATA_TYPE_USHORT4) {
+      metadata.type = IMAGE_DATA_TYPE_HALF4;
+    }
   }
 }