Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2022-05-19 21:31:58 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-05-23 16:34:50 +0300
commit469ee7ff1529a1b28ce0b300835ebc42d5c5362f (patch)
tree9be3874673f222ac3c3773fe726f0158287ac1e6 /intern
parent2f2d13b8c664b90a7d3249d6ad71bac3d519026d (diff)
Python API: add mathutils.Color functions to convert color spaces
Between scene linear and sRGB, XYZ, linear Rec.709 and ACES2065-1. And add some clarifications about color spaces in the docs. Fixes T98267 Ref T68926 Differential Revision: https://developer.blender.org/D14989
Diffstat (limited to 'intern')
-rw-r--r--intern/opencolorio/fallback_impl.cc2
-rw-r--r--intern/opencolorio/ocio_capi.h13
-rw-r--r--intern/opencolorio/ocio_impl.cc9
3 files changed, 12 insertions, 12 deletions
diff --git a/intern/opencolorio/fallback_impl.cc b/intern/opencolorio/fallback_impl.cc
index d78b34d3c92..71b5ab9def2 100644
--- a/intern/opencolorio/fallback_impl.cc
+++ b/intern/opencolorio/fallback_impl.cc
@@ -244,7 +244,7 @@ void FallbackImpl::configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr * /*config*/,
void FallbackImpl::configGetXYZtoRGB(OCIO_ConstConfigRcPtr * /*config*/, float xyz_to_rgb[3][3])
{
/* Default to ITU-BT.709. */
- memcpy(xyz_to_rgb, OCIO_XYZ_TO_LINEAR_SRGB, sizeof(OCIO_XYZ_TO_LINEAR_SRGB));
+ memcpy(xyz_to_rgb, OCIO_XYZ_TO_REC709, sizeof(OCIO_XYZ_TO_REC709));
}
int FallbackImpl::configGetNumLooks(OCIO_ConstConfigRcPtr * /*config*/)
diff --git a/intern/opencolorio/ocio_capi.h b/intern/opencolorio/ocio_capi.h
index 9bd4ec374e2..4be838a218d 100644
--- a/intern/opencolorio/ocio_capi.h
+++ b/intern/opencolorio/ocio_capi.h
@@ -31,10 +31,15 @@ OCIO_DECLARE_HANDLE(OCIO_ConstContextRcPtr);
OCIO_DECLARE_HANDLE(OCIO_PackedImageDesc);
OCIO_DECLARE_HANDLE(OCIO_ConstLookRcPtr);
-/* Standard XYZ to linear sRGB transform, for fallback. */
-static const float OCIO_XYZ_TO_LINEAR_SRGB[3][3] = {{3.2404542f, -0.9692660f, 0.0556434f},
- {-1.5371385f, 1.8760108f, -0.2040259f},
- {-0.4985314f, 0.0415560f, 1.0572252f}};
+/* Standard XYZ (D65) to linear Rec.709 transform. */
+static const float OCIO_XYZ_TO_REC709[3][3] = {{3.2404542f, -0.9692660f, 0.0556434f},
+ {-1.5371385f, 1.8760108f, -0.2040259f},
+ {-0.4985314f, 0.0415560f, 1.0572252f}};
+/* Standard ACES to XYZ (D65) transform.
+ * Matches OpenColorIO builtin transform: UTILITY - ACES-AP0_to_CIE-XYZ-D65_BFD. */
+static const float OCIO_ACES_TO_XYZ[3][3] = {{0.938280f, 0.337369f, 0.001174f},
+ {-0.004451f, 0.729522f, -0.003711f},
+ {0.016628f, -0.066890f, 1.091595f}};
/* This structure is used to pass curve mapping settings from
* blender's DNA structure stored in view transform settings
diff --git a/intern/opencolorio/ocio_impl.cc b/intern/opencolorio/ocio_impl.cc
index 8d9c5dd2d49..a352c54da86 100644
--- a/intern/opencolorio/ocio_impl.cc
+++ b/intern/opencolorio/ocio_impl.cc
@@ -317,7 +317,7 @@ void OCIOImpl::configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config_, float xyz_to_rg
/* 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));
+ memcpy(xyz_to_rgb, OCIO_XYZ_TO_REC709, sizeof(OCIO_XYZ_TO_REC709));
/* Get from OpenColorO config if it has the required roles. */
if (!config->hasRole(ROLE_SCENE_LINEAR)) {
@@ -328,13 +328,8 @@ void OCIOImpl::configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config_, float xyz_to_rg
/* Standard OpenColorIO role, defined as ACES AP0 (ACES2065-1). */
float aces_to_rgb[3][3];
if (to_scene_linear_matrix(config, "aces_interchange", aces_to_rgb)) {
- /* This is the OpenColorIO builtin transform:
- * UTILITY - ACES-AP0_to_CIE-XYZ-D65_BFD. */
- const float ACES_AP0_to_xyz_D65[3][3] = {{0.938280f, 0.337369f, 0.001174f},
- {-0.004451f, 0.729522f, -0.003711f},
- {0.016628f, -0.066890f, 1.091595f}};
float xyz_to_aces[3][3];
- invert_m3_m3(xyz_to_aces, ACES_AP0_to_xyz_D65);
+ invert_m3_m3(xyz_to_aces, OCIO_ACES_TO_XYZ);
mul_m3_m3m3(xyz_to_rgb, aces_to_rgb, xyz_to_aces);
}