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.
This commit is contained in:
Henrik Rydgard 2015-08-27 00:28:16 +02:00
parent 608117085a
commit fecc825e66

View File

@ -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");
}