Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Multiple Game Tabs Makes VR View Flicker

Discussion in 'VR' started by nimra7701, Mar 29, 2023.

  1. nimra7701

    nimra7701

    Joined:
    Sep 3, 2021
    Posts:
    2
    Im trying to make a project where one camera renders to the VR view and another camera renders to the desktop. To do this, I just add two cameras that each target a different display. I specifically want this to work in-edtior.

    However, when I open two game tabs so that I can view each of these displays, the VR view flickers. It looks like one static capture of the first frame of the scene, with a flickering overlay of what I should actually be seeing ontop of it. This happens any time that the game tabs are not all set to target the camera that is rendering to the VR headset - regardless of whether or not other cameras even exist. That is to say, the problem occurs any time there are two game tabs open that do not both target the display being rendered to the VR headset.

    Note that this problem does not occur in a build; I do not get flickering in a build and it works as intended. However, I specifically want this to also work in editor. I have tried rendering the camera's texture to something like an EditorWindow to avoid using the Game tab, but this solution is pretty janky and incomplete

    I am using Unity 2021.3.10f1 and SteamVR. Thanks in advance!

    (Related post that has a similar problem: https://answers.unity.com/questions/1813299/second-camera-in-editor-causes-flickerjudderlag-in.html )
     
  2. nimra7701

    nimra7701

    Joined:
    Sep 3, 2021
    Posts:
    2
    I found a bit of a solution: you don't actually need to target two different displays when using VR. When both my VR camera and the "desktop" camera target Display 1, it works fine. Thus, I can just have one Game tab open to render both to the headset and to the Game tab window on my desktop. This is quite misleading because you would think targetting the same display would cause some type of conflict. However, this does not work in a build. The VR camera overrides my "desktop" camera, so I dont even get to see the "desktop" camera's view. So I think my solution would be to target the same display in editor, but target different displays in a build.

    I should note that targeting different displays in a build forces you to use multi-display (https://docs.unity3d.com/Manual/MultiDisplay.html), which comes with its own problems.
     
  3. EdBlais

    EdBlais

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    311
    In build you should just be able to display the Camera rendering non-vr to the game window. That camera will not render in headset anyways, so it can be the top level camera for the primary window.
    In Editor, multiple game view windows being open can definitely cause conflicts due to the fact that the editor windows don't update at a specific frame rate until play mode is entered, which means the windows might not be updating at the same frame causing the flickering.
    In build, render textures should be updated in the same frame for all cameras, so you shouldn't have a flickering problem is two cameras were to target the same window and one had higher priority.
     
  4. Tech-Labs

    Tech-Labs

    Joined:
    Feb 5, 2014
    Posts:
    105
    I have a similar question but slightly extended.
    I have an app where you can choose VR or Monitor at start.
    I also would like to have 2 monitors active in both these conditions. The second monitor should show some data in a simple UI that is not visible for the player.
    When running the Monitor condition there is no problem.
    When running the VR condition the rendering in the headset is strangely lagging. When I start the same project but without the second display the VR rendering is smooth.
    This is when testing in the build version! In the Editor I disable one of the monitors to get the VR to run smoothly.
    Contrary to what EdBlais said, it seems the issue is present in builds too. At least in mine.

    Any other ideas on how to get the VR rendering smooth?

    Unity 2022.3.10 URP
    OpenXR 1.8.2 with HTC Vive Controller profile added
    Using a HTC Vive Pro Eye (and Pro 2)