Unity 5 & 3D Vision
  1 / 4    
Since a bunch of games I've fixed will soon be moving to Unity 5, I've been actively working out how to fix it in advance. Here's a video with some before+after of the DX11 build of the Unity 5 sample project "Viking Village" fixed using 3Dmigoto - I'll be demoing this at a local game dev meetup on Monday to try to drum up some support (lots of devs around here are using Unity): https://youtu.be/d8Is_nzhFcM http://darkstarsword.net/Unity_5_Viking_Village_NVIDIA_Stereoscopic_3D_Vision_3DMigoto_DirectX11_Fix.avi A build of the demo is here: http://darkstarsword.net/viking.rar The fixed shaders are here: https://github.com/DarkStarSword/3d-fixes/tree/master/Unity5/DX11/ShaderFixes https://github.com/DarkStarSword/3d-fixes/tree/master/Unity5/Viking/ShaderFixes In Unity 4, every surface shader needed a (trivial) fix. Thankfully this is no longer the case, and we now only need to apply this type of fix to shaders used for specific (mostly semi-transparent) effects. The transformations for lights/shadows have barely changed in Unity 5, so the same pattern that fixed Unity 4 lights will mostly work here as well. The one exception to this should actually make things easier for us - the directional lighting shader now has direct access to the inverse projection matrix, so there is no longer any need to copy matrices into it. This also means that if this shader is active we should be able to copy the matrix out of it for use in other lighting shaders. Point lights only have the MV+MVP matrices as they did in Unity 4, and for this fix I inverted just enough of the MV matrix inside the shader to calculate the necessary part of the inverse projection matrix we need to fix the shadows. Full-screen lighting effects done though this shader (such as Unity 5's new "physical lighting", which means specular highlights, environment reflections and global illumination) will need matrices copied from other shaders if the FOV can vary. The flare drawn around the sun has no active depth buffer, and was confusing the driver's heuristics causing it to flicker between screen depth and infinity. To deal with this I applied the stereo correction, then scaled the position such that W would be equal to convergence thereby preventing the driver's stereo correction from moving it further. Like Unity 4, this shader appears to also be used for GUI elements, so I avoided applying the stereo correction if W was 1 to begin with. One of the effects I fixed for this demo was the highlights in the Depth of Field blur that is enabled in demo mode (by pressing C). What is most noteworthy about this particular effect (the effect itself was worthless and would not have been missed if I just killed it) is that I translated the Cg source code from Unity into HLSL that could be used by 3Dmigoto: https://github.com/DarkStarSword/3d-fixes/blob/master/Unity5/Viking/ShaderFixes/3f9324116cce2bd9-ps_replace.txt https://github.com/DarkStarSword/3d-fixes/blob/master/Unity5/Viking/ShaderFixes/a2d7f336b9c0abdf-vs_replace.txt This is also a good example of a fix where a structured buffer has written to from shaders for both eyes and a second shader drawing them to the screen. Since structured buffers cannot be stereoised like textures the data for both eyes got combined into one single buffer. To fix this I tagged each point with which eye it had come from originally then was able to filter out the points for the wrong eye in the second shader. Here's some additional tools I've been working on to deal with Unity games - unity_asset_extractor.py can extract .shader files from Unity's .asset files (and supports the new format used by Unity 5), then extract_unity_shaders.py can be used to pull out the individual headers from those .shader files and match them up with the hash used by 3Dmigoto, which is useful to identify where matrices are used and what is what in the constant buffers: https://github.com/DarkStarSword/3d-fixes/blob/master/unity_asset_extractor.py https://github.com/DarkStarSword/3d-fixes/blob/master/extract_unity_shaders.py Right now a big concern I have for this is that Unity is defaulting to use a full-screen window, and has a warning that the exclusive full screen mode in DX11 builds is broken (hangs on alt+tab). Chiri's old tool might work in some cases and DX9 games can use 3D in a window via profile, but for DX11 games I'd like to try to solve this in 3Dmigoto going forward.
Since a bunch of games I've fixed will soon be moving to Unity 5, I've been actively working out how to fix it in advance. Here's a video with some before+after of the DX11 build of the Unity 5 sample project "Viking Village" fixed using 3Dmigoto - I'll be demoing this at a local game dev meetup on Monday to try to drum up some support (lots of devs around here are using Unity):

https://youtu.be/d8Is_nzhFcM
http://darkstarsword.net/Unity_5_Viking_Village_NVIDIA_Stereoscopic_3D_Vision_3DMigoto_DirectX11_Fix.avi

A build of the demo is here:
http://darkstarsword.net/viking.rar


The fixed shaders are here:
https://github.com/DarkStarSword/3d-fixes/tree/master/Unity5/DX11/ShaderFixes
https://github.com/DarkStarSword/3d-fixes/tree/master/Unity5/Viking/ShaderFixes



In Unity 4, every surface shader needed a (trivial) fix. Thankfully this is no longer the case, and we now only need to apply this type of fix to shaders used for specific (mostly semi-transparent) effects.

The transformations for lights/shadows have barely changed in Unity 5, so the same pattern that fixed Unity 4 lights will mostly work here as well.

The one exception to this should actually make things easier for us - the directional lighting shader now has direct access to the inverse projection matrix, so there is no longer any need to copy matrices into it. This also means that if this shader is active we should be able to copy the matrix out of it for use in other lighting shaders.

Point lights only have the MV+MVP matrices as they did in Unity 4, and for this fix I inverted just enough of the MV matrix inside the shader to calculate the necessary part of the inverse projection matrix we need to fix the shadows.

Full-screen lighting effects done though this shader (such as Unity 5's new "physical lighting", which means specular highlights, environment reflections and global illumination) will need matrices copied from other shaders if the FOV can vary.

The flare drawn around the sun has no active depth buffer, and was confusing the driver's heuristics causing it to flicker between screen depth and infinity. To deal with this I applied the stereo correction, then scaled the position such that W would be equal to convergence thereby preventing the driver's stereo correction from moving it further. Like Unity 4, this shader appears to also be used for GUI elements, so I avoided applying the stereo correction if W was 1 to begin with.


One of the effects I fixed for this demo was the highlights in the Depth of Field blur that is enabled in demo mode (by pressing C). What is most noteworthy about this particular effect (the effect itself was worthless and would not have been missed if I just killed it) is that I translated the Cg source code from Unity into HLSL that could be used by 3Dmigoto:

https://github.com/DarkStarSword/3d-fixes/blob/master/Unity5/Viking/ShaderFixes/3f9324116cce2bd9-ps_replace.txt
https://github.com/DarkStarSword/3d-fixes/blob/master/Unity5/Viking/ShaderFixes/a2d7f336b9c0abdf-vs_replace.txt

This is also a good example of a fix where a structured buffer has written to from shaders for both eyes and a second shader drawing them to the screen. Since structured buffers cannot be stereoised like textures the data for both eyes got combined into one single buffer. To fix this I tagged each point with which eye it had come from originally then was able to filter out the points for the wrong eye in the second shader.


Here's some additional tools I've been working on to deal with Unity games - unity_asset_extractor.py can extract .shader files from Unity's .asset files (and supports the new format used by Unity 5), then extract_unity_shaders.py can be used to pull out the individual headers from those .shader files and match them up with the hash used by 3Dmigoto, which is useful to identify where matrices are used and what is what in the constant buffers:
https://github.com/DarkStarSword/3d-fixes/blob/master/unity_asset_extractor.py
https://github.com/DarkStarSword/3d-fixes/blob/master/extract_unity_shaders.py



Right now a big concern I have for this is that Unity is defaulting to use a full-screen window, and has a warning that the exclusive full screen mode in DX11 builds is broken (hangs on alt+tab). Chiri's old tool might work in some cases and DX9 games can use 3D in a window via profile, but for DX11 games I'd like to try to solve this in 3Dmigoto going forward.

2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit

Alienware M17x R4 w/ built in 3D, Intel i7 3740QM, GTX 680m 2GB, 16GB DDR3 1600MHz RAM, Win7 64bit, 1TB SSD, 1TB HDD, 750GB HDD

Pre-release 3D fixes, shadertool.py and other goodies: http://github.com/DarkStarSword/3d-fixes
Support me on Patreon: https://www.patreon.com/DarkStarSword or PayPal: https://www.paypal.me/DarkStarSword

#1
Posted 03/28/2015 09:00 PM   
So in order to check out the Viking Village demo we'd need the following, right? [s]Unity: [url]http://unity3d.com/get-unity[/url] Viking Village: [url]https://www.assetstore.unity3d.com/en/#!/content/29140[/url] 3DMigoto: [url]https://github.com/bo3b/3Dmigoto/releases[/url] ShaderFixes: [url]https://github.com/DarkStarSword/3d-fixes/tree/master/Unity5/Viking/ShaderFixes[/url] [/s] ... or just use the link below. :)
So in order to check out the Viking Village demo we'd need the following, right?

Unity: http://unity3d.com/get-unity

Viking Village: https://www.assetstore.unity3d.com/en/#!/content/29140

3DMigoto: https://github.com/bo3b/3Dmigoto/releases

ShaderFixes: https://github.com/DarkStarSword/3d-fixes/tree/master/Unity5/Viking/ShaderFixes


... or just use the link below. :)
#2
Posted 03/28/2015 10:01 PM   
Yeah, that's right. I'll start uploading a build of it to my website, but it's 300MB compressed so it will take a little while. If you go down the route of downloading Unity to build it, be sure to enable exclusive mode full screen: 1. File -> Build Settings -> Player Settings 2. On the Inspector pane: Resolution and Presentation -> D3D11 Fullscreen Mode = Exclusive Mode 3. Back on the build settings window: Build and Run Also, keep in mind that some of the shaders (most of the lighting shaders) in the 3D-fixes repository under Unity5/Viking/ShaderFixes are symbolic links to Unity5/DX11/ShaderFixes, so you need them from the later directory instead (The DX11 folder is intended to become a template that can be dropped into any Unity 5 DX11 game, like the Unity 4 template I also have).
Yeah, that's right. I'll start uploading a build of it to my website, but it's 300MB compressed so it will take a little while.

If you go down the route of downloading Unity to build it, be sure to enable exclusive mode full screen:

1. File -> Build Settings -> Player Settings

2. On the Inspector pane: Resolution and Presentation -> D3D11 Fullscreen Mode = Exclusive Mode

3. Back on the build settings window: Build and Run


Also, keep in mind that some of the shaders (most of the lighting shaders) in the 3D-fixes repository under Unity5/Viking/ShaderFixes are symbolic links to Unity5/DX11/ShaderFixes, so you need them from the later directory instead (The DX11 folder is intended to become a template that can be dropped into any Unity 5 DX11 game, like the Unity 4 template I also have).

2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit

Alienware M17x R4 w/ built in 3D, Intel i7 3740QM, GTX 680m 2GB, 16GB DDR3 1600MHz RAM, Win7 64bit, 1TB SSD, 1TB HDD, 750GB HDD

Pre-release 3D fixes, shadertool.py and other goodies: http://github.com/DarkStarSword/3d-fixes
Support me on Patreon: https://www.patreon.com/DarkStarSword or PayPal: https://www.paypal.me/DarkStarSword

#3
Posted 03/29/2015 01:21 AM   
Build is up: http://darkstarsword.net/viking.rar Hold F9 in the demo to see the original unfixed version.
Build is up:

http://darkstarsword.net/viking.rar

Hold F9 in the demo to see the original unfixed version.

2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit

Alienware M17x R4 w/ built in 3D, Intel i7 3740QM, GTX 680m 2GB, 16GB DDR3 1600MHz RAM, Win7 64bit, 1TB SSD, 1TB HDD, 750GB HDD

Pre-release 3D fixes, shadertool.py and other goodies: http://github.com/DarkStarSword/3d-fixes
Support me on Patreon: https://www.patreon.com/DarkStarSword or PayPal: https://www.paypal.me/DarkStarSword

#4
Posted 03/29/2015 02:34 AM   
Just updated viking.rar - I realised I missed the ShaderFixes directory when I created that and I've added fixes for lighting shaders on lower quality settings as well.
Just updated viking.rar - I realised I missed the ShaderFixes directory when I created that and I've added fixes for lighting shaders on lower quality settings as well.

2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit

Alienware M17x R4 w/ built in 3D, Intel i7 3740QM, GTX 680m 2GB, 16GB DDR3 1600MHz RAM, Win7 64bit, 1TB SSD, 1TB HDD, 750GB HDD

Pre-release 3D fixes, shadertool.py and other goodies: http://github.com/DarkStarSword/3d-fixes
Support me on Patreon: https://www.patreon.com/DarkStarSword or PayPal: https://www.paypal.me/DarkStarSword

#5
Posted 03/29/2015 04:18 AM   
Works really well, no artifacts that I could be able to spot. A bit strange though that while it runs almost always on 60 fps, but there are visible lags every few seconds. But it is the same with 3d vision off in 2d.
Works really well, no artifacts that I could be able to spot. A bit strange though that while it runs almost always on 60 fps, but there are visible lags every few seconds. But it is the same with 3d vision off in 2d.

#6
Posted 03/29/2015 12:36 PM   
My GTX670 was definitely chugging along ... the flyby was much more fluid than looking around with the controller, pretty sure this is the first 3DMigoto fix I've tried so far. I did set Hunting to 0 but it didn't seem like it made much difference at all. So I do the double-jump to fly and as I'm flying around I'm generally looking down, which is making me descend, so I have to keep tapping the jump button, which is making it more or less seem like I'm flapping wings to fly ... which really seems to work well and now I want to play a game(3D obviously) that uses a flying mechanic like that and I can't think of any. :/ It'd be fun as all hell to fly around like that and pounce on your enemies/prey, like a vampire or a dragon.
My GTX670 was definitely chugging along ... the flyby was much more fluid than looking around with the controller, pretty sure this is the first 3DMigoto fix I've tried so far. I did set Hunting to 0 but it didn't seem like it made much difference at all.

So I do the double-jump to fly and as I'm flying around I'm generally looking down, which is making me descend, so I have to keep tapping the jump button, which is making it more or less seem like I'm flapping wings to fly ... which really seems to work well and now I want to play a game(3D obviously) that uses a flying mechanic like that and I can't think of any. :/

It'd be fun as all hell to fly around like that and pounce on your enemies/prey, like a vampire or a dragon.
#7
Posted 03/29/2015 03:28 PM   
I don't know if it's just me or what but I'm pretty sure I've noticed this in another fix(Unity?) as well, I think it was the Miasmata shots. Depth is supposed to be gradual from your viewpoint all the way to infinity/depth but instead depth is gradual to roughly halfway up the screen/across the village and from that point to infinity everything's the same depth/separation and winds up looking off. The viewpoints are supposed to be like a V or an X but it winds up being more like a pencil where it's a V up to a certain point and then it's just parallel from there on ... who knows maybe it's this way in all open area games and I'm just used to playing the dark claustrophobic ones like Dead Space. Lol. :) Here's a screenshot showing it, I was getting 69 pixels of Separation at the mountains and about 64 at the torches, even if that was halfway to infinity it should have only been about 35 pixels of Separation. [img]https://forums.geforce.com/cmd/default/download-comment-attachment/63848/[/img]
I don't know if it's just me or what but I'm pretty sure I've noticed this in another fix(Unity?) as well, I think it was the Miasmata shots. Depth is supposed to be gradual from your viewpoint all the way to infinity/depth but instead depth is gradual to roughly halfway up the screen/across the village and from that point to infinity everything's the same depth/separation and winds up looking off.

The viewpoints are supposed to be like a V or an X but it winds up being more like a pencil where it's a V up to a certain point and then it's just parallel from there on ... who knows maybe it's this way in all open area games and I'm just used to playing the dark claustrophobic ones like Dead Space. Lol. :)

Here's a screenshot showing it, I was getting 69 pixels of Separation at the mountains and about 64 at the torches, even if that was halfway to infinity it should have only been about 35 pixels of Separation.

Image
#8
Posted 03/29/2015 04:46 PM   
That's to be expected, take this plot of pixels of separation (on y) over depth (on x), taking separation=69 and convergence=0.5 (Unity games generally need a low convergence, UE3 games need much higher - e.g. Life Is Strange needs at least 50.0): [code] plot 69 * (x - 0.5) / x, x=0 to 40 [/code] [img]http://www.wolframalpha.com/share/img?i=d41d8cd98f00b204e9800998ecf8427ep8r656osir&f=HBQTQYZYGY4TMNDDGM4DEOJUHEYDCNDDGY4DINRQGI4WCMBYMQ4Aaaaa[/img] http://www.wolframalpha.com/input/?i=plot+69+*+%28x+-+0.5%29+%2F+x%2C+x%3D0+to+40 As you can see on this graph, after about 10 units of depth we are already at 66 pixels of separation and there isn't much distinction above that. The same thing happens in all games (and in real life as well), but it's a question of how much detail is drawn at a depth in the first part of that curve. Increasing the convergence will give more usable depth, but will start breaking objects too close to the camera.
That's to be expected, take this plot of pixels of separation (on y) over depth (on x), taking separation=69 and convergence=0.5 (Unity games generally need a low convergence, UE3 games need much higher - e.g. Life Is Strange needs at least 50.0):

plot 69 * (x - 0.5) / x, x=0 to 40

Image


http://www.wolframalpha.com/input/?i=plot+69+*+%28x+-+0.5%29+%2F+x%2C+x%3D0+to+40


As you can see on this graph, after about 10 units of depth we are already at 66 pixels of separation and there isn't much distinction above that. The same thing happens in all games (and in real life as well), but it's a question of how much detail is drawn at a depth in the first part of that curve.

Increasing the convergence will give more usable depth, but will start breaking objects too close to the camera.

2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit

Alienware M17x R4 w/ built in 3D, Intel i7 3740QM, GTX 680m 2GB, 16GB DDR3 1600MHz RAM, Win7 64bit, 1TB SSD, 1TB HDD, 750GB HDD

Pre-release 3D fixes, shadertool.py and other goodies: http://github.com/DarkStarSword/3d-fixes
Support me on Patreon: https://www.patreon.com/DarkStarSword or PayPal: https://www.paypal.me/DarkStarSword

#9
Posted 03/30/2015 01:31 AM   
So, that means, its more easy to fix Unity 5 Engine? And since a lot of game will change to the new enigne, we will see fixes for them? Would be great :-)
So, that means, its more easy to fix Unity 5 Engine?
And since a lot of game will change to the new enigne, we will see fixes for them? Would be great :-)

#10
Posted 03/30/2015 06:39 AM   
My first two "real" Unity 5 fixes are up for The Forest and The Long Dark (both are DX9 games). They both still need some work and more testing (and it will be another two weeks before I can work on them further), but the big issue of shadows are fixed in both, and I've added a Unity 5 DX9 template to my 3d-fixes repository. I've added logic to the shadow fix to use the inverse projection matrix from the directional shadows if it is available, and to fall back to the Unity 4 techniques if it is not, but this has not been tested as both these games always have directional lighting active.
My first two "real" Unity 5 fixes are up for The Forest and The Long Dark (both are DX9 games).

They both still need some work and more testing (and it will be another two weeks before I can work on them further), but the big issue of shadows are fixed in both, and I've added a Unity 5 DX9 template to my 3d-fixes repository.

I've added logic to the shadow fix to use the inverse projection matrix from the directional shadows if it is available, and to fall back to the Unity 4 techniques if it is not, but this has not been tested as both these games always have directional lighting active.

2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit

Alienware M17x R4 w/ built in 3D, Intel i7 3740QM, GTX 680m 2GB, 16GB DDR3 1600MHz RAM, Win7 64bit, 1TB SSD, 1TB HDD, 750GB HDD

Pre-release 3D fixes, shadertool.py and other goodies: http://github.com/DarkStarSword/3d-fixes
Support me on Patreon: https://www.patreon.com/DarkStarSword or PayPal: https://www.paypal.me/DarkStarSword

#11
Posted 04/19/2015 12:38 PM   
Oh, one gotcha that people might run into trying to fix Unity 5 games is that some of the matrices do not pass all four columns into the shaders. This is particularly true of the model-view matrix, which only passes the first three columns in (the 4th is assumed to be 0001). The consequence of this is that you cannot use Helix mod to invert these matrices, and have to do it in the shaders instead - my template includes a partial hand-optimised model-view matrix inversion used to derive the part of the inverse projection matrix we need. Some matrices (like the MVP matrix) will usually include all four columns - check the number at the end of the line in the headers extracted with my tools to be sure.
Oh, one gotcha that people might run into trying to fix Unity 5 games is that some of the matrices do not pass all four columns into the shaders. This is particularly true of the model-view matrix, which only passes the first three columns in (the 4th is assumed to be 0001).

The consequence of this is that you cannot use Helix mod to invert these matrices, and have to do it in the shaders instead - my template includes a partial hand-optimised model-view matrix inversion used to derive the part of the inverse projection matrix we need.

Some matrices (like the MVP matrix) will usually include all four columns - check the number at the end of the line in the headers extracted with my tools to be sure.

2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit

Alienware M17x R4 w/ built in 3D, Intel i7 3740QM, GTX 680m 2GB, 16GB DDR3 1600MHz RAM, Win7 64bit, 1TB SSD, 1TB HDD, 750GB HDD

Pre-release 3D fixes, shadertool.py and other goodies: http://github.com/DarkStarSword/3d-fixes
Support me on Patreon: https://www.patreon.com/DarkStarSword or PayPal: https://www.paypal.me/DarkStarSword

#12
Posted 04/19/2015 12:43 PM   
Amazing stuff...
Amazing stuff...

I got six little friends and they all run faster than you ;)



Check out our mods at

moddb or the SPS Homepage

#13
Posted 04/20/2015 09:33 PM   
I have Unity 5 installed and wanted to make some Nvidia 3d vision games. Would you guys happen to know how I can fix the shadows/shaders from the source code? I'm able to compile my unity game and have it run with nvidia 3d vision, but there are problems with the shaders on gameobjects likes cubes/spheres and the shadows don't seem to work properly. Can this be fixed from within the Unity source code? Maybe I can render the shadows differently or render the shaders differently?
I have Unity 5 installed and wanted to make some Nvidia 3d vision games. Would you guys happen to know how I can fix the shadows/shaders from the source code?

I'm able to compile my unity game and have it run with nvidia 3d vision, but there are problems with the shaders on gameobjects likes cubes/spheres and the shadows don't seem to work properly. Can this be fixed from within the Unity source code? Maybe I can render the shadows differently or render the shaders differently?

#14
Posted 10/26/2015 07:46 AM   
So, fixing Unity 4 + 5 games after the fact using either Helix Mod (DX9) or 3DMigoto (DX11) is now quite well understood and we have a quite a number of fixes for these up on the blog already. Since you are looking to create your own games using Unity you have a few more options than we usually do: 1. You can follow the same process we do to replace the broken shaders using either Helix Mod or 3DMigoto after the fact. This is known to work and is well understood, but since you are developing your own game you can probably do better. 2. You could edit the shader Cg source code to apply the stereo corrections where they are needed, but still use Helix Mod or 3DMigoto to inject the stereo texture (would definitely work with 3DMigoto as it is injected unconditionally into all shaders, not certain about Helix Mod) - this would mean far less shaders to edit than we usually do since we see them after they have been exploded by the pre-processor and you would be editing them before that happens. The shaders you would need to edit are internal to Unity so you won't ordinarily see their source code, but you can download them separately from the Unity download page, and if you add them to your project they will override the internal ones allowing you to modify them. You would need to edit Internal-PrePassCollectShadows.shader (directional lighting), Internal-DeferredShading.shader (Unity 5 physical lighting and point/spot light shadows), Internal-PrePassLighting.shader (Unity 4 lighting, or legacy lighting in Unity 5) and ComputeScreenPos() in UnityCG.inc to include the nvidia stereo formula (I think). I have some ideas for how this would work here - this is a little out of date as it was written for Unity 4, however Unity 5 is broken in much the same way as Unity 4 so it would largely carry over: https://github.com/DarkStarSword/3d-fixes/tree/master/Unity 3. As 2, but also develop a plugin for Unity that injects the stereo texture to remove the need for Helix Mod / 3DMigoto, and allows other developers to support 3D Vision more easily. This has been on my TODO list for some time now, but realistically I am not going to get to it for quite some time unless I was working with someone else on it (hint hint). 4. There is already a plugin in the asset store to support 3D Vision using two cameras, but it costs money, the latest comment (from 2 years ago) indicates that it did not work, and I've tried the demo which did not appear to be using a very good stereo projection, and the separation + convergence settings do not work properly with it (they only mess up the projection further). I would not recommend this approach. 5. Unity 5.1 supposedly has some support for native DX11 stereo (-vrmode stereo). This would require Windows 8 or above and I'm not sure if it even works - I certainly haven't been able to get it to work with existing Unity games, but it may be that the developers have to do something to enable it (which would be silly, but I wouldn't put that past the Unity devs). Even if this approach can work I would not recommend it because it locks out Windows 7 users, and most 3D Vision users are still on Windows 7 thanks to various problems that have plagued Windows 8.1 and Windows 10. Let me know whatever you decide to do and I can provide further assistance.
So, fixing Unity 4 + 5 games after the fact using either Helix Mod (DX9) or 3DMigoto (DX11) is now quite well understood and we have a quite a number of fixes for these up on the blog already.

Since you are looking to create your own games using Unity you have a few more options than we usually do:

1. You can follow the same process we do to replace the broken shaders using either Helix Mod or 3DMigoto after the fact. This is known to work and is well understood, but since you are developing your own game you can probably do better.

2. You could edit the shader Cg source code to apply the stereo corrections where they are needed, but still use Helix Mod or 3DMigoto to inject the stereo texture (would definitely work with 3DMigoto as it is injected unconditionally into all shaders, not certain about Helix Mod) - this would mean far less shaders to edit than we usually do since we see them after they have been exploded by the pre-processor and you would be editing them before that happens.

The shaders you would need to edit are internal to Unity so you won't ordinarily see their source code, but you can download them separately from the Unity download page, and if you add them to your project they will override the internal ones allowing you to modify them.

You would need to edit Internal-PrePassCollectShadows.shader (directional lighting), Internal-DeferredShading.shader (Unity 5 physical lighting and point/spot light shadows), Internal-PrePassLighting.shader (Unity 4 lighting, or legacy lighting in Unity 5) and ComputeScreenPos() in UnityCG.inc to include the nvidia stereo formula (I think).

I have some ideas for how this would work here - this is a little out of date as it was written for Unity 4, however Unity 5 is broken in much the same way as Unity 4 so it would largely carry over:

https://github.com/DarkStarSword/3d-fixes/tree/master/Unity


3. As 2, but also develop a plugin for Unity that injects the stereo texture to remove the need for Helix Mod / 3DMigoto, and allows other developers to support 3D Vision more easily. This has been on my TODO list for some time now, but realistically I am not going to get to it for quite some time unless I was working with someone else on it (hint hint).

4. There is already a plugin in the asset store to support 3D Vision using two cameras, but it costs money, the latest comment (from 2 years ago) indicates that it did not work, and I've tried the demo which did not appear to be using a very good stereo projection, and the separation + convergence settings do not work properly with it (they only mess up the projection further). I would not recommend this approach.

5. Unity 5.1 supposedly has some support for native DX11 stereo (-vrmode stereo). This would require Windows 8 or above and I'm not sure if it even works - I certainly haven't been able to get it to work with existing Unity games, but it may be that the developers have to do something to enable it (which would be silly, but I wouldn't put that past the Unity devs). Even if this approach can work I would not recommend it because it locks out Windows 7 users, and most 3D Vision users are still on Windows 7 thanks to various problems that have plagued Windows 8.1 and Windows 10.

Let me know whatever you decide to do and I can provide further assistance.

2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit

Alienware M17x R4 w/ built in 3D, Intel i7 3740QM, GTX 680m 2GB, 16GB DDR3 1600MHz RAM, Win7 64bit, 1TB SSD, 1TB HDD, 750GB HDD

Pre-release 3D fixes, shadertool.py and other goodies: http://github.com/DarkStarSword/3d-fixes
Support me on Patreon: https://www.patreon.com/DarkStarSword or PayPal: https://www.paypal.me/DarkStarSword

#15
Posted 10/26/2015 08:49 AM   
  1 / 4    
Scroll To Top