[Bug]? Fresnel on VR (oculus) : L/R eye different

Hello everyone !

I am having a little bit of an issue on my shaders :

I am using some Fresnel (on pretty much everything) but I noticed that the left eye and the right eye are not rendering the same effect.

It’s absolutely logical and normal but it’s a big issue as it create a disturbing effect.

I will be okay with a Fresnel averaging on both eye “the middle eye” but I have no idea if that is possible.

So that pose also a more general question of : can camera based effect be based on the “middle eye” ?

I look forward to your enlightenment, thanks.

This is logical, Here is what is going on behind the scene of a fresnel operation.

The most important part is the top left node. CameraVector. This is the world space camera direction. Since virtual reality glasses use 2 separate camera’s ingame, with both a slightly different direction, you won’t get the same result.

Fixing this would be easy internally. It would be cool if epic added a ViewVector for virtual reality, so we could access it in the material editor.

Since this is not the case you would have to set it up yourself. The easiest way would be to make a Material Parameter Collection in the content browser, and within there add a new Vector Parameter. Give it a nice name, like VRViewDir. In any material you can now add this Parameter Collection.

Now from within blueprint you can set the VRViewDir with the “Set Vector Parameter Value” node. This way every shader just used that view direction instead of the CameraVector.

Good luck!

1 Like

Awesome answer,
So you are basically redoing a fresnel just for VR.
This is perfect, merci !
I will add a request to Epic regarding that kind of camera effects.

I’m about to start something that would have a lot of fresnel in VR. Is the discrepancy really problematic? Logically, they should have a slightly different look based on slightly different views, but just how distracting is that in stereo? I haven’t tested it yet.

Me neither, You would have to try it out. If someone could post a picture of how it actually looks through VR, that would be great!

I fixed this here by changing, in MaterialTemplate.usf, the following line of code:

Parameters.CameraVector = normalize(-Parameters.WorldPosition_CamRelative.xyz);

to this:

Parameters.CameraVector = normalize(ResolvedView.WorldCameraOrigin - Parameters.AbsoluteWorldPosition);

btw this fix does not work with Tessellation enabled, not sure how to fix that yet.

Hi, I’ve got some questions regarding your answer, Roel.

What do you mean by Material Parameter Collection in particular? How can you retrieve the view direction of a specific eye camera of a helmet? And do you have to implement a Fresnel function using this particular VRViewDir on your own? And is there an engine update on this topic? Like a VR_Fresnel function?