From d2d1d4a2ef1af1db35bd42bfe6625788821d4234 Mon Sep 17 00:00:00 2001 From: Bernard Kwok Date: Fri, 27 Feb 2026 08:45:22 -0500 Subject: [PATCH 1/2] Use highp for ESSL always and adjust float tolerance to avoid possible underflow. --- libraries/stdlib/genglsl/lib/mx_math.glsl | 6 +++++- source/MaterialXGenGlsl/EsslShaderGenerator.cpp | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libraries/stdlib/genglsl/lib/mx_math.glsl b/libraries/stdlib/genglsl/lib/mx_math.glsl index 1f02bd0589..485aec2787 100644 --- a/libraries/stdlib/genglsl/lib/mx_math.glsl +++ b/libraries/stdlib/genglsl/lib/mx_math.glsl @@ -1,4 +1,8 @@ -#define M_FLOAT_EPS 1e-8 +#ifdef GL_ES + #define M_FLOAT_EPS 0.0001 +#else + #define M_FLOAT_EPS 1e-8 +#endif #define mx_mod mod #define mx_inverse inverse diff --git a/source/MaterialXGenGlsl/EsslShaderGenerator.cpp b/source/MaterialXGenGlsl/EsslShaderGenerator.cpp index ca54b78db7..8c074ea555 100644 --- a/source/MaterialXGenGlsl/EsslShaderGenerator.cpp +++ b/source/MaterialXGenGlsl/EsslShaderGenerator.cpp @@ -27,7 +27,9 @@ void EsslShaderGenerator::emitDirectives(GenContext&, ShaderStage& stage) const { emitLine("#version " + getVersion(), stage, false); emitLineBreak(stage); - emitLine("precision mediump float", stage); + // ESSL 3.0+ is used where highp float is considered mandatory. + // (See https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf) + emitLine("precision highp float", stage); emitLineBreak(stage); } From 80b28974fd06c13de71cbdaf7a9cde29371d7165 Mon Sep 17 00:00:00 2001 From: Bernard Kwok Date: Sat, 28 Feb 2026 09:27:14 -0500 Subject: [PATCH 2/2] Reverse tolerance change. --- libraries/stdlib/genglsl/lib/mx_math.glsl | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libraries/stdlib/genglsl/lib/mx_math.glsl b/libraries/stdlib/genglsl/lib/mx_math.glsl index 485aec2787..1f02bd0589 100644 --- a/libraries/stdlib/genglsl/lib/mx_math.glsl +++ b/libraries/stdlib/genglsl/lib/mx_math.glsl @@ -1,8 +1,4 @@ -#ifdef GL_ES - #define M_FLOAT_EPS 0.0001 -#else - #define M_FLOAT_EPS 1e-8 -#endif +#define M_FLOAT_EPS 1e-8 #define mx_mod mod #define mx_inverse inverse