From bec073ba952dcd1ca79279ebc7e2698cbd0a94c3 Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Sat, 19 Oct 2024 11:54:31 -0700 Subject: [PATCH] Additional refinements to GLSL and MSL (#2079) - Provide mx_mod and mx_inverse in both GLSL and MSL. - Remove a legacy preprocessor definition in MSL. --- libraries/stdlib/genglsl/lib/mx_math.glsl | 2 ++ .../stdlib/genglsl/stdlib_genglsl_impl.mtlx | 26 +++++++++---------- .../stdlib/genmsl/stdlib_genmsl_impl.mtlx | 17 ------------ source/MaterialXGenMsl/MslShaderGenerator.cpp | 1 - 4 files changed, 15 insertions(+), 31 deletions(-) diff --git a/libraries/stdlib/genglsl/lib/mx_math.glsl b/libraries/stdlib/genglsl/lib/mx_math.glsl index f87e5653da..d196615e70 100644 --- a/libraries/stdlib/genglsl/lib/mx_math.glsl +++ b/libraries/stdlib/genglsl/lib/mx_math.glsl @@ -1,5 +1,7 @@ #define M_FLOAT_EPS 1e-8 +#define mx_mod mod +#define mx_inverse inverse #define mx_inversesqrt inversesqrt #define mx_sin sin #define mx_cos cos diff --git a/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx b/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx index 765c48c77b..69f8f9a7f8 100644 --- a/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx +++ b/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx @@ -252,17 +252,17 @@ - - - - - - - - - - - + + + + + + + + + + + @@ -458,8 +458,8 @@ - - + + diff --git a/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx b/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx index 1920d04b70..afdfb2cfbb 100644 --- a/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx +++ b/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx @@ -100,19 +100,6 @@ - - - - - - - - - - - - - @@ -122,10 +109,6 @@ - - - - diff --git a/source/MaterialXGenMsl/MslShaderGenerator.cpp b/source/MaterialXGenMsl/MslShaderGenerator.cpp index 5476b33c90..9511fac7ba 100644 --- a/source/MaterialXGenMsl/MslShaderGenerator.cpp +++ b/source/MaterialXGenMsl/MslShaderGenerator.cpp @@ -944,7 +944,6 @@ void MslShaderGenerator::emitPixelStage(const ShaderGraph& graph, GenContext& co emitLine("{}", stage, false); // Add common math functions - emitLine("#define __DECL_GL_MATH_FUNCTIONS__", stage, false); emitLibraryInclude("stdlib/genmsl/lib/mx_math.metal", context, stage); emitLineBreak(stage);