Search Unity

Single-Pass Stereo rendering causes double vision.

Discussion in 'AR/VR (XR) Discussion' started by hellowill89, May 4, 2018.

  1. hellowill89

    hellowill89

    Joined:
    Jan 8, 2013
    Posts:
    45
    When using Single-Pass Stereo, my game will switch, mid playthrough, to a double vision which looks like this:



    Note that this does not happen immediately at start but always eventually happens.

    It will even split the screen into 4ths sometimes like this:



    Interestingly, if I have a second camera overlayed on top of the messed up one, it renders fine. Like this:



    Has anyone else experienced this? What was the solution to fix it? This is on Windows and Unity 2018.
     
    P_Jong likes this.
  2. vrena

    vrena

    Joined:
    Nov 2, 2017
    Posts:
    2
    no reply to this yet? I have the same issue, but only when using networking.
     
  3. angularsen

    angularsen

    Joined:
    Apr 22, 2017
    Posts:
    18
    I'm having this exact same problem for the game I am developing. No easy way to reproduce, but I'm getting it once in a while on multiple PCs with different Oculus headsets and I have no idea how to fix it. The above comment mentions networking. I too am using a little bit of networking, but nothing heavy and it's not really an option not to use networking anyway. If only I had a consistent reproducible case, then I could test out different things, but I simply can't reproduce on command yet.

    - I've seen this error on and off since maybe the summer of 2019 in my Unity game, I don't recall exactly when or if I introduced any particular new changes at the time.
    - I am usually using the latest Unity version, so probably first seen on 2019.1.x
    - Only tested with Windows 10
    - Game is configured with single-pass rendering and standard render pipeline
    - Error only seen with Oculus Rift so far, not seen with HTC Vive yet
    - Seen with both Oculus SDK and OpenVR SDK
    - Seen in both editor (game tab + inside headset) and in standalone build (only in headset, game window was unaffected the last time I checked)
    - Seen on multiple PCs and headsets
    - Sometimes it fixes itself after maybe 10-20 seconds, but usually I have to restart the game or the Unity editor.
    - Sometimes it happens early in my simpler startup/lobby scene. Sometimes it happens after 30 minutes of playing in levels with post processing effects and way more detailed scenes.

    I have no idea what is causing it or how to fix it and it feels like a bug with either Unity or Oculus or both.

    My best theory right now is perhaps single-pass rendering mode, which I enabled maybe around early spring 2019.

    Another theory is that I'm using some post processing effects, such as Bloom and Color Grading, that maybe has some issues. Historically the post processing stack has had its share of problems, in particular with single-pass rendering mode. However, I've seen this on scenes without post processing so I'm kind of ruling it out.

    A third theory is that I started getting this after complying with Oculus' requirements to pause the game, mute the audio and deactivate the avatar and other VR-pose driven elements when the headset is removed or opening the Oculus dashboard in order to support Oculus' overlay dashboard. But I don't recall if this error started before or after this change.

    Hoping someone from Unity can reach out and give some pointers on how we should proceed to fix this. I'm happy to assist in any way I can to help provide debugging information.



     
    Last edited: Dec 7, 2019
  4. angularsen

    angularsen

    Joined:
    Apr 22, 2017
    Posts:
    18
    @hellowill89 did you find anything more on this issue?
    I've raised a support ticket with Oculus to hopefully to get some assistance as it's impacting my customers and I need to resolve it fast.
     
  5. angularsen

    angularsen

    Joined:
    Apr 22, 2017
    Posts:
    18
    @hellowill89 I think I have finally found the root cause of the problem.

    Post Processing does not seem to work with Adaptive Resolution. I have tried older versions and the latest versions.
    I'm using OVRManager and enabled Adaptive Resolution with min 0.7, max 2.0 values.

    Simplest repro so far
    I don't think this bug is limited to VR and Oculus, but this is my current setup.

    1. Start new project with 3D template on Unity 2019.2.17f1
    2. Import packages Post Processing 2.2.2 and Oculus Desktop 1.38.4
    3. Import Oculus Integration 12 from asset store
    4. Empty scene, add Camera with Post Process Layer and OVR Manager
    5. Enable Adaptive Resolution on OVR Manager and set min/max to 0.7/2.0.
    6. Enable Oculus XR SDK and connect Oculus Rift
    4. Enter play mode, you should be able to look around with the Rift. The image should degrade fairly quickly with scaling issues, but maybe not 100% of the time.

    If you fail to reproduce, maybe it helps load a heavier scene, something that causes adaptive resolution to change the render target resolution.
    You can also try dragging the max slider during runtime. I could only drag it to higher values, so you'd have to start with max=1.0 or something.

    Workarounds
    1. Don't use post processing, not a good option for me.
    2. Don't use adaptive resolution, I'll be doing this for now.

    Related links
    [V2] Incompatible with VRSettings.renderViewportScale changes at runtime · Issue #102 · Unity-Technologies/PostProcessing

    Related to Dynamic Resolution

    I've learned this is not the same as Adaptive Resolution, which uses renderViewPortScale and eyeTextureResolutionScale. It did however have similar bugs in Post Processing v2 and was fixed earlier this year. Maybe the fix for Adaptive Resolution can reuse some of that work?

    Breaking Dynamic Resolution · Issue #801 · Unity-Technologies/PostProcessing
    Adding support for dynamic resolution by JoJo2nd · Pull Request #834 · Unity-Technologies/PostProcessing
    v2.1+ breaking Dynamic Resolution on Xbox · Issue #728 · Unity-Technologies/PostProcessing
     
    Last edited: Dec 23, 2019
    hellowill89 likes this.
  6. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    460
    Same issue here. The double vision occurs when using Single-Pass Stereo and when using a custom shader written for single pass in mind. The shader is a simple fader shader, which is used in OnRenderImage() with the Graphics.Blit() function. If this code is disabled, so the shader is not used, the effect goes away.

    The shader:
    Code (CSharp):
    1. // Source: https://github.com/C-Through/VR-XRSceneLoader/blob/d6d0a53199df162fa6461ddcdc1199c6c1494ee1/Assets/Shaders/ScreenFade.shader
    2.  
    3. Shader "ScreenFader"
    4. {
    5.     Properties
    6.     {
    7.         _MainTex("Texture", 2D) = "white" {}
    8.         _FadeColor ("Color", Color) = (0,0,0,0)
    9.         _Intensity ("Intensity", float) = 0
    10.     }
    11.  
    12.     SubShader
    13.     {
    14.         Cull Off ZWrite Off ZTest Always
    15.  
    16.         Pass
    17.         {
    18.             CGPROGRAM
    19.             #pragma vertex vert
    20.             #pragma fragment frag
    21.          
    22.             #include "UnityCG.cginc"
    23.  
    24.             struct appdata
    25.             {
    26.                 float4 vertex : POSITION;
    27.                 float2 uv : TEXCOORD0;
    28.             };
    29.  
    30.             struct v2f
    31.             {
    32.                 float2 uv : TEXCOORD0;
    33.                 float4 vertex : SV_POSITION;
    34.                 UNITY_VERTEX_OUTPUT_STEREO
    35.             };
    36.  
    37.             v2f vert (appdata v)
    38.             {
    39.                 v2f o;
    40.                 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
    41.                 o.vertex = UnityObjectToClipPos(v.vertex);
    42.                 o.uv = v.uv;
    43.                 return o;
    44.             }
    45.          
    46.             UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
    47.             half4 _FadeColor;
    48.             half _Intensity;
    49.  
    50.             fixed4 frag(v2f i) : SV_Target
    51.             {
    52.                 UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
    53.                 fixed4 color = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
    54.                 fixed4 lerpedColor = lerp(color.rgba, _FadeColor.rgba, _Intensity);
    55.                 return lerpedColor;
    56.             }
    57.             ENDCG
    58.         }
    59.     }
    60. }
     
  7. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    460
    How could this shader be made to support Single-Pass rendering?
     
  8. saifshk17

    saifshk17

    Joined:
    Dec 4, 2016
    Posts:
    488
    I think the issue is at:

    UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex)

    in the shader. This could be the reason it shows double vision (screenspace + screenspace).
    If you are just using this shader to fade in/out, then I would suggest to use the script in Oculus library called as ScreenFade.cs/ScreenFader.cs. It will be attached to CentreAnchorCamera under OVRCameraRig and works better.
     
  9. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    460