From 0b1d7a65b90d0ac799ac28a3da8674e3b392611a Mon Sep 17 00:00:00 2001 From: Jerry Gamache Date: Fri, 24 Nov 2023 16:01:47 -0500 Subject: [PATCH] LOOKDEVX-0000 - Fix legacy CM nodes affected by MaterialX 1.38.8 There was a change in MaterialX 1.38.8 that heavily modified the CM implementations provided. Fixing this required copying the relevant code from 1.38.7 to MayaUSD so the nodes can continue working. I have backed-up all the implementation code affected in the 1.38.7 folder, with a version specific install so 1.38.7 continues working. --- .../render/MaterialXGenOgsXml/CMakeLists.txt | 24 ++++++++++++-- ...mx_srgb_texture_to_aces_2065_1_color3.glsl | 11 +++++++ ...mx_srgb_texture_to_aces_2065_1_color4.glsl | 13 ++++++++ .../mx_srgb_texture_to_acescg_color3.glsl | 11 +++++++ .../mx_srgb_texture_to_acescg_color4.glsl | 13 ++++++++ ...srgb_texture_to_lin_dci_p3_d65_color3.glsl | 11 +++++++ ...srgb_texture_to_lin_dci_p3_d65_color4.glsl | 13 ++++++++ .../mx_srgb_texture_to_linrec2020_color3.glsl | 11 +++++++ .../mx_srgb_texture_to_linrec2020_color4.glsl | 13 ++++++++ .../1.38.7/usd_utilities_genglsl_impl.mtlx | 32 +++++++++++++++++++ ...mx_srgb_texture_to_aces_2065_1_color3.glsl | 4 +-- ...mx_srgb_texture_to_aces_2065_1_color4.glsl | 4 +-- .../mx_srgb_texture_to_acescg_color3.glsl | 4 +-- .../mx_srgb_texture_to_acescg_color4.glsl | 4 +-- ...srgb_texture_to_lin_dci_p3_d65_color3.glsl | 4 +-- ...srgb_texture_to_lin_dci_p3_d65_color4.glsl | 4 +-- .../mx_srgb_texture_to_lin_rec709_color3.glsl | 6 ++++ .../mx_srgb_texture_to_lin_rec709_color4.glsl | 6 ++++ .../mx_srgb_texture_to_linrec2020_color3.glsl | 4 +-- .../mx_srgb_texture_to_linrec2020_color4.glsl | 4 +-- .../libraries/usd_transform_color.glsl | 7 ++++ .../libraries/usd_utilities_genglsl_impl.mtlx | 4 +-- 22 files changed, 186 insertions(+), 21 deletions(-) create mode 100644 lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_aces_2065_1_color3.glsl create mode 100644 lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_aces_2065_1_color4.glsl create mode 100644 lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_acescg_color3.glsl create mode 100644 lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_acescg_color4.glsl create mode 100644 lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_lin_dci_p3_d65_color3.glsl create mode 100644 lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_lin_dci_p3_d65_color4.glsl create mode 100644 lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_linrec2020_color3.glsl create mode 100644 lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_linrec2020_color4.glsl create mode 100644 lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/usd_utilities_genglsl_impl.mtlx create mode 100644 lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_lin_rec709_color3.glsl create mode 100644 lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_lin_rec709_color4.glsl create mode 100644 lib/mayaUsd/render/MaterialXGenOgsXml/libraries/usd_transform_color.glsl diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/CMakeLists.txt b/lib/mayaUsd/render/MaterialXGenOgsXml/CMakeLists.txt index 0f4f3e79ba..afc78958f6 100644 --- a/lib/mayaUsd/render/MaterialXGenOgsXml/CMakeLists.txt +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/CMakeLists.txt @@ -58,6 +58,15 @@ list(APPEND NODE_GLSL_IMPLEMENTATIONS_VERSIONED libraries/mx_srgb_texture_to_linrec2020_color4.glsl ) +list(APPEND NODE_GLSL_LIB_VERSIONED + libraries/usd_transform_color.glsl +) + +list(APPEND NODE_GLSL_EXTRA_IMPLEMENTATIONS_VERSIONED + libraries/mx_srgb_texture_to_lin_rec709_color3.glsl + libraries/mx_srgb_texture_to_lin_rec709_color4.glsl +) + # ----------------------------------------------------------------------------- # promote headers # ----------------------------------------------------------------------------- @@ -95,9 +104,12 @@ if(MaterialX_VERSION VERSION_LESS "1.38.4") endforeach() elseif(MaterialX_VERSION VERSION_LESS "1.38.8") MESSAGE(STATUS "Using 1.38.[4-7] libraries with MaterialX ${MaterialX_VERSION}") - install(FILES ${NODE_GLSL_IMPLEMENTATIONS_VERSIONED} - DESTINATION ${CMAKE_INSTALL_PREFIX}/libraries/adsk/maya/genglsl - ) + foreach(MTLX_FILE ${NODE_GLSL_IMPLEMENTATIONS_VERSIONED}) + string(REPLACE "libraries/" "libraries/1.38.7/" MTLX_FILE ${MTLX_FILE}) + install(FILES "${MTLX_FILE}" + DESTINATION ${CMAKE_INSTALL_PREFIX}/libraries/adsk/maya/genglsl + ) + endforeach() foreach(MTLX_FILE ${LIGHT_IMPLEMENTATIONS}) string(REPLACE "libraries/" "libraries/1.38.7/" MTLX_FILE ${MTLX_FILE}) install(FILES "${MTLX_FILE}" @@ -109,6 +121,12 @@ else() install(FILES ${NODE_GLSL_IMPLEMENTATIONS_VERSIONED} DESTINATION ${CMAKE_INSTALL_PREFIX}/libraries/adsk/maya/genglsl ) + install(FILES ${NODE_GLSL_EXTRA_IMPLEMENTATIONS_VERSIONED} + DESTINATION ${CMAKE_INSTALL_PREFIX}/libraries/adsk/maya/genglsl + ) + install(FILES ${NODE_GLSL_LIB_VERSIONED} + DESTINATION ${CMAKE_INSTALL_PREFIX}/libraries/adsk/maya/genglsl/lib + ) install(FILES ${LIGHT_IMPLEMENTATIONS} DESTINATION ${CMAKE_INSTALL_PREFIX}/libraries/pbrlib/genglsl/ogsxml ) diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_aces_2065_1_color3.glsl b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_aces_2065_1_color3.glsl new file mode 100644 index 0000000000..a73cd13167 --- /dev/null +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_aces_2065_1_color3.glsl @@ -0,0 +1,11 @@ +#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" + +void mx_srgb_texture_to_aces_2065_1_color3(vec3 _in, out vec3 result) +{ + result = mx_srgb_texture_to_lin_rec709(_in); + + // Same matrix as found in ../../vp2ShaderFragments/shaderFragments.cpp + result = mat3(0.43963298, 0.08977644, 0.01754117, + 0.38298870, 0.81343943, 0.11154655, + 0.17737832, 0.09678413, 0.87091228) * result; +} diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_aces_2065_1_color4.glsl b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_aces_2065_1_color4.glsl new file mode 100644 index 0000000000..813b7dbb26 --- /dev/null +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_aces_2065_1_color4.glsl @@ -0,0 +1,13 @@ +#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" + +void mx_srgb_texture_to_aces_2065_1_color4(vec4 _in, out vec4 result) +{ + vec3 color = mx_srgb_texture_to_lin_rec709(_in.rgb); + + // Same matrix as found in ../../vp2ShaderFragments/shaderFragments.cpp + color = mat3(0.43963298, 0.08977644, 0.01754117, + 0.38298870, 0.81343943, 0.11154655, + 0.17737832, 0.09678413, 0.87091228) * color; + + result = vec4(color, _in.a); +} diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_acescg_color3.glsl b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_acescg_color3.glsl new file mode 100644 index 0000000000..be922b4c17 --- /dev/null +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_acescg_color3.glsl @@ -0,0 +1,11 @@ +#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" + +void mx_srgb_texture_to_acescg_color3(vec3 _in, out vec3 result) +{ + result = mx_srgb_texture_to_lin_rec709(_in); + + // Same matrix as found in ../../vp2ShaderFragments/shaderFragments.cpp + result = mat3(0.61309740, 0.07019372, 0.02061559, + 0.33952315, 0.91635388, 0.10956977, + 0.04737945, 0.01345240, 0.86981463) * result; +} diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_acescg_color4.glsl b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_acescg_color4.glsl new file mode 100644 index 0000000000..feefa87e9b --- /dev/null +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_acescg_color4.glsl @@ -0,0 +1,13 @@ +#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" + +void mx_srgb_texture_to_acescg_color4(vec4 _in, out vec4 result) +{ + vec3 color = mx_srgb_texture_to_lin_rec709(_in.rgb); + + // Same matrix as found in ../../vp2ShaderFragments/shaderFragments.cpp + color = mat3(0.61309740, 0.07019372, 0.02061559, + 0.33952315, 0.91635388, 0.10956977, + 0.04737945, 0.01345240, 0.86981463) * color; + + result = vec4(color, _in.a); +} diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_lin_dci_p3_d65_color3.glsl b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_lin_dci_p3_d65_color3.glsl new file mode 100644 index 0000000000..2e7748ba2b --- /dev/null +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_lin_dci_p3_d65_color3.glsl @@ -0,0 +1,11 @@ +#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" + +void mx_srgb_texture_to_lin_dci_p3_d65_color3(vec3 _in, out vec3 result) +{ + result = mx_srgb_texture_to_lin_rec709(_in); + + // Same matrix as found in ../../vp2ShaderFragments/shaderFragments.cpp + result = mat3(0.82246197, 0.03319420, 0.01708263, + 0.17753803, 0.96680580, 0.07239744, + 0., 0., 0.91051993) * result; +} diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_lin_dci_p3_d65_color4.glsl b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_lin_dci_p3_d65_color4.glsl new file mode 100644 index 0000000000..03105f4b83 --- /dev/null +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_lin_dci_p3_d65_color4.glsl @@ -0,0 +1,13 @@ +#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" + +void mx_srgb_texture_to_lin_dci_p3_d65_color4(vec4 _in, out vec4 result) +{ + vec3 color = mx_srgb_texture_to_lin_rec709(_in.rgb); + + // Same matrix as found in ../../vp2ShaderFragments/shaderFragments.cpp + color = mat3(0.82246197, 0.03319420, 0.01708263, + 0.17753803, 0.96680580, 0.07239744, + 0., 0., 0.91051993) * color; + + result = vec4(color, _in.a); +} diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_linrec2020_color3.glsl b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_linrec2020_color3.glsl new file mode 100644 index 0000000000..f98b4dcddc --- /dev/null +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_linrec2020_color3.glsl @@ -0,0 +1,11 @@ +#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" + +void mx_srgb_texture_to_linrec2020_color3(vec3 _in, out vec3 result) +{ + result = mx_srgb_texture_to_lin_rec709(_in); + + // Same matrix as found in ../../vp2ShaderFragments/shaderFragments.cpp + result = mat3(0.62740389, 0.06909729, 0.01639144, + 0.32928304, 0.91954039, 0.08801331, + 0.04331307, 0.01136232, 0.89559525) * result; +} diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_linrec2020_color4.glsl b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_linrec2020_color4.glsl new file mode 100644 index 0000000000..65be01311a --- /dev/null +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/mx_srgb_texture_to_linrec2020_color4.glsl @@ -0,0 +1,13 @@ +#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" + +void mx_srgb_texture_to_linrec2020_color4(vec4 _in, out vec4 result) +{ + vec3 color = mx_srgb_texture_to_lin_rec709(_in.rgb); + + // Same matrix as found in ../../vp2ShaderFragments/shaderFragments.cpp + color = mat3(0.62740389, 0.06909729, 0.01639144, + 0.32928304, 0.91954039, 0.08801331, + 0.04331307, 0.01136232, 0.89559525) * color; + + result = vec4(color, _in.a); +} diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/usd_utilities_genglsl_impl.mtlx b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/usd_utilities_genglsl_impl.mtlx new file mode 100644 index 0000000000..05670c54b7 --- /dev/null +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/1.38.7/usd_utilities_genglsl_impl.mtlx @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_aces_2065_1_color3.glsl b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_aces_2065_1_color3.glsl index a73cd13167..2f1d11d275 100644 --- a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_aces_2065_1_color3.glsl +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_aces_2065_1_color3.glsl @@ -1,8 +1,8 @@ -#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" +#include "libraries/adsk/maya/genglsl/lib/usd_transform_color.glsl" void mx_srgb_texture_to_aces_2065_1_color3(vec3 _in, out vec3 result) { - result = mx_srgb_texture_to_lin_rec709(_in); + result = usd_srgb_texture_to_lin_rec709(_in); // Same matrix as found in ../../vp2ShaderFragments/shaderFragments.cpp result = mat3(0.43963298, 0.08977644, 0.01754117, diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_aces_2065_1_color4.glsl b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_aces_2065_1_color4.glsl index 813b7dbb26..511b8e0252 100644 --- a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_aces_2065_1_color4.glsl +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_aces_2065_1_color4.glsl @@ -1,8 +1,8 @@ -#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" +#include "libraries/adsk/maya/genglsl/lib/usd_transform_color.glsl" void mx_srgb_texture_to_aces_2065_1_color4(vec4 _in, out vec4 result) { - vec3 color = mx_srgb_texture_to_lin_rec709(_in.rgb); + vec3 color = usd_srgb_texture_to_lin_rec709(_in.rgb); // Same matrix as found in ../../vp2ShaderFragments/shaderFragments.cpp color = mat3(0.43963298, 0.08977644, 0.01754117, diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_acescg_color3.glsl b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_acescg_color3.glsl index be922b4c17..3e5935aa1a 100644 --- a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_acescg_color3.glsl +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_acescg_color3.glsl @@ -1,8 +1,8 @@ -#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" +#include "libraries/adsk/maya/genglsl/lib/usd_transform_color.glsl" void mx_srgb_texture_to_acescg_color3(vec3 _in, out vec3 result) { - result = mx_srgb_texture_to_lin_rec709(_in); + result = usd_srgb_texture_to_lin_rec709(_in); // Same matrix as found in ../../vp2ShaderFragments/shaderFragments.cpp result = mat3(0.61309740, 0.07019372, 0.02061559, diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_acescg_color4.glsl b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_acescg_color4.glsl index feefa87e9b..09d3d4db85 100644 --- a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_acescg_color4.glsl +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_acescg_color4.glsl @@ -1,8 +1,8 @@ -#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" +#include "libraries/adsk/maya/genglsl/lib/usd_transform_color.glsl" void mx_srgb_texture_to_acescg_color4(vec4 _in, out vec4 result) { - vec3 color = mx_srgb_texture_to_lin_rec709(_in.rgb); + vec3 color = usd_srgb_texture_to_lin_rec709(_in.rgb); // Same matrix as found in ../../vp2ShaderFragments/shaderFragments.cpp color = mat3(0.61309740, 0.07019372, 0.02061559, diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_lin_dci_p3_d65_color3.glsl b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_lin_dci_p3_d65_color3.glsl index 2e7748ba2b..d4fc31669f 100644 --- a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_lin_dci_p3_d65_color3.glsl +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_lin_dci_p3_d65_color3.glsl @@ -1,8 +1,8 @@ -#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" +#include "libraries/adsk/maya/genglsl/lib/usd_transform_color.glsl" void mx_srgb_texture_to_lin_dci_p3_d65_color3(vec3 _in, out vec3 result) { - result = mx_srgb_texture_to_lin_rec709(_in); + result = usd_srgb_texture_to_lin_rec709(_in); // Same matrix as found in ../../vp2ShaderFragments/shaderFragments.cpp result = mat3(0.82246197, 0.03319420, 0.01708263, diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_lin_dci_p3_d65_color4.glsl b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_lin_dci_p3_d65_color4.glsl index 03105f4b83..ff3c0cc408 100644 --- a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_lin_dci_p3_d65_color4.glsl +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_lin_dci_p3_d65_color4.glsl @@ -1,8 +1,8 @@ -#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" +#include "libraries/adsk/maya/genglsl/lib/usd_transform_color.glsl" void mx_srgb_texture_to_lin_dci_p3_d65_color4(vec4 _in, out vec4 result) { - vec3 color = mx_srgb_texture_to_lin_rec709(_in.rgb); + vec3 color = usd_srgb_texture_to_lin_rec709(_in.rgb); // Same matrix as found in ../../vp2ShaderFragments/shaderFragments.cpp color = mat3(0.82246197, 0.03319420, 0.01708263, diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_lin_rec709_color3.glsl b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_lin_rec709_color3.glsl new file mode 100644 index 0000000000..7f65fd7b93 --- /dev/null +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_lin_rec709_color3.glsl @@ -0,0 +1,6 @@ +#include "libraries/adsk/maya/genglsl/lib/usd_transform_color.glsl" + +void mx_srgb_texture_to_lin_rec709_color3(vec3 _in, out vec3 result) +{ + result = usd_srgb_texture_to_lin_rec709(_in); +} diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_lin_rec709_color4.glsl b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_lin_rec709_color4.glsl new file mode 100644 index 0000000000..02b1aa1216 --- /dev/null +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_lin_rec709_color4.glsl @@ -0,0 +1,6 @@ +#include "libraries/adsk/maya/genglsl/lib/usd_transform_color.glsl" + +void mx_srgb_texture_to_lin_rec709_color4(vec4 _in, out vec4 result) +{ + result = vec4(usd_srgb_texture_to_lin_rec709(_in.rgb), _in.a); +} diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_linrec2020_color3.glsl b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_linrec2020_color3.glsl index f98b4dcddc..ffe10f636f 100644 --- a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_linrec2020_color3.glsl +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_linrec2020_color3.glsl @@ -1,8 +1,8 @@ -#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" +#include "libraries/adsk/maya/genglsl/lib/usd_transform_color.glsl" void mx_srgb_texture_to_linrec2020_color3(vec3 _in, out vec3 result) { - result = mx_srgb_texture_to_lin_rec709(_in); + result = usd_srgb_texture_to_lin_rec709(_in); // Same matrix as found in ../../vp2ShaderFragments/shaderFragments.cpp result = mat3(0.62740389, 0.06909729, 0.01639144, diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_linrec2020_color4.glsl b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_linrec2020_color4.glsl index 65be01311a..82d6f13560 100644 --- a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_linrec2020_color4.glsl +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/mx_srgb_texture_to_linrec2020_color4.glsl @@ -1,8 +1,8 @@ -#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" +#include "libraries/adsk/maya/genglsl/lib/usd_transform_color.glsl" void mx_srgb_texture_to_linrec2020_color4(vec4 _in, out vec4 result) { - vec3 color = mx_srgb_texture_to_lin_rec709(_in.rgb); + vec3 color = usd_srgb_texture_to_lin_rec709(_in.rgb); // Same matrix as found in ../../vp2ShaderFragments/shaderFragments.cpp color = mat3(0.62740389, 0.06909729, 0.01639144, diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/usd_transform_color.glsl b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/usd_transform_color.glsl new file mode 100644 index 0000000000..2c9d96282a --- /dev/null +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/usd_transform_color.glsl @@ -0,0 +1,7 @@ +vec3 usd_srgb_texture_to_lin_rec709(vec3 color) +{ + bvec3 isAbove = greaterThan(color, vec3(0.04045)); + vec3 linSeg = color / 12.92; + vec3 powSeg = pow(max(color + vec3(0.055), vec3(0.0)) / 1.055, vec3(2.4)); + return mix(linSeg, powSeg, vec3(isAbove)); +} diff --git a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/usd_utilities_genglsl_impl.mtlx b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/usd_utilities_genglsl_impl.mtlx index 05670c54b7..b7c78fc3be 100644 --- a/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/usd_utilities_genglsl_impl.mtlx +++ b/lib/mayaUsd/render/MaterialXGenOgsXml/libraries/usd_utilities_genglsl_impl.mtlx @@ -18,8 +18,8 @@ - - + +