From 63aeb31e078e85ed6612e08ae5bed5e9bb52c79a Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sat, 22 Mar 2014 23:49:14 +0100 Subject: [PATCH] Attempt workaround for fog issue #5384 --- GPU/GLES/ShaderManager.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/GPU/GLES/ShaderManager.cpp b/GPU/GLES/ShaderManager.cpp index 7c80bea04953..b3924e2b8f72 100644 --- a/GPU/GLES/ShaderManager.cpp +++ b/GPU/GLES/ShaderManager.cpp @@ -387,6 +387,14 @@ void LinkedShader::UpdateUniforms(u32 vertType) { // not really sure what a sensible value might be. fogcoef[1] = fogcoef[1] < 0.0f ? -10000.0f : 10000.0f; } + if (my_isnan(fogcoef[1])) { + // Workaround for https://github.com/hrydgard/ppsspp/issues/5384#issuecomment-38365988 + // Just put the fog far away at a large finite distance. + // Infinities and NaNs are rather unpredictable in shaders on many GPUs + // so it's best to just make it a sane calculation. + fogcoef[0] = 100000.0f; + fogcoef[1] = 1.0f; + } glUniform2fv(u_fogcoef, 1, fogcoef); }