From 502dbc7c4a666ce845db6fff160b6ff59e956f4e Mon Sep 17 00:00:00 2001 From: Marcus Brummer Date: Sun, 19 May 2019 21:59:55 +0200 Subject: Use highp precision for gles2 shader uniforms if not explicitly set. The use of different default precision values (highp in vertex; mediump in fragment) for uniform variables caused the shader program to not link properly on some android devices/emulators. --- drivers/gles2/shader_compiler_gles2.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'drivers/gles2') diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index d00b03fb8a..8f3405c71b 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -316,9 +316,14 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener for (Map::Element *E = snode->uniforms.front(); E; E = E->next()) { StringBuffer<> uniform_code; - uniform_code += "uniform "; + // use highp if no precision is specified to prevent different default values in fragment and vertex shader + SL::DataPrecision precision = E->get().precision; + if (precision == SL::PRECISION_DEFAULT) { + precision = SL::PRECISION_HIGHP; + } - uniform_code += _prestr(E->get().precision); + uniform_code += "uniform "; + uniform_code += _prestr(precision); uniform_code += _typestr(E->get().type); uniform_code += " "; uniform_code += _mkid(E->key()); -- cgit v1.2.3