Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

GL3: Use log2 depth scaling in fragment shader #1234

Merged
merged 1 commit into from Jul 23, 2018
Merged

Conversation

flyinghead
Copy link
Contributor

Currently a compile time option (!GLES). Fixes many depth issues (Dynamite Cop, Cannon Spike, etc.)

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"
Copy link
Owner

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

Copy link
Contributor Author

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.

@skmp
Copy link
Owner

skmp commented Jul 23, 2018

Alright. We really should make an option out of this as it breaks MSAA on desktop, at some point.

@skmp skmp changed the title Use log2 depth scaling in fragment shader when available. GL3: Use log2 depth scaling in fragment shader Jul 23, 2018
@skmp skmp merged commit 055c359 into master Jul 23, 2018
@skmp
Copy link
Owner

skmp commented Jul 23, 2018

This is GL3.x isn't it? I don't recall if the GL device is 3.x or 4.x

@flyinghead
Copy link
Contributor Author

OpenGL 1.1 but GLES 3

@flyinghead
Copy link
Contributor Author

How would this break MSAA?

@skmp
Copy link
Owner

skmp commented Jul 23, 2018

iirc the init uses some core profile, so it should be at least 3.x for the desktop

@flyinghead flyinghead deleted the fh/log2-depth-scaling branch July 23, 2018 13:29
@skmp
Copy link
Owner

skmp commented Jul 23, 2018

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

@blackman91
Copy link

Nice! So this finally fixes Cannon Spike on Android too?

@Deivmsr
Copy link

Deivmsr commented Jul 23, 2018

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.

@blackman91
Copy link

Yeah just tested the same version and no combination of settings fixes it, the bug still present, I guess this only works on the pc version:
screenshot_20180723-160154

@blackman91
Copy link

I'll try to test the game on standalone pc reicast .

@blackman91
Copy link

The master builds are uninstallable on windows for some reason, has anyone been able to successfully install them?

@blackman91
Copy link

Nevermind I figured how to install them #813

I tested Cannon Spike and it works on the windows build!
cannonspikeworking

So it only works on pc, any chance you guys could port these changes to gles3 so I could be playable on Android?

@Deivmsr
Copy link

Deivmsr commented Aug 8, 2018

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.

@blackman91
Copy link

blackman91 commented Aug 8, 2018

Holy shit you are right, Cannon Spike is finally playable after all these years on mobile on flyinghead branch!!! Amazing job as usual, it even fixes a lot of bugs in other games like EGG and the performance is perfect even on motog5:
screenshot_20180807-212943

Hope these changes come to the main branch because no background service. Either way these are awesome news, great job devs.

@blackman91
Copy link

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:
skmp/reicast-gamedb#7

skmp/reicast-gamedb#8

skmp/reicast-gamedb#9

https://github.com/reicast/gamedb/issues/10

skmp/reicast-gamedb#11

Really impressive fh.

@blackman91
Copy link

Bug report: on latest fh my master instead of black bars to the sides you get this:
screenshot_20180808-022025

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants