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

HDRP + VR + Second Camera - Frustum Culling Issues

Discussion in 'High Definition Render Pipeline' started by rtilton1, Mar 19, 2020.

  1. rtilton1

    rtilton1

    Joined:
    Jan 4, 2017
    Posts:
    62
    I have an HDRP scene in Unity 2019.3.5f1. I am using VR (Oculus Rift) and have imported the XR Plugin Management correctly.

    The issue:
    I want to have a second camera in addition to the VR camera - in order to display a 3rd person view (this is what folks will see on the computer monitor when the exe is run). I created this Camera and set its depth higher than the VR camera. Everything looks correct, but when I press Play - this second camera only shows meshes within the VR user's frustrum. I want to have an overview of the whole scene with this second camera while the VR user is within the VR Camera/Rig. This has always worked for me in other render pipelines.

    Any idea what's going on? Is there a work-around or do I need to wait for Unity to update something?
     
    Last edited: Mar 19, 2020
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Hi I edited out the mass @ from your post. Please @ people when participating, not from the first post in a thread since that would pretty much fall foul of unsolicited spam rule since you don't know them well. If you did you'd invite them all in a PM or other way but only if you know them well.

    You can @ people you think might be interested during a conversation but this was pretty much spam :p
     
  3. rtilton1

    rtilton1

    Joined:
    Jan 4, 2017
    Posts:
    62
    I thought those were the Unity folks who dealt with VR + HDRP and would be interested, but I guess I won't @ people unless they comment...
     
  4. foonix

    foonix

    Joined:
    Dec 15, 2019
    Posts:
    20
    There are a lot of bugs related to XRSDK and multiple cameras. Probably this one is relevant:

    https://issuetracker.unity3d.com/is...espect-near-slash-far-clipping-plane-settings

    The VR camera disregards the clipping plane settings. It is possible that the problem in your case manifests in the texture camera using the headset's settings.

    May also be this one if the texture is exactly showing what the headset sees:

    https://issuetracker.unity3d.com/is...ameras-output-is-set-to-mirror-render-texture

    Basically the mirror view code is overwriting the camera's render target with the headset mirror.
     
  5. fabien-unity

    fabien-unity

    Unity Technologies

    Joined:
    Oct 17, 2018
    Posts:
    60
    Hi, I will look into the reported issues.
    @rtilton1 : could you submit a bug with a simple repro project so that I can investigate ?

    Thanks,
    Fabien
     
  6. fabien-unity

    fabien-unity

    Unity Technologies

    Joined:
    Oct 17, 2018
    Posts:
    60
  7. rtilton1

    rtilton1

    Joined:
    Jan 4, 2017
    Posts:
    62
    Last edited: Mar 20, 2020
  8. rtilton1

    rtilton1

    Joined:
    Jan 4, 2017
    Posts:
    62
    I just tried the change you did in HDRenderPipeline.cs - and it fixed the RT issue. Thank you so much for that @fabien-unity

    However - this frustum culling issue is still happening. The second camera is still using the frustum culling of the VR camera instead of its own frustum which causes meshes to pop in and out of the scene based on what the VR camera is/isn't looking at...
     
    Last edited: Mar 20, 2020
  9. rtilton1

    rtilton1

    Joined:
    Jan 4, 2017
    Posts:
    62
    @fabien-unity I also tried to hack around this issue by doing:

    Code (CSharp):
    1.         MeshFilter[] meshFilters = FindObjectsOfType<MeshFilter>();
    2.         foreach(MeshFilter mf in meshFilters)
    3.         {
    4.             mf.sharedMesh.bounds = new Bounds(Vector3.zero, Vector3.one * 500f);
    5.         }
    But that didn't work... Still seems to be doing frustum culling based on VR camera to the original meshfilter's bounds
     
  10. fabien-unity

    fabien-unity

    Unity Technologies

    Joined:
    Oct 17, 2018
    Posts:
    60
  11. rtilton1

    rtilton1

    Joined:
    Jan 4, 2017
    Posts:
    62
    Thanks @fabien-unity

    So this indeed fixed the frustum culling issue with multiple cameras!!! There is however one more issue which I apologize for not mentioning earlier. My second camera - the 3rd person camera... it seems to be taking over my VR display... In the default Unity pipeline I could just set this camera's "Target Eye" to "None (Main Display)" and it works perfectly. With HDRP this isn't an option and its actually placing the camera image fixed on my VR display since I set its depth higher than the VR camera in hopes to have it be displayed on the desktop monitor. Any idea how I would get around this? How do I make my second camera target just the main display and not the VR display?

    Just for clarity:
    The VR camera/rig is used by a VR user.
    The second camera is for folks not in VR to view the scene with a 3rd person camera.
     
    Last edited: Mar 21, 2020
  12. rtilton1

    rtilton1

    Joined:
    Jan 4, 2017
    Posts:
    62
    @fabien-unity since you indeed solved the original question in this thread I decided to make a separate thread for my new question about achieving a second camera to be displayed as main display with HDRP + VR:
    https://forum.unity.com/threads/hdrp-vr-target-eye-none-main-display.853099/

    Thanks again for all your help. If you have any leads to the other question it would be greatly appreciated (it's the final problem between me and launching a project)
     
    Mr-me-alexey likes this.
  13. fabien-unity

    fabien-unity

    Unity Technologies

    Joined:
    Oct 17, 2018
    Posts:
    60
    I'll look into it. It's a known issue but we want to get the design right.