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..4a0f0e3730 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 1dcc1bbc55..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,21 +21,13 @@ const StringMap COLOR_SPACE_REMAP = { "gamma18", "g18_rec709" }, { "gamma22", "g22_rec709" }, { "gamma24", "rec709_display" }, - { "lin_ap1", "acescg" }, - - // In 1.39 we remap namespaces from ASWF recommended color interop spaces - // See https://github.com/AcademySoftwareFoundation/ColorInterop - // This should improve interop with the nanocolor spaces found in USD. - {"lin_ap1_scene", "acescg"}, - {"lin_rec709_scene", "lin_rec709"}, - {"lin_p3d65_scene", "lin_displayp3"}, - {"lin_adobergb_scene", "lin_adobergb"}, - {"srgb_rec709_scene", "srgb_texture"}, - {"g22_rec709_scene", "g22_rec709"}, - {"g18_rec709_scene", "g18_rec709"}, - {"g22_ap1_scene", "g22_ap1"}, - {"srgb_p3d65_scene", "srgb_displayp3"}, - {"g22_adobergb_scene", "adobergb"} + + // 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 @@ -67,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)) diff --git a/source/MaterialXGenShader/ShaderGraph.cpp b/source/MaterialXGenShader/ShaderGraph.cpp index 5658de328c..3110085b35 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; }