Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect FOV conversion (might not affect real programs) #1716

Closed
Sgeo opened this issue Aug 24, 2021 · 5 comments
Closed

Incorrect FOV conversion (might not affect real programs) #1716

Sgeo opened this issue Aug 24, 2021 · 5 comments
Labels

Comments

@Sgeo
Copy link

Sgeo commented Aug 24, 2021

Describe the bug

The FOV conversion at

vr::VRTextureBounds_t CompositorBase::FovPortToTextureBounds(ovrFovPort eyeFov, ovrFovPort fov)
can be incorrect when the game-provided bounds are neither the default FOV bounds nor symmetrical. I imagine that those two cases do cover the vast majority of games. The attached reproduction is intentionally bizarre.

I believe that the correct calculation is taking the headset-suggested tan bounds and multiplying them by the game's projection matrix. If left tans were negative, then uMin = vrTanAngleLeft * 2 / (gameTanAngleRight - gameTanAngleLeft) - (gameTanAngleRight + gameTanAngleLeft) / (gameTanAngleRight - gameTanAngleLeft)

Even if I'm wrong about what the correct conversion is, the attached demo shows incorrect behavior in Revive.

To Reproduce
Steps to reproduce the behavior:
OculusRoomTiny_GL_modified.zip

  1. Run program, in Revive and on real Oculus headset

Expected behavior
The 3D view should look almost good, except there's a black area on most of the left of the view

Actual behavior
Weird distortion. The view is pushed excessively to the right, and does not behave properly as the head moves

Environment (please complete the following information):

  • App: Modified version of OculusRoomTiny_GL
  • OS: Win10
  • Headset: Oculus Quest 2

Versions (please complete the following information):

  • Revive: 2.1.1
  • SteamVR: beta 1.19.7

Additional context
The attached program contains the below code, to force an asymmetric FOV:

	hmdDesc.DefaultEyeFov[0].LeftTan = 0.17f;
	hmdDesc.DefaultEyeFov[1].LeftTan = 0.17f;

Screenshot of Oculus headset:
image

Screenshot of Revive:
image

@Sgeo Sgeo added the revive label Aug 24, 2021
@CrossVR
Copy link
Member

CrossVR commented Aug 24, 2021

Have you tried testing that demo on the latest beta version of ReviveXR? The OpenVR version is mostly deprecated and all development should focus on the OpenXR version which offers superior compatibility.

You'll have to build from source though, since the last development binary was deleted due to inactivity.

@Sgeo
Copy link
Author

Sgeo commented Feb 10, 2022

Just tried testing the most recent build from https://ci.appveyor.com/project/librevr/revive/build/artifacts, it closed immediately when I tried.

@CrossVR
Copy link
Member

CrossVR commented Feb 10, 2022

It looks like we'll be on OpenVR a while longer anyway. To check if your calculations are correct I'd recommend running Lucky's Tale on your modified build, if you have it.

That game uses a symmetric field of view which is the main reason for these calculations.

@CrossVR
Copy link
Member

CrossVR commented Mar 12, 2023

A little late, but I have figured out the correct math:

// Adjust the bounds based on the field-of-view in the game
result.uMin = (fov.LeftTan - eyeFov.LeftTan) / (fov.LeftTan + fov.RightTan);
result.uMax = 1.0f - (fov.RightTan - eyeFov.RightTan) / (fov.LeftTan + fov.RightTan);
result.vMin = (fov.UpTan - eyeFov.UpTan) / (fov.UpTan + fov.DownTan);
result.vMax = 1.0f - (fov.DownTan - eyeFov.DownTan) / (fov.UpTan + fov.DownTan);

@CrossVR
Copy link
Member

CrossVR commented Mar 12, 2023

Here's a quick paint graphic I used to figure out the correct answer:

image

CrossVR added a commit that referenced this issue Mar 12, 2023
@CrossVR CrossVR closed this as completed Mar 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants