Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

HDRP and 4K display issue when enabling XRSettings

Discussion in 'Graphics Experimental Previews' started by AudrasC, May 22, 2019.

  1. AudrasC

    AudrasC

    Joined:
    Feb 19, 2016
    Posts:
    19
    Hello,

    I'm using Unity 2019.1.1 with HDRP 5.16.

    Objective: enabling and disabling VR in runtime and mirroring on a 4K display.

    Problem:
    When I enable VR using
    Code (CSharp):
    1. XRSettings.enabled = true;
    in code, it renders a black screen in the HMD or in the display when in using a 4K resolution in the Game tab.

    Comment:
    • When using a 2K resolution, VR works correctly.
    • When using a 4K resolution and starting directly in VR, it renders correctly but when disable/enable XRSettings, it doen't work anymore.
    Test Devices:
    Windows MR Sansung Odessey
    HTC Vive

    Here is the code:
    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.XR;
    6.  
    7. public class Setting : MonoBehaviour
    8. {
    9.     // Start is called before the first frame update
    10.     void Start()
    11.     {
    12.         DisableVR();
    13.     }
    14.     // Update is called once per frame
    15.     void Update()
    16.     {
    17.         if(Input.GetKeyDown(KeyCode.V))
    18.         {
    19.             EnableVR();
    20.         }
    21.         if (Input.GetKeyDown(KeyCode.C))
    22.         {
    23.             DisableVR();
    24.         }
    25.     }
    26.     IEnumerator LoadDevice(string newDevice, bool enable)
    27.     {
    28.         XRSettings.LoadDeviceByName(newDevice);
    29.         yield return null;
    30.         XRSettings.enabled = enable;
    31.     }
    32.     void EnableVR()
    33.     {
    34.         StartCoroutine(LoadDevice("openvr", true));
    35.     }
    36.     void DisableVR()
    37.     {
    38.         StartCoroutine(LoadDevice("", false));
    39.     }
    40. }
    41.  
    Does anyone know what to do to enable VR in runtime and mirroring on a 4K display ?
    Thank you.
     
    Last edited: May 23, 2019
  2. Benjams

    Benjams

    Unity Technologies

    Joined:
    Oct 27, 2017
    Posts:
    20
    We could not reproduce this issue. It would be helpful if you file a bug and attach a minimum repro project so we can investigate your issue directly. If you do open a bug, please reply to this thread so we can track your bug case down.
     
  3. AudrasC

    AudrasC

    Joined:
    Feb 19, 2016
    Posts:
    19
    Thank you for the reply.
    I found the solution :
    I had to set eyeTextureResolutionScale after a yield return null; otherwise it doesn't work.

    Code (CSharp):
    1.  
    2. IEnumerator LoadDevice(string newDevice, bool enable)
    3.         {
    4.             XRSettings.LoadDeviceByName(newDevice);
    5.             yield return null;
    6.             XRSettings.enabled = enable;
    7.             yield return null;
    8.             XRSettings.eyeTextureResolutionScale = 1.5f;
    9.         }
    10.  
    Is this the official way to do it ?

    I don't understand why it works when starting directly in VR with 4K resolution.

    Should I file a bug ticket ?
     
    Last edited: Jun 12, 2019
  4. Benjams

    Benjams

    Unity Technologies

    Joined:
    Oct 27, 2017
    Posts:
    20
    Adjustment of the eyeTextureResolutionScale should not be necessary, so it appears like you're still encountering an issue. We would appreciate a filed bug with a repro project - it will help us resolve this a little quicker since we weren't able to reproduce it locally.
     
  5. AudrasC

    AudrasC

    Joined:
    Feb 19, 2016
    Posts:
    19
    I have submitted a bug report, case 1162760.
    Hope this help.
     
  6. Benjams

    Benjams

    Unity Technologies

    Joined:
    Oct 27, 2017
    Posts:
    20
    Thanks for taking the time to file a report. We'll take a look.