Open rwb1977 opened 3 years ago
We are also seeing this, only on WMR kits.
I am seeing this problem on 4 different computers in unity builds and out of the editor. If I were to guess it is a rounding error in the coordinates for the unity steam VR plugin. I think this because the error occurs predictably at the same location and it is not from reflections. I have verified that the error does not happen in the native WMR home environment or in the Steam VR executable lobby when unity is not hosting a VR session. I have tested on the latest Steam VR environment and earlier versions of Steam VR. Tested on the HP reverb G2. Please help this is a major issue for our studio!
I wrote a MonoBehavior SteamVRCameraGlitchFix which basically detects when this spike occurs in the rotation and calculates a projected "correct" rotation, and sets the camera. This has to occur in the OnPreCull. I tried it in the OnPreRender, but that had issues. But because OnPreCull can happen more than once per frame, you need a condition to protect calculating this more than once per frame.
private void OnPreCull() { if (Time.frameCount == lastFrameSeen) return;
Basically, I keep the last two frame's forward and up vectors. Then based on them I calculate where the next frame "should" likely be. Then I calculate the difference between the projected vectors and the ones calculated by Steam and put into the camera already. If they surpass some threshold error (spike), I use the projected value instead. Otherwise, no need to correct.
This seems to fix the issue for vast majority of cases. In theory it can still happen for small rotation spikes, but I haven't been able to see that condition trigger.
https://steamcommunity.com/app/250820/discussions/0/3113655160553656493/ https://forum.unity.com/threads/steamvr-random-camera-rotation-glitch-occasionally.1111609/
Okay, I think I'm in the right place now.
I'm using Unity 2019.4.23 and the SteamVR unity plugin 2.7.2. I am having an issue where occasionally but regularly, the camera will "snap" or "flip" to another rotation for one or a few frames at a time, and then "snap" or "flip" back to the original orientation. The position doesn't change. This doesn't happen in other VR apps for SteamVR. Only for the SteamVR app I'm building with Unity. (Some sort of gimbal lock?)
I've captured the camera values every frame and can plot the random nature in which the rotation of the camera suddenly changes, and spikes way out of line.
I'm using the XR framework, the XR Rig.
I'm seeing this when using a WMR headset on an MSI backpack via SteamVR.
When I build an Oculus client, I cannot reproduce this.
So, it seems to be some sort of low-level Unity/SteamVR bug with setting the camera orientation from the device.
Anybody else seeing this?
This doesn't happen in Unity Editor, just a build.
Here's a plot of the difference in y values and difference in z values of the forward vector from frame to frame of the camera. This shows sudden jolting spikes, revealing the "glitch", but the difference from frame to frame should be "small" near 0.