5dof support for TrackIR and improved 6dof for VR

A Forum dedicated to the Suggestion, Creation and Editing of XWA Dynamic Link Library Files

Moderators: Darksaber, General_Trageton, Forceflow, DTM, JeremyaFr

Re: 5dof support for TrackIR and improved 6dof for VR

User avatar
blue_max
Lieutenant
XWAU Member
Posts: 941
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Tue Feb 18, 2020 5:44 pm

VanillaEssence wrote:
Tue Feb 18, 2020 3:08 am
Even with 3d_aspect_ratio set to 1 there was still warping.
I didn't notice this detail before, the aspect ratio probably shouldn't be 1; but setting the "3d_window_size" to 1 seems to have helped cylonsurfer.

@cylonsurfer: Yes, I'm using the latest OpenVR -- from Jan 2020, if I remember correctly.

I've been thinking about this problem and there's probably one other place where the scale can be applied: after the 2D projection. Scaling at any point before that is equivalent to what you guys already tested. So, I added a new parameter in this preview, called "post_projection_size":

https://www.dropbox.com/s/0zlmzd0lp7cbz ... 2.zip?dl=0

In this preview, the keys are the same; but the scaling shortcut (Ctrl + Up/Down) will change the "post_projection_size" instead of the 3d size. Honestly, I don't think it'll help and it may even cause blurry vision or double images. If so, please don't try to fix the blurry image, just set "post_projection_size" back to 1.

I'm starting to believe that this is the wrong question to ask. There's always some distortion when projecting 3D to 2D near the edges of the screen -- even without VR. This is something intrinsic to the way pinhole cameras work; but why is it bothering you so much? From the video posted above, the distortion *on the screen* doesn't look that bad. Maybe SteamVR isn't applying the right lens correction?

User avatar
keiranhalcyon7
Lieutenant JG
Posts: 524
Joined: Tue Jan 02, 2018 6:41 am

Post by keiranhalcyon7 » Tue Feb 18, 2020 6:16 pm

I would say, it's more due to to the planar projection than to the way pinhole cameras work. Although it's possible those are equivalent statements and I just don't know the terms.

There are two other comments I would like to make, but with my limited knowledge of and nonexistent exposure to VR, feel free to correct me.

The first is: is it possible that these various headsets have lenses with different strengths, which would in turn need different levels of distortion correction rather than a flat preset on/off for apply_lens_correction? (Is this just a pincushion distortion meant to counter barrel distortion introduced in the optics? If so, can the strength of it be varied?)

The second is that cylonsurfer's comments about "twisting" sounds to me like a pure FOV issue. If your FOV is correct, when you pan your head, your expect the your ship's nosecone in the image to pan the same angular distance in the opposite direction. If it appears to be panning more than your head turn, your FOV setting is too low. (Cylonsurfer, is this an accurate description of what you're seeing?) Further, if it pans in a non-linear fashion, the lens correction is wrong; see previous point.

User avatar
blue_max
Lieutenant
XWAU Member
Posts: 941
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Tue Feb 18, 2020 8:12 pm

I pretty much agree with everything you said, keiranhalcyon7. Yes, the problem is the projection from 3D to 2D through a single projection point -- that always causes some distortion at the edges of the screen.

The lenses for the VR headsets all have different strengths and geometries; but SteamVR is *expected* to do the lens correction automatically. Having said that, there are some tools out there (https://github.com/sencercoltu/steamvr-undistort, https://steamcommunity.com/app/358720/d ... 677671314/) that help tweak the distortion applied by SteamVR. However, it looks like this is necessary only if the lenses/headset have been customized (new lenses have been installed, or extra foam has been applied thus increasing the effective focal length). The VRParams "apply_lens_correction" is an on/off switch; but its strength can be fine-tuned by 3 parameters in VRParams (k1, k2, k3).

When a square is viewed through a VR lens without lens correction, it looks like a pincushion with a horrible distortion near the edges. The edges speed away when you turn your head (this sounds very similar to the problem reported here). To fix this, the images need a barrel effect to cancel the pincushion effect from the lenses.

Assuming that SteamVR is doing the proper lens correction, then yes, I totally agree with you that this sounds like a FOV issue. But adjusting the FOV doesn't seem to have helped so far :?

@cylonsurfer and @VanillaEssence: You may also try applying extra lens correction by setting "apply_lens_correction" to 1 in VRParams.cfg and then adjusting the effect in real-time with Ctrl+Alt + Arrow Keys. The settings for the lens correction are not automatically saved, though. So you'd need to press Ctrl+Alt+S to save them manually.

cylonsurfer
Cadet 4th Class
Posts: 14
Joined: Sun Feb 09, 2020 3:37 pm

Post by cylonsurfer » Sat Feb 22, 2020 2:05 pm

I just tried messing with the distortion in game. No good I'm afraid. In regards to the warping, in the videos you have seen it may look quite minor but during actual gameplay it is actually very apparent, much more so than in the video.

User avatar
blue_max
Lieutenant
XWAU Member
Posts: 941
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Sat Feb 22, 2020 9:32 pm

Hey cylonsurfer.

Alright, let's forget about the internal lens correction shader for now.

In the latest preview I posted above, I added a new parameter called "post_projection_size" that scales the image *after* it has been projected into 2D space. I believe you mentioned at some point that if "3d_window_size" is set to 1, then you don't see any distortion. So, the idea here was to keep "3d_window_size" at 1 (because you reported no distortion), while changing "post_projection_size" to get rid of the blank spaces. The only thing I fear here is that doing this may cause blurry vision, though.

So, just to be sure: did you try the method above?

cylonsurfer
Cadet 4th Class
Posts: 14
Joined: Sun Feb 09, 2020 3:37 pm

Post by cylonsurfer » Sat Feb 22, 2020 11:53 pm

No, sorry. I missed that completely. I just tried it, it seems to creat a "double image" and I'm sorry to say that the warping is still present.

User avatar
blue_max
Lieutenant
XWAU Member
Posts: 941
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Sun Feb 23, 2020 1:42 am

I kind of expected the double image; but I was hoping the warping would at least go away. Thanks for checking anyway.

... and this is the only game where this happens, correct?

There should be a file called "steamvr_mat.txt" in your XWA installation folder. Do you think you could perhaps send it to me?

One more thing, I think if you press 'S' (?) in the SteamVR compositor window that'll capture the images that are being sent to the headset. Do you think you could post them here as well?

EDIT: In the latest release:

https://www.dropbox.com/s/4ag3p9io01k5q ... 1.zip?dl=0

I added a new parameter in VRParams.cfg to toggle SteamVR's lens distortion correction called "steamvr_distortion_enabled". So, another thing you could try is setting this to 0 (which should cause even *more* distortion) and then enable the internal lens correction with Ctrl+B and adjust k2,k1 to see if that helps.

Post Reply