Skip to content

Commit 72d59cb

Browse files
authored
Use high precision in generated ESSL (#2792)
## Change - Specify `highp` to use 32-bit precision with ESSL Fixes: #2655, #2654. ### Details High Precision Change The minimum ESSL version required is 3.0 , where `highp` precision is mandatory in fragment shaders, so the switch is safe. Instead of IEEE 754 half‑precision (16‑bit) we now use single‑precision (32‑bit). This avoids cases of underflow/overflow and reduces accumulated math errors (for Std surface, OpenPBR and glTF).
1 parent eae43db commit 72d59cb

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

source/MaterialXGenGlsl/EsslShaderGenerator.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ void EsslShaderGenerator::emitDirectives(GenContext&, ShaderStage& stage) const
2727
{
2828
emitLine("#version " + getVersion(), stage, false);
2929
emitLineBreak(stage);
30-
emitLine("precision mediump float", stage);
30+
// ESSL 3.0+ is used where highp float is considered mandatory.
31+
// (See https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf)
32+
emitLine("precision highp float", stage);
3133
emitLineBreak(stage);
3234
}
3335

0 commit comments

Comments
 (0)