From fecc825e66b2e9d5d366c950073090bb61d07f47 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Thu, 27 Aug 2015 00:28:16 +0200 Subject: [PATCH] Round depth in the fragment shader. Simpler alternative to #7920 but will not work on ES 2.0, and will in many cases be slower. So possibly this could be an option for modern devices, and possibly for games that #7920 can't fix. --- GPU/GLES/FragmentShaderGenerator.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/GPU/GLES/FragmentShaderGenerator.cpp b/GPU/GLES/FragmentShaderGenerator.cpp index e286241ece..1596d2dea8 100644 --- a/GPU/GLES/FragmentShaderGenerator.cpp +++ b/GPU/GLES/FragmentShaderGenerator.cpp @@ -1003,6 +1003,13 @@ void GenerateFragmentShader(char *buffer) { WRITE(p, " %s = vec4(1,0,1,1);\n", fragColor0); } #endif + + if (true) { + WRITE(p, " highp float z = gl_FragCoord.z;\n"); + WRITE(p, " z = (1.0/65535.0) * floor(z * 65535.0);\n"); + WRITE(p, " gl_FragDepth = z;\n"); + } + WRITE(p, "}\n"); }