[Bf-blender-cvs] [eb20250d2a5] master: Fix wrong white point of Linear ACES in config reading and the bundled config

Brecht Van Lommel noreply at git.blender.org
Wed Mar 10 16:57:01 CET 2021


Commit: eb20250d2a51cb6152c086a7f42194b95b67d9fd
Author: Brecht Van Lommel
Date:   Wed Mar 10 16:38:26 2021 +0100
Branches: master
https://developer.blender.org/rBeb20250d2a51cb6152c086a7f42194b95b67d9fd

Fix wrong white point of Linear ACES in config reading and the bundled config

The Blender/Cycles XYZ color space has a D65 white point instead of E, and
this was not correctly accounted for both in the OpenColor config reading code
and the bundled config.

This meant that since the OpenColorIO v2 upgrade, the Linear ACES color space
was not working correctly, and other OpenColorIO configs defining
aces_interchange were not interpreted correctly.

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

M	intern/cycles/render/shader.cpp
M	intern/opencolorio/ocio_impl.cc
M	release/datafiles/colormanagement/config.ocio
A	release/datafiles/colormanagement/luts/xyz_D65_to_E.spimtx

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

diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp
index ea83073d5ce..2d3cac45935 100644
--- a/intern/cycles/render/shader.cpp
+++ b/intern/cycles/render/shader.cpp
@@ -831,7 +831,8 @@ static bool to_scene_linear_transform(OCIO::ConstConfigRcPtr &config,
 
 void ShaderManager::init_xyz_transforms()
 {
-  /* Default to ITU-BT.709 in case no appropriate transform found. */
+  /* Default to ITU-BT.709 in case no appropriate transform found.
+   * Note XYZ here is defined as having a D65 white point. */
   xyz_to_r = make_float3(3.2404542f, -1.5371385f, -0.4985314f);
   xyz_to_g = make_float3(-0.9692660f, 1.8760108f, 0.0415560f);
   xyz_to_b = make_float3(0.0556434f, -0.2040259f, 1.0572252f);
@@ -848,24 +849,27 @@ void ShaderManager::init_xyz_transforms()
 
   if (config->hasRole("aces_interchange")) {
     /* Standard OpenColorIO role, defined as ACES2065-1. */
-    const Transform xyz_to_aces = make_transform(1.0498110175f,
-                                                 0.0f,
-                                                 -0.0000974845f,
-                                                 0.0f,
-                                                 -0.4959030231f,
-                                                 1.3733130458f,
-                                                 0.0982400361f,
-                                                 0.0f,
-                                                 0.0f,
-                                                 0.0f,
-                                                 0.9912520182f,
-                                                 0.0f);
+    const Transform xyz_E_to_aces = make_transform(1.0498110175f,
+                                                   0.0f,
+                                                   -0.0000974845f,
+                                                   0.0f,
+                                                   -0.4959030231f,
+                                                   1.3733130458f,
+                                                   0.0982400361f,
+                                                   0.0f,
+                                                   0.0f,
+                                                   0.0f,
+                                                   0.9912520182f,
+                                                   0.0f);
+    const Transform xyz_D65_to_E = make_transform(
+        1.0521111f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.9184170f, 0.0f);
+
     Transform aces_to_rgb;
     if (!to_scene_linear_transform(config, "aces_interchange", aces_to_rgb)) {
       return;
     }
 
-    xyz_to_rgb = aces_to_rgb * xyz_to_aces;
+    xyz_to_rgb = aces_to_rgb * xyz_E_to_aces * xyz_D65_to_E;
   }
   else if (config->hasRole("XYZ")) {
     /* Custom role used before the standard existed. */
diff --git a/intern/opencolorio/ocio_impl.cc b/intern/opencolorio/ocio_impl.cc
index c4d7a0c4fe9..146d5d1a5a7 100644
--- a/intern/opencolorio/ocio_impl.cc
+++ b/intern/opencolorio/ocio_impl.cc
@@ -326,7 +326,8 @@ void OCIOImpl::configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config_, float xyz_to_rg
 {
   ConstConfigRcPtr config = (*(ConstConfigRcPtr *)config_);
 
-  /* Default to ITU-BT.709 in case no appropriate transform found. */
+  /* Default to ITU-BT.709 in case no appropriate transform found.
+   * Note XYZ is defined here as having a D65 white point. */
   memcpy(xyz_to_rgb, OCIO_XYZ_TO_LINEAR_SRGB, sizeof(OCIO_XYZ_TO_LINEAR_SRGB));
 
   /* Get from OpenColorO config if it has the required roles. */
@@ -336,12 +337,15 @@ void OCIOImpl::configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config_, float xyz_to_rg
 
   if (config->hasRole("aces_interchange")) {
     /* Standard OpenColorIO role, defined as ACES2065-1. */
-    const float xyz_to_aces[3][3] = {{1.0498110175f, -0.4959030231f, 0.0f},
-                                     {0.0f, 1.3733130458f, 0.0f},
-                                     {-0.0000974845f, 0.0982400361f, 0.9912520182f}};
+    const float xyz_E_to_aces[3][3] = {{1.0498110175f, -0.4959030231f, 0.0f},
+                                       {0.0f, 1.3733130458f, 0.0f},
+                                       {-0.0000974845f, 0.0982400361f, 0.9912520182f}};
+    const float xyz_D65_to_E[3][3] = {
+        {1.0521111f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, 0.9184170f}};
+
     float aces_to_rgb[3][3];
     if (to_scene_linear_matrix(config, "aces_interchange", aces_to_rgb)) {
-      mul_m3_m3m3(xyz_to_rgb, aces_to_rgb, xyz_to_aces);
+      mul_m3_series(xyz_to_rgb, aces_to_rgb, xyz_E_to_aces, xyz_D65_to_E);
     }
   }
   else if (config->hasRole("XYZ")) {
diff --git a/release/datafiles/colormanagement/config.ocio b/release/datafiles/colormanagement/config.ocio
index 156ca960e88..bb9fd27fb84 100644
--- a/release/datafiles/colormanagement/config.ocio
+++ b/release/datafiles/colormanagement/config.ocio
@@ -100,6 +100,7 @@ colorspaces:
     from_reference: !<GroupTransform>
       children:
         - !<FileTransform> {src: srgb_to_xyz.spimtx, interpolation: linear}
+        - !<FileTransform> {src: xyz_D65_to_E.spimtx, interpolation: linear}
         - !<FileTransform> {src: xyz_to_aces.spimtx, interpolation: linear}
 
   - !<ColorSpace>
diff --git a/release/datafiles/colormanagement/luts/xyz_D65_to_E.spimtx b/release/datafiles/colormanagement/luts/xyz_D65_to_E.spimtx
new file mode 100644
index 00000000000..3670b94c9fe
--- /dev/null
+++ b/release/datafiles/colormanagement/luts/xyz_D65_to_E.spimtx
@@ -0,0 +1,3 @@
+1.0521111  0.0000000  0.0000000  0
+0.0000000  1.0000000  0.0000000  0
+0.0000000  0.0000000  0.9184170  0



More information about the Bf-blender-cvs mailing list