Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Status of camera stacking for vr cockpit

Discussion in 'Universal Render Pipeline' started by larrydu88, Jun 21, 2020.

  1. larrydu88

    larrydu88

    Joined:
    Aug 5, 2018
    Posts:
    66
    I have a 3d space shooter I've been working on for mobile that I'd like to try out for vr. Of course this means having a cockpit, and I was wondering if a camera stacking cockpit for VR is workable with URP right now
     
  2. ShilohGames

    ShilohGames

    Joined:
    Mar 24, 2014
    Posts:
    2,834
    Yes, I have tested URP 7.4.1 with Unity 2019.4 in a space game project of mine. I successfully stacked the cameras. Camera stacking works better with URP now than it did with the built-in renderer.

    I also decided to use Beautify 2 for URP instead of Unity's post processing, and that also worked with stacked URP cameras.

    I have a 3D cockpit at the origin that I rotate to match the player's ship rotation. I keep the cockpit at the origin so it does not jitter in VR.
     
  3. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    297
    I am trying this in Unity 2019.3.0b6 and I have a world camera, and a cockpit camera. If only one of them is rendering, everything is OK, but when both are rendering, the world cam (lowest depth) is really jittery and shaky, while the cockpit cam is fine. Any idea what might be causing that?
     
  4. larrydu88

    larrydu88

    Joined:
    Aug 5, 2018
    Posts:
    66
    Innovine, I figured out the trick to eliminate the camera jitter. You need to have the worldcam update its position and rotation in LateUpdate rather than Update!

    It took me forever to figure this out, but once implemented, the results are dramatic!
     
  5. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    297
    I found an alternate solution... in my VR setup code I found a call to XRDevice.DisableAutoXRCameraTracking(Camera.main, true) and I changed this to false. Worked for me, where I have a second script on the other cameras which is doing InputTracking.GetNodeStates(states) and then TryGetPosition() for a tracked state and assign that to the transform. It's really a long time since I wrote that, no idea if it's good or not now but it appears to work ok. I'll come back to it some day and try some more experiments :)
     
unityunity