Thursday, July 20, 2017

Zelda - Breath Of The Wild 3D Vision Fix (Depth map based post effect)

Zelda - Breath Of The Wild 3D Vision Fix






Fix v.1.9 by:
Stephen Shepard - sgsrules - Stereocopic 3D Shaders and code. sgsrules3dfixes@gmail.com
Helifax - Code and OpenGLto3DVision Wrapper creator. OpenGLto3DVision v.7.19

This is not a traditional 3D geometry based solution where the scene is rendered twice. It's a image based post processing approach that uses a depth map to re-project the image and render it in stereoscopic 3D. It's similar to Nvidia's Compatibility mode, Tridef and Crytek's S3D, but provides much better results.

There are benefits as well as drawbacks to this approach. First off it's very efficient since the scene is only rendered once, so it's possible to play the game at 4k resolutions and in 3D. Second, and most importantly, since the game is running on OpenGL and through an emulator, it's simply not feasible to use a traditional 3D stereoscopic approach. Because of this you should expect a few limitations. There's no negative parallax (stuff popping out of the screen), there are slight halos around objects and it doesn't work well with transparent objects. Nvidia's compatibility mode suffers from the same set of limitations, but I've made several improvements to alleviate these issues.

Convergence is automatically shifted based on the the distance to the nearest pixel. This was done to increase the amount of 3D “real estate” since there is no negative parallax. Re-adjusting the convergence requires you to refocus your eyes, so this is done gradually to avoid eyestrain. So you may notice things get gradually closer or further away when there is a sudden change in the scene.

Depth based 3D solutions don't have access to occluded geometry so they need to fill that space with something else. This is what is perceived as a halo around objects that are close to the screem. Nvidia's compatibility mode does this by stretching out the pixels horizontally, this causes a warping effect that I personally find quite distracting. Crytek's solution involves duplicating the pixels, kind of like a photoshop stamp tool, unfortunately this causes a hard seem along the edge of the halo which is also pretty distracting. My approach basically duplicates the pixel's like Crytek's, but selectively blurs out the edge without increasing the size of the halo. Overall it works pretty well, you don't get the odd warping when there's movement like you do with some of the other methods. It works particularly well when backgrounds have a lot of ransom elements and variation, like foliage rocky textures etc.

There's another minor artifact that is specific to this game which only affects the map in the menu and the movies. Whenever the game renders something in 2d without a depth map the 3D stereoscopic shader will still attempt to apply 3d stereo. Since the game doesn't write to depth or clear the buffer it uses the last depth map value that was available. So you end up with an image that has improper depth map applied to it.

Alt Tabbing, hitting escape or doing anything that cuases the game to go out of fulscreen mode will crash the game. So don't do it unless you're ready to quit playing.

Nvidia chose to not add native 3D vision support for OpenGL, they reserved this functionality for there overpriced Quadro cards. Because of this, this fix would not have been possible without Helifax's OpenGL to 3D Vision wrapper: http://3dsurroundgaming.com/OGL3DVision.html Even though I added a lot of the code to make this possible he deserves a lot of credit for some of this “magic”. So a huge thank's to Helifax for being kind enough to not only share his code with me, but also help out with some of the additions I made, create the nvidia profile and answer a ton of questions. I'd also like to thank BlueSkyDefender his reshade shader: https://github.com/BlueSkyDefender/Depth3D is what originally turned me on to this idea.

For more details on this implementation or to discuss it please check out the forum thread:

TLDR: This is not true 3d, it's a post processing effect so expect a few artifacts. It's not as good as true stereoscopic 3D but it's pretty damn close and it certainly beats playing the game in 2D.

Installation:

  1. You'll need Cemu and a copy of the game. Make sure you have both working properly before attempting to install this fix. I won't be detailing how to get them working since that is beyond the scope of this fix and there are already a ton of tutorials and instructions elsewhere. This fix has been tested with Cemu 1.8.0 and up.
  2. Extract the entire contents of the archive to your Cemu directory. It contains several files and folders. The graphicsPacks folder contains custom graphics packs for 1080p, 1440p and 4K resolutions. The graphics packs also disable the game's built in Anti-Aliasing and provide higher resolution shadows.
  3. Launch Cemu and enable one of the graphics packs. I would recommend using the 4K one. Quit Cemu.
  4. In 3DVisionWrapper.ini. Make sure that OverrideDepthBufferSize = true and that DepthBufferWidth and DepthBufferHeight match the resolution of the graphics pack that you're using. This is very important! Otherwise the wrapper won't find the proper depth buffer.
  5. Right click on the Cemu.exe and open up properties. Under the compatibility tab make sure that Run this program as administrator is checked.
  6. Create a Shortucut to Cemu and set it to launch with the following target:
    C:\Cemu\Cemu.exe -g "C:\Zelda Breath of the Wild\code\U-King.rpx" -f .
    Obviously change the paths so that they match yours. The -g flag tells cemu to load a game at launch. -f tells it to run in fulscreen.
  7. Launch the game via the shortcut.
  8. Separation and Convergence can be adjusted via the normal 3d Vision hotkeys. You can increase the convergence, but adding to much will flatten out near by objects, cut through silhouettes and cause other artifacts. I would highly recommend leaving the default convergence value as is. It provides the most amount of 3D without additional artifacts.

Extra options:

    Hotkeys, default convergence, initial separation, etc can be changed in the 3DVisionWrapper.ini files.
    By Default the fix uses the “m” key to toggle separation to zero. This is useful to fix the wrong depth value being used during cut scenes and a few of the menus. To enable additional hotkeys or change separation you can add something like the following:
    [code]
    ; Keyboard M - for Map mode
    NewKeyShortcut(0x0000004D, 10.0, -1.0, -1.0, -1.0, -1.0, -1.0, one-time)
    ; Keyboard ESC - Revert stereo to 100%
    NewKeyShortcut(0x0000001B, 100.0, -1.0, -1.0, -1.0, -1.0, -1.0, one-time)
    ; Xbox Back - Select - for Map mode
    NewKeyShortcut(0x00000020, 10.0, -1.0, -1.0, -1.0, -1.0, -1.0, one-time)
    ; Xbox Start - for Menu Mode
    NewKeyShortcut(0x00000010, 10.0, -1.0, -1.0, -1.0, -1.0, -1.0, one-time)
    ; Xbox B - Revert stereo to 100%
    NewKeyShortcut(0x00002000, 100.0, -1.0, -1.0, -1.0, -1.0, -1.0, one-time)
    [/code]
like my work or Helifax's OpenGL wrapper and want to express it?
You can send a PayPal donation to:

sgs.rules@gmail.com for the fix
tavyhome@gmail.com for Helifax's OpenGL wrapper









26 comments:

  1. Big thank you Sgsrules! Without this we wouldn't be able to experience Zelda BOTW in 3D!!!!
    Another video I made using the above fix:
    https://www.youtube.com/watch?v=iIlsX97tyVg&t=629s

    ReplyDelete
    Replies
    1. Once again thanks for giving me access to your source code, as well as all the help. This wouldn't have been possible without you.

      Delete
    2. Hello!
      Do you plan to update the patch for version CEMU_2.0-25?
      THANKS :)

      Delete
  2. Thanks so much Sgsrules and also thanks to Helifax.

    ReplyDelete
  3. Thanks guys. It's awesome to see shader hackers working together to make something magical!

    ReplyDelete
  4. awesome work. Cant try it myself for now. but im glad is out.

    ReplyDelete
  5. This. Is. Crazy!!! 3D Fix guys, you keep proving you are true MAGICIANS! The things you do for 3D Vision community is beyond any words! THANK YOU SOOOOOO MUCH!!!!

    ReplyDelete
  6. With Cemu 1.91 the problem with photo's taken being corrupt is now fixed. =) Also seems like a 60 fps hack maybe soon on the horizon. (currently works in shrines)

    Now, sometimes however when I press the map icon the game come sout and loses depth, has anyone else experienced this?

    ReplyDelete
  7. This is SUPER impressive. Great job!

    ReplyDelete
  8. Yeah I'm having an issue where it forces full screen before I can enable the hack to allow it to play at 30 FPS and it's at 1080p even though the .ini is 4K. Trying to kill the process via ctrl+alt+delete brings me to at 1080 version of a my desktop with CEMU at 1080p and I need to log off and log back on otherwise I can't access process explorer.

    Windows 7 64 bit.
    GTX 1080 Ti
    378.78

    Latest CEMU and BOTW build.

    ReplyDelete
  9. No uninstall.bat too, sweet, now CEMU isn't working and I have to figure out how your "fix" fucked my game.

    ReplyDelete
    Replies
    1. Booo Hoo, fix works fine. Not his fault you are an ungrateful idiot. PEBCAK

      Delete
  10. Thanks for your work on this but I am not able to get it to work.
    Whenever I try to run the game with 3d enabled in nvidia control panel I just get a full screen (but low resolution) image of the CEMU home screen. Once this happens I am unable to get out of it as no other screen will show on top. I have to log out to exit the programme. If I disable 3d the game works perfectly.
    I am only using the graphic pack supplied with this fix but I do have CEMUhook installed, could this be causing me problems?

    ReplyDelete
    Replies
    1. Update - does not seem to be related to CEMUhook, I removed the files and I'm still seeing the same issue.
      Also, if I try to run the game by starting CEMU normally and loading BOTW (as opposed to the shortcut described above) I still see the same issue but can close the application normally. Sometimes when I do this I see BOTW for a very short time (milliseconds) whilst CEMU closes.

      Delete
    2. same problem. Did you ever fix it?

      Delete
  11. This fix was designed around an older version of CEMU. It worked from my testing at least until version 1.11.3
    Latest build appears to hang in 3d at compiling shaders, and it seems to be an issue fix installed or not.

    ReplyDelete
  12. works till version 1.11.5 … just spent a day testing 10 diff versions only to upgrade by 2. (1.11.6 up to 1.12.0 will compile in 3d--sometimes--but the second the mouse is moved or 3d is turned off or you hit ctrl+alt+insert to disable the nvidia 3d vision overlay or anything it will crash and stop compiling. even if it finishes to 100% it will crash upon trying to load the game--even with a proper desktop shortcut to run in fullscreen. and 1.12.1 and beyond wouldn't compile at all in 3d for me w/ immediate crash, and the only way to escape this crash is to ctrl+alt+del and sign out of windows super annoying lol).

    hoping that any of this info or something in the detailed changelog at
    http://cemu.info/changelog.html
    can help figure out why but till then i'm on 1.11.5 which runs pretty flawlessly anyway :)

    ("GX2: Adjusted the way attributes are passed from geometry to pixel shader so it works on AMD") looked sketchy to me but idk. lol)

    ReplyDelete
  13. zelda: breath of the wild for nintendo labo vr for the "switch":

    https://oi60.photobucket.com/albums/h27/Nintendians/zelda%20vr%203d%204.jpg~original
    https://oi60.photobucket.com/albums/h27/Nintendians/zelda%20vr%203d%202.jpg~original

    (note: 720p images from the actual source are edit and resized to 1080p resolution for 1080p 3dtv, might be blurry for 4k's, it's half side by side stereoscopic 3d)

    ReplyDelete
  14. Hi!
    I'm not sure if my computer can hold it but i really want to try this game in 3d.
    Intel I7 4790K
    Gtx 980 Ti
    8 Mo ddr4
    But is the fix already work for Cemu 1.17.1?
    I tried to install it but the graphics packs didn't show up in the graphic pack menu of cemu.
    May be it need an update?

    ReplyDelete
    Replies
    1. Is there any reason not to roll back to the 1.11.5 which is reported as working fine?

      Is there something in the latest version that is a must have feature? Is there something broken in 1.11.5 that is unbearable? If neither of those are true, then there's not much value in waiting for an update to fix, which of course will just be broken again when they revise CEMU again.

      Best bet in 3D land is to use what's working, not try to stay on the bleeding edge.

      Delete
    2. Hi bob!

      the 1.17.1 version improve stability and add vulkan feature.
      I was unable to run the game smoothly with the 1.11.5 version but now i can play in 1440p with 60 fps.

      i'll give a try with the older version again with the fix this time to see if it work.

      The strange thing was that the graphic pack didn't show up in the graphic pack list.
      Did those pack need an update on every cemu update?

      (sry if my english is weird, i'm not english)

      Delete
  15. Hi!
    I installed 1.11.5 and did all the settings but now the game is stuck at the loading screen after i load my save or start a new game.

    It will probably be a good idea to update the pack now because since the 1.11.5 version, it has been a really big improvement to cemu and especially the multi-core optimization.

    with the 1.15.20 i was not able to have 30 fps in 720p, but with the 1.17.3 i can now play in 1440p where i can reach 60 fps almost all the time with the lowest at 48 fps. (but botw need to be capped to 30 fps or glitches start to appear in mass)

    I'm so sad to not have the opportunity to play this particulary game in 3d while it's apparently possible.
    Zelda is all my childhood memories and when i saw this game in helix mod blog i was so happy ....

    I hope someone who know how to do this kind of fix will have the desire to play this game in 3d soon.

    :)

    ReplyDelete
  16. Hi!
    It's been a while now since this fix and there was a lot of improvement with Cemu.
    With the 1.11.5 version i was unable to run the game at more than 20 Fps at 720P resolution.
    But today i can run it in 4K at more than 120 Fps.
    So i think maybe it worth the try with the actual version of Cemu
    This game is so good, i hope i will have the chance to see it in 3D on day.
    :)

    ReplyDelete
    Replies
    1. The CEMU_2.0-25 version works, but there is a big problem with color and contrast saturation. I don't know if anyone can fix it?

      Delete
  17. I confirm, this game does not work anymore. That is a pity.

    ReplyDelete