From 4ac0999f7dc9daa2e0b3727f9fa6313ef796739f Mon Sep 17 00:00:00 2001 From: Jerry Gamache Date: Mon, 4 Aug 2025 14:38:05 -0400 Subject: [PATCH 1/3] Align MaterialX to Color Interop recommendations For more details, see the [Texture asset color space](https://github.com/AcademySoftwareFoundation/ColorInterop/blob/main/Recommendations/01_TextureAssetColorSpaces/TextureAssetColorSpaces.md) recommendations. - All names are now based on color interop short names - Deprecated names are now labeled as such - Unit tests still covers all names even older legacy ones - Introduced lin_ap0, lin_rec2020, and srgb_ap1 color spaces --- libraries/cmlib/cmlib_defs.mtlx | 120 ++++++- libraries/cmlib/cmlib_ng.mtlx | 315 +++++++++++++----- .../deprecated_color_management.mtlx | 91 +++++ .../interop_color_management.mtlx | 229 +++++++++++++ .../DefaultColorManagementSystem.cpp | 26 +- 5 files changed, 683 insertions(+), 98 deletions(-) create mode 100644 resources/Materials/TestSuite/stdlib/color_management/deprecated_color_management.mtlx create mode 100644 resources/Materials/TestSuite/stdlib/color_management/interop_color_management.mtlx diff --git a/libraries/cmlib/cmlib_defs.mtlx b/libraries/cmlib/cmlib_defs.mtlx index 0f73109ea7..128d357d9e 100644 --- a/libraries/cmlib/cmlib_defs.mtlx +++ b/libraries/cmlib/cmlib_defs.mtlx @@ -7,6 +7,18 @@ Declarations of the default color transforms in MaterialX. --> + + + + + + + + + + + + @@ -27,66 +39,128 @@ - + - + - + + + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -107,4 +181,26 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/cmlib/cmlib_ng.mtlx b/libraries/cmlib/cmlib_ng.mtlx index 7271bd944b..93872645ec 100644 --- a/libraries/cmlib/cmlib_ng.mtlx +++ b/libraries/cmlib/cmlib_ng.mtlx @@ -7,6 +7,43 @@ Nodegraph implementations for the default color transforms in MaterialX. --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -67,25 +104,28 @@ - + - + - + + + + - + - + - + @@ -97,7 +137,12 @@ - + + + + + + @@ -114,13 +159,16 @@ - + + + + - + - + @@ -132,28 +180,34 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - + - + @@ -165,7 +219,98 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -223,48 +368,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - + - + @@ -276,7 +389,10 @@ - + + + + @@ -295,13 +411,16 @@ - + + + + - + - + @@ -313,17 +432,12 @@ - + - + - - - - - + @@ -335,13 +449,13 @@ - + - + - + @@ -353,10 +467,9 @@ - + - + @@ -371,13 +484,45 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + diff --git a/resources/Materials/TestSuite/stdlib/color_management/deprecated_color_management.mtlx b/resources/Materials/TestSuite/stdlib/color_management/deprecated_color_management.mtlx new file mode 100644 index 0000000000..88dd3a4fb8 --- /dev/null +++ b/resources/Materials/TestSuite/stdlib/color_management/deprecated_color_management.mtlx @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/Materials/TestSuite/stdlib/color_management/interop_color_management.mtlx b/resources/Materials/TestSuite/stdlib/color_management/interop_color_management.mtlx new file mode 100644 index 0000000000..fc09a61082 --- /dev/null +++ b/resources/Materials/TestSuite/stdlib/color_management/interop_color_management.mtlx @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/MaterialXGenShader/DefaultColorManagementSystem.cpp b/source/MaterialXGenShader/DefaultColorManagementSystem.cpp index 06e6e13c17..20559f6d61 100644 --- a/source/MaterialXGenShader/DefaultColorManagementSystem.cpp +++ b/source/MaterialXGenShader/DefaultColorManagementSystem.cpp @@ -13,6 +13,7 @@ namespace { const string CMS_NAME = "default_cms"; +const string INTEROP_SUFFIX = "_scene"; // Remap from legacy color space names to their ACES 1.2 equivalents. const StringMap COLOR_SPACE_REMAP = @@ -20,7 +21,13 @@ const StringMap COLOR_SPACE_REMAP = { "gamma18", "g18_rec709" }, { "gamma22", "g22_rec709" }, { "gamma24", "rec709_display" }, - { "lin_ap1", "acescg" } + + // Remap from 1.38 names to color interop equivalents (minus _scene suffix) + { "acescg", "lin_ap1" }, + { "srgb_displayp3", "srgb_p3d65" }, + { "lin_displayp3", "lin_p3d65" }, + { "srgb_texture", "srgb_rec709" }, + { "adobergb", "g22_adobergb" }, }; } // anonymous namespace @@ -53,6 +60,23 @@ NodeDefPtr DefaultColorManagementSystem::getNodeDef(const ColorSpaceTransform& t string sourceSpace = COLOR_SPACE_REMAP.count(transform.sourceSpace) ? COLOR_SPACE_REMAP.at(transform.sourceSpace) : transform.sourceSpace; string targetSpace = COLOR_SPACE_REMAP.count(transform.targetSpace) ? COLOR_SPACE_REMAP.at(transform.targetSpace) : transform.targetSpace; + + // Color interop short names systematically end in "_scene". We can truncate to keep as + // many names as possible from the 1.38 era. + if (stringEndsWith(sourceSpace, INTEROP_SUFFIX)) + { + sourceSpace = sourceSpace.substr(0, sourceSpace.size() - INTEROP_SUFFIX.size()); + } + if (stringEndsWith(targetSpace, INTEROP_SUFFIX)) + { + targetSpace = targetSpace.substr(0, targetSpace.size() - INTEROP_SUFFIX.size()); + } + + if (sourceSpace == targetSpace) + { + return _document->getNodeDef("ND_dot_" + transform.type.getName()); + } + string nodeName = sourceSpace + "_to_" + targetSpace; for (NodeDefPtr nodeDef : _document->getMatchingNodeDefs(nodeName)) From 59e408b0833d21b896f5ab0affc608a5ff46ba99 Mon Sep 17 00:00:00 2001 From: Jerry Gamache Date: Tue, 5 Aug 2025 09:31:36 -0400 Subject: [PATCH 2/3] Introduce "data" as equivalent to "none" And small tweak to the p3d65 matrix. --- libraries/cmlib/cmlib_ng.mtlx | 4 ++-- source/MaterialXGenShader/ShaderGraph.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/cmlib/cmlib_ng.mtlx b/libraries/cmlib/cmlib_ng.mtlx index 93872645ec..4a0f0e3730 100644 --- a/libraries/cmlib/cmlib_ng.mtlx +++ b/libraries/cmlib/cmlib_ng.mtlx @@ -225,7 +225,7 @@ + value="1.224940176281, -0.042056954710, -0.019637554590, -0.224940176281, 1.042056954710, -0.078636045551, -0.000000000000, 0.000000000000, 1.09827360014" /> @@ -271,7 +271,7 @@ + value="1.224940176281, -0.042056954710, -0.019637554590, -0.224940176281, 1.042056954710, -0.078636045551, -0.000000000000, 0.000000000000, 1.09827360014" /> diff --git a/source/MaterialXGenShader/ShaderGraph.cpp b/source/MaterialXGenShader/ShaderGraph.cpp index 5658de328c..07c9bf1fd0 100644 --- a/source/MaterialXGenShader/ShaderGraph.cpp +++ b/source/MaterialXGenShader/ShaderGraph.cpp @@ -1105,8 +1105,8 @@ void ShaderGraph::populateColorTransformMap(ColorManagementSystemPtr colorManage sourceColorSpace.empty() || targetColorSpace.empty() || sourceColorSpace == targetColorSpace || - sourceColorSpace == "none" || - targetColorSpace == "none") + sourceColorSpace == "none" || sourceColorSpace == "data" + targetColorSpace == "none" || targetColorSpace == "data") { return; } From bba605e7297845644ccf71420f7d578c3406fe6e Mon Sep 17 00:00:00 2001 From: Jerry Gamache Date: Tue, 5 Aug 2025 09:58:36 -0400 Subject: [PATCH 3/3] Fix build. --- source/MaterialXGenShader/ShaderGraph.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/MaterialXGenShader/ShaderGraph.cpp b/source/MaterialXGenShader/ShaderGraph.cpp index 07c9bf1fd0..3110085b35 100644 --- a/source/MaterialXGenShader/ShaderGraph.cpp +++ b/source/MaterialXGenShader/ShaderGraph.cpp @@ -1105,7 +1105,7 @@ void ShaderGraph::populateColorTransformMap(ColorManagementSystemPtr colorManage sourceColorSpace.empty() || targetColorSpace.empty() || sourceColorSpace == targetColorSpace || - sourceColorSpace == "none" || sourceColorSpace == "data" + sourceColorSpace == "none" || sourceColorSpace == "data" || targetColorSpace == "none" || targetColorSpace == "data") { return;