GL3: Use log2 depth scaling in fragment shader #1234
Conversation
Currently a compile time option (!GLES). Fixes many depth issues (Dynamite Cop, Cannon Spike, etc.)
#ifndef GLES | ||
"\ | ||
highp float w = gl_FragCoord.w * 100000.0; \n\ | ||
gl_FragDepth = log2(1.0 + w) / 34.0; \n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess those numbers need some tuning from time to time? I used a (somewhat) similar technique for nullDC, though clamped the exponent part to make sure everything fits - https://github.com/skmp/nulldc/blob/master/nulldc/plugins/drkPvr/ps_hlsl.fx#L143
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, redream was using log2(1 + w * 100) / 24 originally.
I bumped it up as I found one case of loss of precision on very small z.
Alright. We really should make an option out of this as it breaks MSAA on desktop, at some point. |
This is GL3.x isn't it? I don't recall if the GL device is 3.x or 4.x |
OpenGL 1.1 but GLES 3 |
How would this break MSAA? |
iirc the init uses some core profile, so it should be at least 3.x for the desktop |
MSAA depends on per sample depth, the fragment shader runs.. per fragment. so in 16x samples end up with the same depth, effectivelly disabling it. In msaa modes the depth buffer is 2-16x the density of the pixel buffer, to better resolve edges |
Nice! So this finally fixes Cannon Spike on Android too? |
I tested (055c359) the last beta of Google Play and Cannon Spike continued with the same problems. I do not know if any option should be activated. |
I'll try to test the game on standalone pc reicast . |
The master builds are uninstallable on windows for some reason, has anyone been able to successfully install them? |
Nevermind I figured how to install them #813 I tested Cannon Spike and it works on the windows build! So it only works on pc, any chance you guys could port these changes to gles3 so I could be playable on Android? |
blackman91, In the last build of fh / mymaster of flyinghead for Android were repaired the broken graphics of Cannon Spike and the shadow of Sonic Adventure 2, where even allowed me to pass the King Boom Boo boss. But this was only possible because the flyinghead added a system that automatically identifies the GLES version that the device uses. |
Wow that build even fixes the graphics errors of a lot of games like Seaman, Rayman 2, Jedi Power Battles, Zombie Revenge, EGG without performance hit: https://github.com/reicast/gamedb/issues/10 Really impressive fh. |
Currently a compile time option (!GLES). Fixes many depth issues (Dynamite Cop, Cannon Spike, etc.)