VR universal shader

  • Fu-Bama
  • Topic Author
More
5 years 2 months ago - 3 years 4 months ago #1 by Fu-Bama VR universal shader was created by Fu-Bama
Hello, I would like to present to you unfinished VR shader that can change any game into VR.

Some of the features:
• Stereoscopic view from single image
• Lens distortion correction through Brown-Conrady model
• Chromatic aberration correction
• Stereo 3D parallax occlusion from depth







Since it's only a visual effect, there's no head-tracking, so nausea can occur. To minimize unpleasant effects, use of virtual nose (VR_nose) is recommended.

The shader is not perfect, there is a problem with stereo-parallax geometry (tested on PSVR), but offset effect itself works very well. It's just an alpha version so feel free to contribute.

Known issues:
• Parallax stereo 3D does not 'feel' right
• Parallax offset creates gaps that have to be compensated with "Parallax gaps compensation"

You can download VR shader here:
github.com/Fubaxiusz/fubax-shaders-dev/b...master/Shaders/VR.fx
and VR nose:
github.com/Fubaxiusz/fubax-shaders-dev/b...r/Shaders/VR_nose.fx
and nose texture:
github.com/Fubaxiusz/fubax-shaders-dev/b...er/Textures/nose.png

Just right-click on RAW and save as .fx to your shaders location, same for the texture to textures location.
Last edit: 3 years 4 months ago by Fu-Bama. Reason: repo update
The following user(s) said Thank You: Wicked Sick, brussell, BlueSkyKnight, Momsacks

Please Log in or Create an account to join the conversation.

  • Duran.te
More
5 years 2 months ago #2 by Duran.te Replied by Duran.te on topic VR universal shader

Please Log in or Create an account to join the conversation.

  • Marty McFly
More
5 years 2 months ago #3 by Marty McFly Replied by Marty McFly on topic VR universal shader
^this

Fu-Bama Even though I can' use this shader here, I find your other works remarkable. Your coding style is very easy to read as well! Can't wait to see what future projects you can come up with.
The following user(s) said Thank You: Wicked Sick, Fu-Bama

Please Log in or Create an account to join the conversation.

  • ShoterXX
More
5 years 2 months ago - 5 years 2 months ago #4 by ShoterXX Replied by ShoterXX on topic VR universal shader
I'll be sure to give this a try once I get home.

Also, in case you didn't know, you could get a PSVR, which is a decent VR headset, for around 200€ back during last Black Friday. Then, add Trinus PSVR to use it on PC, a smartphone as webcam (for better head tracking, not required), and look for some ghetto solutions for hand controllers (if required, though I prefer playing Elite with my joystick), and you get yourself a decent VR setup. It's no Vive, but it's way better than the smartphone "VR" that gets often thrown around, and you're not locked to Window$ 10, like the Mixed Reality ones.
Last edit: 5 years 2 months ago by ShoterXX.

Please Log in or Create an account to join the conversation.

  • BlueSkyKnight
More
5 years 2 months ago - 5 years 2 months ago #5 by BlueSkyKnight Replied by BlueSkyKnight on topic VR universal shader
Good work. Also heads up the shader fails to compile in the OpenGL game I tested it in.
Amnesia: MfP

Also this is the first time I did hear of Virtual nose. This is good information. I think I will add something like his to my own shader. Since it's a really good idea.

TIL
www.wired.com/2015/04/reduce-vr-sickness-just-add-virtual-nose/
Last edit: 5 years 2 months ago by BlueSkyKnight.

Please Log in or Create an account to join the conversation.

  • Fu-Bama
  • Topic Author
More
5 years 2 months ago - 5 years 2 months ago #6 by Fu-Bama Replied by Fu-Bama on topic VR universal shader
@BlueSkyKnight
Could not reproduce your issue.
Tested it in Amnesia MfP and Blender, both OpenGL and it compiles fine, both VR and VR_nose on both ReShade 3.4.1 and 4.1.1
Maybe there is something with your drivers..
Last edit: 5 years 2 months ago by Fu-Bama.

Please Log in or Create an account to join the conversation.

  • BlueSkyKnight
More
5 years 2 months ago - 5 years 2 months ago #7 by BlueSkyKnight Replied by BlueSkyKnight on topic VR universal shader

Fu-Bama wrote: @BlueSkyKnight
Could not reproduce your issue.
Tested it in Amnesia MfP and Blender, both OpenGL and it compiles fine, both VR and VR_nose on both ReShade 3.4.1 and 4.1.1
Maybe there is something with your drivers..


I will look into this. Also, just in case I will reinstall my drivers. Just a quick question would it be ok if add and change a few things to your shader? I am interested in the hold/gap filling you are using. Mainly in testing, it's limitations.

I am always happy to see a 3D Shader. :)

I will submit my changes to your work if you are ok with it.

Added convergence. Keep in mind perspective needs to be changed for VR headsets. Because that screen pop out is a big no no for VR headsets.
Last edit: 5 years 2 months ago by BlueSkyKnight. Reason: My grammar

Please Log in or Create an account to join the conversation.

  • Fu-Bama
  • Topic Author
More
5 years 2 months ago #8 by Fu-Bama Replied by Fu-Bama on topic VR universal shader

BlueSkyKnight wrote: Just a quick question would it be ok if add and change a few things to your shader? I am interested in the hold/gap filling you are using. Mainly in testing, it's limited.

Sure man, you're free to adapt and share your edits, non commercially (CC by-nc-sa 4.0)

Please Log in or Create an account to join the conversation.

  • Fu-Bama
  • Topic Author
More
5 years 2 months ago - 5 years 2 months ago #9 by Fu-Bama Replied by Fu-Bama on topic VR universal shader

BlueSkyKnight wrote:

Warning: Spoiler!
Added convergence. Keep in mind perspective needs to be changed for VR headsets. Because that screen pop out is a big no no for VR headsets.


@BlueSkyKnight
Thanks for the screenshoot. The shader already had Zero Parallax Point adjustment under Parallax rotation center (ZPD).

Fu-Bama wrote: Known issues:
• Parallax stereo 3D does not 'feel' right


I know now what's wrong with the parallax shader, It transforms view for each eye in isometric projection :huh:
while it should be in perspective projection, where the objects in the distance are transformed in lesser degree than those in front.

Warning: Spoiler!

It works like this:
• Cut image into planes accordingly to the depth buffer
(like a Topographic Maps layers)

• Shift each layer by a [ constant offset value * layer number ]
(this one is wrong it should be gradual value, not constant)

• Blend each layer 'jump' nicely to get smooth result (remove stairs effect)

I did not put much thought into the stereoscopic 3D mode, just dumped parallax occlusion shader into it and added little bit of salt (gaps compensation) :side:
Last edit: 5 years 2 months ago by Fu-Bama.

Please Log in or Create an account to join the conversation.

  • crosire
More
5 years 2 months ago #10 by crosire Replied by crosire on topic VR universal shader

BlueSkyKnight wrote: I will look into this. Also, just in case I will reinstall my drivers. Just a quick question would it be ok if add and change a few things to your shader? I am interested in the hold/gap filling you are using. Mainly in testing, it's limitations.

If there are still errors in OpenGL, please post the error log. There are huge differences in the kind of GLSL code NVIDIA's and AMD's drivers accept, so stuff working on one of them may not work on the other and vice versa. As such it can happen that the ReShade FX compiler generates code that is not working on one of them since it wasn't noticed during testing. Those are bugs in ReShade that need fixing.
The following user(s) said Thank You: Wicked Sick

Please Log in or Create an account to join the conversation.

  • BlueSkyKnight
More
5 years 2 months ago - 5 years 2 months ago #11 by BlueSkyKnight Replied by BlueSkyKnight on topic VR universal shader

Fu-Bama wrote:

BlueSkyKnight wrote:

Warning: Spoiler!
Added convergence. Keep in mind perspective needs to be changed for VR headsets. Because that screen pop out is a big no no for VR headsets.


@BlueSkyKnight
Thanks for the screenshoot. The shader already had Zero Parallax Point adjustment under Parallax rotation center (ZPD).

Fu-Bama wrote: Known issues:
• Parallax stereo 3D does not 'feel' right


I know now what's wrong with the parallax shader, It transforms view for each eye in isometric projection :huh:
while it should be in perspective projection, where the objects in the distance are transformed in lesser degree than those in front.

Warning: Spoiler!

It works like this:
• Cut image into planes accordingly to the depth buffer
(like a Topographic Maps layers)

• Shift each layer by a [ constant offset value * layer number ]
(this one is wrong it should be gradual value, not constant)

• Blend each layer 'jump' nicely to get smooth result (remove stairs effect)

I did not put much thought into the stereoscopic 3D mode, just dumped parallax occlusion shader into it and added little bit of salt (gaps compensation) :side:


I adapted your code into SuperDepth3D.

I also Updated my old WobbleDepth3D Shader with the same code. You can also see my edits here.
github.com/BlueSkyDefender/Depth3D/blob/...Depth3D.fx#L245-L291

It looks really good. Fu-Bama Good work.


Not the best Thumbnail.. :dry:

I also noticed the issue with AA....

Fu-Bama wrote: I know now what's wrong with the parallax shader, It transforms view for each eye in isometric projection :huh:
while it should be in perspective projection, where the objects in the distance are transformed in lesser degree than those in front.


Ya, I been trying to fix this. Do you know where this should be adjusted? Even with this problem it still looks really good BTW. I can somewhat control it using (1 - Z / Depthbuffer). But, I would like to know if there a better way.
Last edit: 5 years 2 months ago by BlueSkyKnight.

Please Log in or Create an account to join the conversation.

  • BlueSkyKnight
More
5 years 2 months ago - 5 years 2 months ago #12 by BlueSkyKnight Replied by BlueSkyKnight on topic VR universal shader

crosire wrote:

BlueSkyKnight wrote: I will look into this. Also, just in case I will reinstall my drivers. Just a quick question would it be ok if add and change a few things to your shader? I am interested in the hold/gap filling you are using. Mainly in testing, it's limitations.

If there are still errors in OpenGL, please post the error log. There are huge differences in the kind of GLSL code NVIDIA's and AMD's drivers accept, so stuff working on one of them may not work on the other and vice versa. As such it can happen that the ReShade FX compiler generates code that is not working on one of them since it wasn't noticed during testing. Those are bugs in ReShade that need fixing.


Here you go crosir
pastebin.com/NJ6F40d8
This issue happens when I try to enable Universal VR shader.

Also, I noticed another issue with the PingPong function special runtime values.
uniform float2 pingpong < source = "pingpong"; min = 0; max = 9; step = 1; >;
//I used to be able to set it from Zero to One and adjust the steps for speed.
uniform float2 WobbleSpeedSix < source = "pingpong"; min = 0; max = 1; step = 10; >;//like this

Then use WobbleSpeedSix.x in my code. But, I can't anymore. Also Maybe I was using it wrong before. :side: I don't know.

So I had to write my own Ping Pong. To get my old shader to work.
github.com/BlueSkyDefender/Depth3D/blob/...Depth3D.fx#L306-L315
Last edit: 5 years 2 months ago by BlueSkyKnight.

Please Log in or Create an account to join the conversation.

  • crosire
More
5 years 2 months ago - 5 years 2 months ago #13 by crosire Replied by crosire on topic VR universal shader

BlueSkyKnight wrote: Here you go crosir
pastebin.com/NJ6F40d8

Fixed: github.com/crosire/reshade/commit/5dd20c...03ef1eeba144ae477cce

BlueSkyKnight wrote: Then use WobbleSpeedSix.x in my code. But, I can't anymore. Also Maybe I was using it wrong before. :side: I don't know.

This still works. But ReShade doesn't do type conversion on annotations currently. It expects floats for the "min", "max" and "step" values, but you set them to integers, which get reinterpreted to some huge float values and it all falls apart.
Write it like this for it to work in the current version:
uniform float2 WobbleSpeedSix < source = "pingpong"; min = 0.0; max = 1.0; step = 10.0; >;//like this
It's fixed now: github.com/crosire/reshade/commit/2d179b...13b7445772fcc5ee1c33
Last edit: 5 years 2 months ago by crosire.
The following user(s) said Thank You: BlueSkyKnight

Please Log in or Create an account to join the conversation.

  • Momsacks
More
3 years 9 months ago #14 by Momsacks Replied by Momsacks on topic VR universal shader
Hello! I've gotta say, this is such a fantastic shader from what I've seen so far! So I have to ask, how exactly do I get this to display on my HMD? I've tried the 3D SBS in Bigscreen, but this is not exactly a Depth 3D shader, so I'm assuming that there is a way to get this to display directly onto the headset?

Please Log in or Create an account to join the conversation.

  • Thurbo
More
3 years 6 months ago #15 by Thurbo Replied by Thurbo on topic VR universal shader
Hello folks,

is there a way to use this shader for old VR games that already produce a 3D SBS image but the distortion doesn't work on Oculus headsets? Games such as Team Fortress 2 or Half-Life, for example.

What this means is I'd like to get the shader to distort the left and right halves of the screen individually rather than assuming that the game needs to be converted to 3D SBS first.

Please Log in or Create an account to join the conversation.

  • Fu-Bama
  • Topic Author
More
3 years 6 months ago #16 by Fu-Bama Replied by Fu-Bama on topic VR universal shader
Ok, I will put-up together 3D SBS version of this shader.

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.