Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LOOKDEVX-0000 - Fix legacy CM nodes affected by MaterialX 1.38.8 #3481

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions lib/mayaUsd/render/MaterialXGenOgsXml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -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}"
Expand All @@ -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
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these new files in the 1.37.7 folder are copies of files modified for 1.38.8 before changes.


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;
}
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0"?>
<materialx version="1.38">
<!--
Copyright 2022 Autodesk

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<implementation name="MayaIM_texcoordtangents_vector3_genglsl" nodedef="MayaND_texcoordtangents_vector3" file="libraries/adsk/maya/genglsl/mx_texcoordtangents_vector3.glsl" function="mx_texcoordtangents_vector3" target="genglsl" />
<implementation name="MayaIM_arbitrarytangents_vector3_genglsl" nodedef="MayaND_arbitrarytangents_vector3" file="libraries/adsk/maya/genglsl/mx_arbitrarytangents_vector3.glsl" function="mx_arbitrarytangents_vector3" target="genglsl" />

<implementation name="MayaIM_sRGBtoLinrec709_color3_genglsl" nodedef="MayaND_sRGBtoLinrec709_color3" file="libraries/stdlib/genglsl/mx_srgb_texture_to_lin_rec709_color3.glsl" function="mx_srgb_texture_to_lin_rec709_color3" target="genglsl" />
<implementation name="MayaIM_sRGBtoLinrec709_color4_genglsl" nodedef="MayaND_sRGBtoLinrec709_color4" file="libraries/stdlib/genglsl/mx_srgb_texture_to_lin_rec709_color4.glsl" function="mx_srgb_texture_to_lin_rec709_color4" target="genglsl" />
<implementation name="MayaIM_sRGBtoACEScg_color3_genglsl" nodedef="MayaND_sRGBtoACEScg_color3" file="libraries/adsk/maya/genglsl/mx_srgb_texture_to_acescg_color3.glsl" function="mx_srgb_texture_to_acescg_color3" target="genglsl" />
<implementation name="MayaIM_sRGBtoACEScg_color4_genglsl" nodedef="MayaND_sRGBtoACEScg_color4" file="libraries/adsk/maya/genglsl/mx_srgb_texture_to_acescg_color4.glsl" function="mx_srgb_texture_to_acescg_color4" target="genglsl" />
<implementation name="MayaIM_sRGBtoACES2065_color3_genglsl" nodedef="MayaND_sRGBtoACES2065_color3" file="libraries/adsk/maya/genglsl/mx_srgb_texture_to_aces_2065_1_color3.glsl" function="mx_srgb_texture_to_aces_2065_1_color3" target="genglsl" />
<implementation name="MayaIM_sRGBtoACES2065_color4_genglsl" nodedef="MayaND_sRGBtoACES2065_color4" file="libraries/adsk/maya/genglsl/mx_srgb_texture_to_aces_2065_1_color4.glsl" function="mx_srgb_texture_to_aces_2065_1_color4" target="genglsl" />
<implementation name="MayaIM_sRGBtoLinDCIP3D65_color3_genglsl" nodedef="MayaND_sRGBtoLinDCIP3D65_color3" file="libraries/adsk/maya/genglsl/mx_srgb_texture_to_lin_dci_p3_d65_color3.glsl" function="mx_srgb_texture_to_lin_dci_p3_d65_color3" target="genglsl" />
<implementation name="MayaIM_sRGBtoLinDCIP3D65_color4_genglsl" nodedef="MayaND_sRGBtoLinDCIP3D65_color4" file="libraries/adsk/maya/genglsl/mx_srgb_texture_to_lin_dci_p3_d65_color4.glsl" function="mx_srgb_texture_to_lin_dci_p3_d65_color4" target="genglsl" />
<implementation name="MayaIM_sRGBtoLinrec2020_color3_genglsl" nodedef="MayaND_sRGBtoLinrec2020_color3" file="libraries/adsk/maya/genglsl/mx_srgb_texture_to_linrec2020_color3.glsl" function="mx_srgb_texture_to_linrec2020_color3" target="genglsl" />
<implementation name="MayaIM_sRGBtoLinrec2020_color4_genglsl" nodedef="MayaND_sRGBtoLinrec2020_color4" file="libraries/adsk/maya/genglsl/mx_srgb_texture_to_linrec2020_color4.glsl" function="mx_srgb_texture_to_linrec2020_color4" target="genglsl" />

</materialx>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl"
#include "libraries/adsk/maya/genglsl/lib/usd_transform_color.glsl"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requires copying the old mx_transform_color.glsl to MayaUSD since that file no longer exists in 1.38.8.


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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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));
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<implementation name="MayaIM_texcoordtangents_vector3_genglsl" nodedef="MayaND_texcoordtangents_vector3" file="libraries/adsk/maya/genglsl/mx_texcoordtangents_vector3.glsl" function="mx_texcoordtangents_vector3" target="genglsl" />
<implementation name="MayaIM_arbitrarytangents_vector3_genglsl" nodedef="MayaND_arbitrarytangents_vector3" file="libraries/adsk/maya/genglsl/mx_arbitrarytangents_vector3.glsl" function="mx_arbitrarytangents_vector3" target="genglsl" />

<implementation name="MayaIM_sRGBtoLinrec709_color3_genglsl" nodedef="MayaND_sRGBtoLinrec709_color3" file="libraries/stdlib/genglsl/mx_srgb_texture_to_lin_rec709_color3.glsl" function="mx_srgb_texture_to_lin_rec709_color3" target="genglsl" />
<implementation name="MayaIM_sRGBtoLinrec709_color4_genglsl" nodedef="MayaND_sRGBtoLinrec709_color4" file="libraries/stdlib/genglsl/mx_srgb_texture_to_lin_rec709_color4.glsl" function="mx_srgb_texture_to_lin_rec709_color4" target="genglsl" />
<implementation name="MayaIM_sRGBtoLinrec709_color3_genglsl" nodedef="MayaND_sRGBtoLinrec709_color3" file="libraries/adsk/maya/genglsl/mx_srgb_texture_to_lin_rec709_color3.glsl" function="mx_srgb_texture_to_lin_rec709_color3" target="genglsl" />
<implementation name="MayaIM_sRGBtoLinrec709_color4_genglsl" nodedef="MayaND_sRGBtoLinrec709_color4" file="libraries/adsk/maya/genglsl/mx_srgb_texture_to_lin_rec709_color4.glsl" function="mx_srgb_texture_to_lin_rec709_color4" target="genglsl" />
<implementation name="MayaIM_sRGBtoACEScg_color3_genglsl" nodedef="MayaND_sRGBtoACEScg_color3" file="libraries/adsk/maya/genglsl/mx_srgb_texture_to_acescg_color3.glsl" function="mx_srgb_texture_to_acescg_color3" target="genglsl" />
<implementation name="MayaIM_sRGBtoACEScg_color4_genglsl" nodedef="MayaND_sRGBtoACEScg_color4" file="libraries/adsk/maya/genglsl/mx_srgb_texture_to_acescg_color4.glsl" function="mx_srgb_texture_to_acescg_color4" target="genglsl" />
<implementation name="MayaIM_sRGBtoACES2065_color3_genglsl" nodedef="MayaND_sRGBtoACES2065_color3" file="libraries/adsk/maya/genglsl/mx_srgb_texture_to_aces_2065_1_color3.glsl" function="mx_srgb_texture_to_aces_2065_1_color3" target="genglsl" />
Expand Down