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









6 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. 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