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

Using A Second Cam While Still Rendering The Vr Camera For The Vr Headset

Discussion in 'AR/VR (XR) Discussion' started by TrackLabs, Apr 10, 2019.

  1. TrackLabs

    TrackLabs

    Joined:
    Feb 18, 2019
    Posts:
    30
    Hey,

    I am not sure if I`m in the correct Section since the Topic was more (XR) focused.

    I am completely new to VR Unity, but what I am trying to do is (probably) pretty simple.

    I want to render the VR Camera so the person on the headset still sees everything normal, and at the same time render a second camera that can look at the VR Player from an outside view.

    Here a short video for example:

    https://i.gyazo.com/96cafa3bab90d3955a477993d7312e5d.mp4

    What you see on the Video is the Rendering for the Game on a Screen, so what People see if they watch someone playing VR. At the same time, the VR Player sees his own Perspective tho. He does not see the exact same thing everyone else does. So there are 2 Cameras rendering. 1 the VR Camera, 2 the other Camera for Spectators.

    How do I achieve this? Because I want to set a Camera at some location so that I can show this camera rendering on Screen, while I still see everything normal in VR.
    Putting a second Camera will break the VR Camera.

    Context:

    I am using an HTC Vive (And that's the only VR Headset I need it for. The project is just
     
  2. StayTalm_Unity

    StayTalm_Unity

    Unity Technologies

    Joined:
    May 3, 2017
    Posts:
    182
    Gabyalf, Alex-CG, satchell and 2 others like this.
  3. TrackLabs

    TrackLabs

    Joined:
    Feb 18, 2019
    Posts:
    30
    Sadly your Blog and Source Project is for the Oculus. I am using the Vive..so Importing and using your Program wont work for me.

    Also in your Blog you say to simply create a second camera, put it as Main Display and run the game. That stops rendering the VR camera tho, freezing the View inside the Headset. I can only switch between one of them, rendering one of the two. But not both at the same time. So what I need is a way to render both cameras at the same time.

    Thanks for your link to the blog, but im affraid it wont help me. Especially since the Blog uses Oculus SDK etc. and I am using HTC Vive
     
  4. jgwinner

    jgwinner

    Joined:
    Dec 21, 2016
    Posts:
    19
    I'm having exactly the same problem.

    I agree, the tutorial is pretty straight forward, and thank you for that.

    I dropped a camera in the scene, set it to "Main display (None)" and it never renders, on either screen. I have a main screen and a secondary screen, in addition to the VR display. I, at least, still get a VR display.

    We need to ship something in 2 days :( Does anyone have any suggestions?

    == John ==
     
  5. TrackLabs

    TrackLabs

    Joined:
    Feb 18, 2019
    Posts:
    30
    Quite a short goal to ship something in 2 Days if you haven`t even the Camera figured out, isn`t it? Anyway,

    I managed to find a solution. And forgot to post it here...

    Set your VR Cameras Depth to -1, the Target Display to Display 1. Target Eye to Both
    Set your Spectator Cameras Depth to 1, the Target Display to Display 1 as well. Target Eye to None (Main Display)

    I am not sure if its the right/perfect way to do it, but thats how it got it working for me
     
  6. jgwinner

    jgwinner

    Joined:
    Dec 21, 2016
    Posts:
    19
    I could only get one screen to work, basically a mirror of the current VR scene. Oddly, no combination of settings seemed to make other cameras work.

    Client, for whatever reason, wants to use Unreal now ... lol.

    == John ==
     
  7. Kjelle69

    Kjelle69

    Joined:
    Nov 9, 2016
    Posts:
    53
    Tracklabs. Your solution was exactly what I was looking for. Thanks :)

    ---


     
  8. LexMoge

    LexMoge

    Joined:
    Apr 14, 2018
    Posts:
    2
    Hi. :)

    We're developing a coop game with one player VR and another one PC.
    We're using SteamVR and the kit FirstPersonExploration Kit. We've just added the two players in the scene but now our PC Player can't move his cam vertically. Alone, both player are working well. But together, nope.

    If you have any advice :)
     
  9. alpahbeta2000

    alpahbeta2000

    Joined:
    Sep 11, 2013
    Posts:
    9
    I'm working on android cardboard using 2019.1.
    I modified camera depth value, it's not working at all.
    Do you have any clue?
    Thanks.
     
  10. chrpetry

    chrpetry

    Joined:
    Mar 7, 2018
    Posts:
    65
    Hello,

    I have a solution where a user can interact directly at the PC (mouse, keyboard) and another user uses the VR rig simultaneously on the same PC.
    Recently, since working with UnityXR (Unity 2021 + OpenXR), all cameras stopped rendering when my Oculus Rift S goes into 'sleep mode' (headset not being on a head / sensor not detecting anything).
    My previous solution with SteamVR (and Unity 2019) this worked as expected.
    I want other in game cameras to keep rendering. I don't care about the VR camera in that case.
    Of course when putting the headset on again, the VR camera should render the scene as expected.

    How can I prevent that my (disabled) headset sets all other cameras to sleep?
    If not possible, how can I force the Oculus headset to not go into sleep mode?

    Thanks in advance.
     
  11. chrpetry

    chrpetry

    Joined:
    Mar 7, 2018
    Posts:
    65
  12. StayTalm_Unity

    StayTalm_Unity

    Unity Technologies

    Joined:
    May 3, 2017
    Posts:
    182
    I do not. You can put a post it over the head sensor, but I don't think that's the kind of fix you want.

    I do know that OpenXR backends are setup to go into a sleep state whenever the user presence is not detected. I don't think there is a current workaround, but please put in a bug report. Our internal systems should fall back to regular rendering if headset rendering is not available in my opinion. I can try to forward this along unofficially, but a bug report will help keep everyone honest. Sadly I don't think there is a workaround right now.
     
  13. chrpetry

    chrpetry

    Joined:
    Mar 7, 2018
    Posts:
    65
    Alright, I created a bug report on this.
    I can post updates once there is a solution.
    Thanks for your reply!
     
  14. chrpetry

    chrpetry

    Joined:
    Mar 7, 2018
    Posts:
    65
    Last edited: Aug 30, 2021
  15. Iron-Warrior

    Iron-Warrior

    Joined:
    Nov 3, 2009
    Posts:
    838
    The issue above unfortunately seems to be labelled "by design", which doesn't sound correct--falling back to regular rendering would be the more intuitive solution, and the behaviour is inconsistent between SteamVR (which allows rendering the secondary cameras) and Oculus (which does not).

    EDIT: Related workaround, I notice that when OpenXR is enabled in the XR Management plugins it disables the ability to toggle the Oculus plugin. This behaviour can be removed by commenting a bit of the XR Management UI code...are there any issues with having both OpenXR and Oculus available at runtime? I'm thinking we could use the Oculus plugin when it is available, and fall back to OpenXR for SteamVR devices. Will test to see if this works.

    ANOTHER EDIT: Built out the above, seems to work in both the editor + builds. To achieve this I disable line 244 of XRLoaderOrderUI.cs
    Code (CSharp):
    1. SetDisablesStateOnLoadersFromLoader(loader);
    Which allows me to toggle on both Oculus and OpenXR loaders in the XR Management window. Then, I use
    XRGeneralSettings.Instance.Manager.TrySetLoaders(reorderedLoaders);
    to load Oculus/OpenXR in the desired order. Something odd is that the priority of the loaders seems to be reversed in builds vs. the editor; in the editor, the first element in the array is prioritized, while in builds it's the last element. I don't have a SteamVR headset with me to test to ensure it *does* fail to load Oculus when no headset is present, but planning to get a team member to test that tomorrow. Since secondary cameras continue to render in SteamVR when the headset is asleep, this workaround should solve my problem.

    Wondering if there's going to be any issues with having both loaders present, since there was clearly some thought behind prohibiting it in the first place.
     
    Last edited: Sep 6, 2021
  16. chrpetry

    chrpetry

    Joined:
    Mar 7, 2018
    Posts:
    65
  17. sh0v0r

    sh0v0r

    Joined:
    Nov 29, 2010
    Posts:
    325
    This doesn't work in URP 2022.11, the 2nd camera just renders with the default solid blue clear color.
     
  18. chrpetry

    chrpetry

    Joined:
    Mar 7, 2018
    Posts:
    65
    Now I'm stuck again in 2022.2.18f.
    Second camera does not render when Post-Process Layer is active.
     
  19. darketomaly

    darketomaly

    Joined:
    Dec 18, 2017
    Posts:
    1
    Seems to only work on multi pass (2022.3.4f1). We have the same setup on another project which does work with single pass instanced (2021.3.16f1) so I'm thinking it's a bug with the current Unity version. Both using the built-in render pipeline.
     
  20. chrpetry

    chrpetry

    Joined:
    Mar 7, 2018
    Posts:
    65
    I already created a bug report with example project for them. It seems they can't reproduce it on their side.
    Glad that I'm not the only one having this problem... Can't update until this is fixed
     
  21. lvcoc

    lvcoc

    Joined:
    Jul 26, 2018
    Posts:
    9
    2021.3.2 using vive openxr , all cameras still stop rendering when vr headset is sleeping.Can anyone help me?
     
  22. chrpetry

    chrpetry

    Joined:
    Mar 7, 2018
    Posts:
    65