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

Flickering UI in one eye (5.5.0f3)

Discussion in 'AR/VR (XR) Discussion' started by BlackPete, Feb 21, 2017.

  1. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    I just recently added a new world space canvas to our software with a basic panel, and it looked OK... or so I thought until I created a Win64 standalone build, and saw this:

    uiflicker.gif

    This has me stumped.

    This looks fine in the editor. It's only when I make a standalone build and run it, do I see this behaviour. This also only happens with the right eye in the VR headset. The left eye looks fine.

    I've also tried changing various things in the project to make this behaviour go away with little luck. Here are the things I've tried:

    1) Attach the UI to the camera as a world space canvas.
    2) Make the UI canvas its own game object as a screen space camera canvas

    Here's the really weird part: I have another world space canvas in the scene and that one does NOT flicker. I've compared both canvases, and they are identical, as far as I can tell.

    Plus I also have another screen space overlay canvas for the HUD on the main (non-VR) display, and that one does not flicker either. Toggling these canvas on/off have no effect on the flickering UI, however.

    At this stage, I think I need to take a step back and try to figure out what's causing the flicker in the first place instead of trying random things to make it stop as I don't like fixing things without understanding why it's broken in the first place.

    Here are the clues:

    1) Only happens in standalone builds.
    2) Only happens with the right eye in VR.
    3) Two world space canvases. One flickers, the other does not.
    4) Changing the flickering canvas into a SS-camera still flickers.
    5) This is a basic canvas and basic panel. No shaders or scripts attached. Only the color of the panel was changed.
    6) Disabling all other game objects (except the camera) has no effect.
     
  2. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    OK I think I've partially found the cause of this issue... although it's still not clear how or why it's happening.

    There's another (inactive) camera in the scene that's manually updated in code from an Update() call. That is, I create a temporary RT, call camera.Render(), perform a texture.ReadPixels(), and throw away the temporary RT.

    I use this for performing depth testing, but the purpose of this camera is irrelevant since the important bit is the camera.Render() call.

    When I comment out the camera.Render() call, the flickering stops.

    When I restore the camera.Render() call, the flickering returns.

    There's a shader included, but I've actually 100% commented out the entire shader file so it does nothing, and the flickering still persists. This rules out the shader.

    It also doesn't seem to be a render texture issue because I've also disabled/commented that out so only the camera.Render() remains. The flickering still occurs.

    I've tried messing around with the camera depth relative to the main VR camera (both before and after). No effect; flickering still persists.

    Changed the target display to 3 (non-existent) while VR camera is left on display 1. Flickering still exists.

    What gets me is this flickering happens with one world space canvas (and all UI within), but not the other world space canvas!

    If I changed the code around so that the camera is active and I let it handle its own rendering, then the flicker goes away.

    So that's one way to solve the issue, but it also brings its own set of problems I was hoping to avoid -- such as the ability to use temporary render textures, update when needed, and avoid dealing with lagging issues.

    Plus, I'm still mystified by the fact that this only happens to some UI, but not others. This camera also is supposed to have no relationship to either the UI or the main VR camera. It's just the fact that calling camera.Render() during Update() is somehow changing something internally for the right eye in VR for certain UI elements...? :confused::eek:o_O
     
  3. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    Welp, I ended up sweeping the bug under the carpet by merging the UIs into the one canvas that's known to be stable.

    Still no idea why the flicker existed in the first place with multiple world space canvas. I'll try revisiting this with a newer version of Unity eventually (perhaps when 5.6 is out).
     
  4. jaised

    jaised

    Joined:
    Jul 5, 2012
    Posts:
    17
    Have you tried it to perform the Render() in FixedUpdate() instead of Update()? Any differences?