Search Unity

VR Depth Camera (Layering)

Discussion in 'AR/VR (XR) Discussion' started by Roiw, Sep 13, 2019.

  1. Roiw

    Roiw

    Joined:
    Jan 15, 2013
    Posts:
    23
    Hi guys,

    I was making a cool pointer for my VR application but it's jittering when I move my head during the game.

    Before this pointer I had a similar one made with an UI image attached to the HMD and I didn't have any problem.

    Now the new pointer is a mesh that i create and scale at run-time, I wonder if this could be causing issues?

    Is there anything I am missing in regards to mesh generation and unity vr camera rendering that could be causing the issue? Any guesses and ideas are welcome :)
     
  2. StayTalm_Unity

    StayTalm_Unity

    Unity Technologies

    Joined:
    May 3, 2017
    Posts:
    182
    Big one with VR rendering is that we update the camera position 2x a frame: Once during Monobehaviour.Update(), and once during Application.onBeforeRender()
    This second one is likely what's causing the jitter. If you use Update, or LateUpdate, Unity is going to sneak in and move the camera *right* before rendering. That would explain why UI parented to the HMD works (it moves with the HMD and therefore gets that before render update), and a mesh in a separate part of the hierarchy does not. You'll want to register for Application.onBeforeRender() and update your meshes position there.

    In fact, if it's purely cosmetic, you can likely drop the Monobehaviour.Update() update and rely entirely on before render.

    Let me know if that fixes it for you!
    -Tom
     
    JoeStrout likes this.