Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VertexShaderGen: Move the sonic epsilon hack to the vertex shader. #4164

Merged
merged 1 commit into from
Sep 1, 2016

Conversation

CrossVR
Copy link
Contributor

@CrossVR CrossVR commented Aug 30, 2016

In the vertex shader we have control over the depth clipping planes, so we don't have to offset every floating point value and lose accuracy. This fixes z fighting in the Metroid Prime visor. It also make slow depth a lot more accurate.

It has also been confirmed that the only reason the SW backend rendered the Sonic Adventure/Unleashed UIs correctly was because of its own version of the epsilon hack: https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/VideoBackends/Software/TransformUnit.cpp#L60

We can't use the exact same hack as the SW backend because our depth comparison is done in floats instead of integers and is therefore sensitive to rounding errors introduced by adding an epsilon to all depth values.


This change is Reviewable

@CrossVR CrossVR added the WIP / do not merge Work in progress (do not merge) label Aug 31, 2016
@ghost
Copy link

ghost commented Aug 31, 2016

There are issues in ogl-lin-intel / nfsu-reflections, ogl-lin-intel / fishing-resort-map, ogl-lin-intel / inverted-depth-range, and potentially others.

@JMC47
Copy link
Contributor

JMC47 commented Aug 31, 2016

The latest run should have resolved them.

@ghost
Copy link

ghost commented Aug 31, 2016

ogl-lin-intel / fishing-resort-map appears to be fixed but the other two still exhibit changes.

@JMC47
Copy link
Contributor

JMC47 commented Aug 31, 2016

the other two are broken fifologs and should be ignored

@CrossVR CrossVR added the RFC Request for comments label Aug 31, 2016
@CrossVR
Copy link
Contributor Author

CrossVR commented Aug 31, 2016

Things look fine now, but I'd still like some comment on whether my 1 / w accurately represents the smallest unit of depth. Another option is to just use an epsilon of 0.00001 or similar.

@CrossVR CrossVR removed the WIP / do not merge Work in progress (do not merge) label Aug 31, 2016
@CrossVR
Copy link
Contributor Author

CrossVR commented Aug 31, 2016

Switched to an arbitrary small value after all. Note that simply using an epsilon value doesn't work, not even if I multiply it by z as would be implied by the projection matrix.

In the vertex shader we have control over the depth clipping planes,
so we don't have to offset every floating point value and lose accuracy.
@CrossVR CrossVR removed the RFC Request for comments label Sep 1, 2016
@degasus
Copy link
Member

degasus commented Sep 1, 2016

I like to move those hacks to farer stages, so LGTM. But I have no clue about the impact on the z accuracy...

@CrossVR CrossVR merged commit 50984d8 into dolphin-emu:master Sep 1, 2016
@dolphin-emu-bot
Copy link
Contributor

FifoCI detected that this change impacts graphical rendering. Here are the behavior differences detected by the system:

  • ab11-homebrew on ogl-lin-intel: diff
  • aeon-charge-attack on ogl-lin-intel: diff
  • chibi-robo-fastdepth on ogl-lin-intel: diff
  • chibi-robo-zfighting on ogl-lin-intel: diff
  • custom-brawl-char on ogl-lin-intel: diff
  • dbz-depth on ogl-lin-intel: diff
  • djfny-menu on ogl-lin-intel: diff
  • DKCR-Char on ogl-lin-intel: diff
  • DKCR-fast-depth on ogl-lin-intel: diff
  • ed-updated on ogl-lin-intel: diff
  • fifa-street on ogl-lin-intel: diff
  • find-mii on ogl-lin-intel: diff
  • fishing-resort-map on ogl-lin-intel: diff
  • fortune-street on ogl-lin-intel: diff
  • fortune-street-fog on ogl-lin-intel: diff
  • fortune-street-white-box on ogl-lin-intel: diff
  • fsa-layers on ogl-lin-intel: diff
  • f-zero-rain on ogl-lin-intel: diff
  • goldeneye-depth on ogl-lin-intel: diff
  • inverted-depth-range on ogl-lin-intel: diff
  • kirby-shadows on ogl-lin-intel: diff
  • last-story-shadows on ogl-lin-intel: diff
  • lego-star-wars-crane-shadow on ogl-lin-intel: diff
  • lesson08 on ogl-lin-intel: diff
  • line-width-test on ogl-lin-intel: diff
  • luigi-shadows on ogl-lin-intel: diff
  • mario-baseball-shadows on ogl-lin-intel: diff
  • mario-sluggers-bar on ogl-lin-intel: diff
  • mario-tennis-menu on ogl-lin-intel: diff
  • MaS-LOG-wiimote on ogl-lin-intel: diff
  • medabots-crash on ogl-lin-intel: diff
  • megaman-heat on ogl-lin-intel: diff
  • melee-depth on ogl-lin-intel: diff
  • melee-lighting on ogl-lin-intel: diff
  • metroid-visor on ogl-lin-intel: diff
  • mii-channel on ogl-lin-intel: diff
  • milotic-texture on ogl-lin-intel: diff
  • mini-ninjas on ogl-lin-intel: diff
  • mkdd-babypark on ogl-lin-intel: diff
  • mkdd-efb on ogl-lin-intel: diff
  • mkwii-bluebox on ogl-lin-intel: diff
  • monkeyball-fuse on ogl-lin-intel: diff
  • mp3-bloom on ogl-lin-intel: diff
  • mp7-text on ogl-lin-intel: diff
  • mtennis-zfreeze on ogl-lin-intel: diff
  • my-word-coach on ogl-lin-intel: diff
  • nddemo-bumpmapping on ogl-lin-intel: diff
  • nddemo-lighting on ogl-lin-intel: diff
  • nfsu-purplerect on ogl-lin-intel: diff
  • nfsu-reflections on ogl-lin-intel: diff
  • nsmbw-coins on ogl-lin-intel: diff
  • nsmbw-intro on ogl-lin-intel: diff
  • pm-hc-jp on ogl-lin-intel: diff
  • rs2-bumpmapping on ogl-lin-intel: diff
  • rs2-glass on ogl-lin-intel: diff
  • rs2-skybox on ogl-lin-intel: diff
  • rs2-zfreeze on ogl-lin-intel: diff
  • rs3-bumpmapping on ogl-lin-intel: diff
  • sadx-ui on ogl-lin-intel: diff
  • sfa-shadows on ogl-lin-intel: diff
  • sf-assault-flashing on ogl-lin-intel: diff
  • simpsons-game on ogl-lin-intel: diff
  • smg2-fog on ogl-lin-intel: diff
  • smg-marioeyes on ogl-lin-intel: diff
  • sms-bubbles on ogl-lin-intel: diff
  • sms-gc on ogl-lin-intel: diff
  • sms-water on ogl-lin-intel: diff
  • soa-black on ogl-lin-intel: diff
  • soniccolors-mm on ogl-lin-intel: diff
  • sonic-riders-blur on ogl-lin-intel: diff
  • sonicriderszg-gb on ogl-lin-intel: diff
  • spyro-bloom on ogl-lin-intel: diff
  • spyro-depth on ogl-lin-intel: diff
  • ssbb-mod-lloyd on ogl-lin-intel: diff
  • ssbm-pointsize on ogl-lin-intel: diff
  • ss-map on ogl-lin-intel: diff
  • ss-timestone on ogl-lin-intel: diff
  • super-sluggers-white-out on ogl-lin-intel: diff
  • sw3-dt on ogl-lin-intel: diff
  • taiko-depth on ogl-lin-intel: diff
  • thps3-earlyz on ogl-lin-intel: diff
  • thps4-shadow on ogl-lin-intel: diff
  • tla-menu on ogl-lin-intel: diff
  • tos-invis-char on ogl-lin-intel: diff
  • tsp3-pinkgrass on ogl-lin-intel: diff
  • vegas-party-depth on ogl-lin-intel: diff
  • xenoblade-menu on ogl-lin-intel: diff
  • ztp-grass on ogl-lin-intel: diff
  • zww-armos on ogl-lin-intel: diff
  • zww-water on ogl-lin-intel: diff
  • zww-waves on ogl-lin-intel: diff
  • ab11-homebrew on ogl-lin-mesa: diff
  • aeon-charge-attack on ogl-lin-mesa: diff
  • cel-damage-lighting on ogl-lin-mesa: diff
  • chibi-robo-fastdepth on ogl-lin-mesa: diff
  • chibi-robo-zfighting on ogl-lin-mesa: diff
  • custom-brawl-char on ogl-lin-mesa: diff
  • dbz-depth on ogl-lin-mesa: diff
  • djfny-menu on ogl-lin-mesa: diff
  • DKCR-Char on ogl-lin-mesa: diff
  • DKCR-fast-depth on ogl-lin-mesa: diff
  • ed-updated on ogl-lin-mesa: diff
  • et-vid on ogl-lin-mesa: diff
  • fifa-street on ogl-lin-mesa: diff
  • find-mii on ogl-lin-mesa: diff
  • fishing-resort-map on ogl-lin-mesa: diff
  • fortune-street on ogl-lin-mesa: diff
  • fortune-street-fog on ogl-lin-mesa: diff
  • fortune-street-white-box on ogl-lin-mesa: diff
  • fsa-layers on ogl-lin-mesa: diff
  • f-zero-rain on ogl-lin-mesa: diff
  • inverted-depth-range on ogl-lin-mesa: diff
  • kirby-shadows on ogl-lin-mesa: diff
  • last-story-shadows on ogl-lin-mesa: diff
  • lego-star-wars-crane-shadow on ogl-lin-mesa: diff
  • lesson08 on ogl-lin-mesa: diff
  • luigi-shadows on ogl-lin-mesa: diff
  • mario-baseball-shadows on ogl-lin-mesa: diff
  • mario-sluggers-bar on ogl-lin-mesa: diff
  • mario-tennis-menu on ogl-lin-mesa: diff
  • MaS-LOG-wiimote on ogl-lin-mesa: diff
  • medabots-crash on ogl-lin-mesa: diff
  • megaman-heat on ogl-lin-mesa: diff
  • melee-depth on ogl-lin-mesa: diff
  • melee-lighting on ogl-lin-mesa: diff
  • metroid-visor on ogl-lin-mesa: diff
  • mii-channel on ogl-lin-mesa: diff
  • milotic-texture on ogl-lin-mesa: diff
  • mini-ninjas on ogl-lin-mesa: diff
  • mkdd-babypark on ogl-lin-mesa: diff
  • mkdd-efb on ogl-lin-mesa: diff
  • mkwii-bluebox on ogl-lin-mesa: diff
  • monkeyball-fuse on ogl-lin-mesa: diff
  • mp3-bloom on ogl-lin-mesa: diff
  • mp7-text on ogl-lin-mesa: diff
  • mtennis-zfreeze on ogl-lin-mesa: diff
  • my-word-coach on ogl-lin-mesa: diff
  • nddemo-bumpmapping on ogl-lin-mesa: diff
  • nddemo-lighting on ogl-lin-mesa: diff
  • nfsu-purplerect on ogl-lin-mesa: diff
  • nfsu-reflections on ogl-lin-mesa: diff
  • nsmbw-coins on ogl-lin-mesa: diff
  • nsmbw-intro on ogl-lin-mesa: diff
  • pm-hc-jp on ogl-lin-mesa: diff
  • pw-black-bars on ogl-lin-mesa: diff
  • rs2-bumpmapping on ogl-lin-mesa: diff
  • rs2-glass on ogl-lin-mesa: diff
  • rs2-skybox on ogl-lin-mesa: diff
  • rs2-zfreeze on ogl-lin-mesa: diff
  • rs3-bumpmapping on ogl-lin-mesa: diff
  • sadx-ui on ogl-lin-mesa: diff
  • sfa-shadows on ogl-lin-mesa: diff
  • sf-assault-flashing on ogl-lin-mesa: diff
  • simpsons-game on ogl-lin-mesa: diff
  • smg2-fog on ogl-lin-mesa: diff
  • smg-marioeyes on ogl-lin-mesa: diff
  • sms-bubbles on ogl-lin-mesa: diff
  • sms-gc on ogl-lin-mesa: diff
  • sms-water on ogl-lin-mesa: diff
  • soa-black on ogl-lin-mesa: diff
  • soniccolors-mm on ogl-lin-mesa: diff
  • sonic-riders-blur on ogl-lin-mesa: diff
  • sonicriderszg-gb on ogl-lin-mesa: diff
  • spyro-bloom on ogl-lin-mesa: diff
  • spyro-depth on ogl-lin-mesa: diff
  • ssbb-mod-lloyd on ogl-lin-mesa: diff
  • ssbm-pointsize on ogl-lin-mesa: diff
  • ss-map on ogl-lin-mesa: diff
  • ss-timestone on ogl-lin-mesa: diff
  • super-sluggers-white-out on ogl-lin-mesa: diff
  • sw3-dt on ogl-lin-mesa: diff
  • thps3-earlyz on ogl-lin-mesa: diff
  • thps4-shadow on ogl-lin-mesa: diff
  • tla-menu on ogl-lin-mesa: diff
  • tos-invis-char on ogl-lin-mesa: diff
  • tsp3-pinkgrass on ogl-lin-mesa: diff
  • vegas-party-depth on ogl-lin-mesa: diff
  • xenoblade-menu on ogl-lin-mesa: diff
  • ztp-grass on ogl-lin-mesa: diff
  • zww-armos on ogl-lin-mesa: diff
  • zww-water on ogl-lin-mesa: diff
  • zww-waves on ogl-lin-mesa: diff
  • ab11-homebrew on ogl-lin-nv: diff
  • aeon-charge-attack on ogl-lin-nv: diff
  • chibi-robo-fastdepth on ogl-lin-nv: diff
  • chibi-robo-zfighting on ogl-lin-nv: diff
  • custom-brawl-char on ogl-lin-nv: diff
  • dbz-depth on ogl-lin-nv: diff
  • djfny-menu on ogl-lin-nv: diff
  • DKCR-Char on ogl-lin-nv: diff
  • DKCR-fast-depth on ogl-lin-nv: diff
  • ed-updated on ogl-lin-nv: diff
  • et-vid on ogl-lin-nv: diff
  • fifa-street on ogl-lin-nv: diff
  • find-mii on ogl-lin-nv: diff
  • fishing-resort-map on ogl-lin-nv: diff
  • fog-adj on ogl-lin-nv: diff
  • fortune-street on ogl-lin-nv: diff
  • fortune-street-fog on ogl-lin-nv: diff
  • fortune-street-white-box on ogl-lin-nv: diff
  • fsa-layers on ogl-lin-nv: diff
  • f-zero-rain on ogl-lin-nv: diff
  • goldeneye-depth on ogl-lin-nv: diff
  • hb-discgolf on ogl-lin-nv: diff
  • inverted-depth-range on ogl-lin-nv: diff
  • kirby-shadows on ogl-lin-nv: diff
  • last-story-shadows on ogl-lin-nv: diff
  • lego-star-wars-crane-shadow on ogl-lin-nv: diff
  • lesson08 on ogl-lin-nv: diff
  • luigi-shadows on ogl-lin-nv: diff
  • mario-baseball-shadows on ogl-lin-nv: diff
  • mario-sluggers-bar on ogl-lin-nv: diff
  • mario-tennis-menu on ogl-lin-nv: diff
  • MaS-LOG-wiimote on ogl-lin-nv: diff
  • medabots-crash on ogl-lin-nv: diff
  • megaman-heat on ogl-lin-nv: diff
  • melee-depth on ogl-lin-nv: diff
  • melee-lighting on ogl-lin-nv: diff
  • metroid-visor on ogl-lin-nv: diff
  • mii-channel on ogl-lin-nv: diff
  • milotic-texture on ogl-lin-nv: diff
  • mini-ninjas on ogl-lin-nv: diff
  • mkdd-babypark on ogl-lin-nv: diff
  • mkdd-efb on ogl-lin-nv: diff
  • mkwii-bluebox on ogl-lin-nv: diff
  • monkeyball-fuse on ogl-lin-nv: diff
  • mp3-bloom on ogl-lin-nv: diff
  • mp7-text on ogl-lin-nv: diff
  • mtennis-zfreeze on ogl-lin-nv: diff
  • my-word-coach on ogl-lin-nv: diff
  • nddemo-bumpmapping on ogl-lin-nv: diff
  • nddemo-lighting on ogl-lin-nv: diff
  • nfsu-purplerect on ogl-lin-nv: diff
  • nfsu-reflections on ogl-lin-nv: diff
  • nsmbw-coins on ogl-lin-nv: diff
  • nsmbw-intro on ogl-lin-nv: diff
  • pm-hc-jp on ogl-lin-nv: diff
  • pw-black-bars on ogl-lin-nv: diff
  • rs2-bumpmapping on ogl-lin-nv: diff
  • rs2-glass on ogl-lin-nv: diff
  • rs2-skybox on ogl-lin-nv: diff
  • rs2-zfreeze on ogl-lin-nv: diff
  • rs3-bumpmapping on ogl-lin-nv: diff
  • sadx-ui on ogl-lin-nv: diff
  • sfa-shadows on ogl-lin-nv: diff
  • sf-assault-flashing on ogl-lin-nv: diff
  • simpsons-game on ogl-lin-nv: diff
  • smg2-fog on ogl-lin-nv: diff
  • smg-marioeyes on ogl-lin-nv: diff
  • sms-bubbles on ogl-lin-nv: diff
  • sms-gc on ogl-lin-nv: diff
  • sms-water on ogl-lin-nv: diff
  • soa-black on ogl-lin-nv: diff
  • soniccolors-mm on ogl-lin-nv: diff
  • sonic-riders-blur on ogl-lin-nv: diff
  • sonicriderszg-gb on ogl-lin-nv: diff
  • spyro-bloom on ogl-lin-nv: diff
  • spyro-depth on ogl-lin-nv: diff
  • ssbb-mod-lloyd on ogl-lin-nv: diff
  • ssbm-pointsize on ogl-lin-nv: diff
  • ss-map on ogl-lin-nv: diff
  • ss-timestone on ogl-lin-nv: diff
  • super-sluggers-white-out on ogl-lin-nv: diff
  • sw3-dt on ogl-lin-nv: diff
  • taiko-depth on ogl-lin-nv: diff
  • thps3-earlyz on ogl-lin-nv: diff
  • thps4-shadow on ogl-lin-nv: diff
  • tla-menu on ogl-lin-nv: diff
  • tos-invis-char on ogl-lin-nv: diff
  • tsp3-pinkgrass on ogl-lin-nv: diff
  • vegas-party-depth on ogl-lin-nv: diff
  • xenoblade-menu on ogl-lin-nv: diff
  • ztp-grass on ogl-lin-nv: diff
  • zww-armos on ogl-lin-nv: diff
  • zww-water on ogl-lin-nv: diff
  • zww-waves on ogl-lin-nv: diff

automated-fifoci-reporter

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

Successfully merging this pull request may close these issues.

4 participants