Search Unity

Depth map right eye issue with VR single pass instanced stereo on Android

Discussion in 'VR' started by stephero, Oct 26, 2018.

  1. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    83
    Hi guys,
    I am struggling to properly sample the _CameraDepthTexture when using the VR Stereo Rendering Method "Single Pass" on Android (I am testing with Oculus VR SDK on a Gear VR). Depending on the Unity version, this option is named "Single Pass (Preview)" or Single Pass Instanced (Preview)".

    I basically followed this page: https://docs.unity3d.com/Manual/SinglePassInstancing.html

    In my v2f struct I added:
    Code (CSharp):
    1. struct v2f
    2. {
    3. // ...
    4.  
    5.     UNITY_VERTEX_INPUT_INSTANCE_ID
    6.     UNITY_VERTEX_OUTPUT_STEREO
    7. };
    8.  
    Then I added this in my vertex shader:
    Code (CSharp):
    1.  v2f vert(appdata_base v)
    2. {
    3.     v2f o;
    4.     UNITY_SETUP_INSTANCE_ID(v);
    5.     UNITY_INITIALIZE_OUTPUT(v2f, o);
    6.     UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
    7.     // ...
    And this in my fragment shader:
    Code (CSharp):
    1. half4 frag(v2f i)
    2. {
    3.     UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
    4.     // ...
    And this is how I sample my depth map:
    Code (CSharp):
    1. UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
    2.  
    3. //...
    4.  
    5. LinearEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, uv));
    6.  

    On VR PC with an Oculus Rift CV1, I can enable "single pass" without any problem. The eye index "unity_StereoEyeIndex" (0 for left and 1 for right) is properly transferred to the fragment shader. On the Rift, the macro UNITY_SINGLE_PASS_STEREO is defined and used.

    On Gear VR, the "unity_StereoEyeIndex" variable is also properly transferred to the fragment shader. The depth buffer value sampled is fine for the left eye, but always empty for the right eye. On Gear VR, UNITY_SINGLE_PASS_STEREO is not defined but UNITY_STEREO_MULTIVIEW_ENABLED is, which seems fine according to this page: https://docs.unity3d.com/Manual/SinglePassInstancing.html
    Note that it works fine if I use "Multi Pass" stereo mode. The problem occurs only with single pass.
    I tested with multiple versions of Unity, from 2017.3 to the latest 2018.3 beta, and the result is the same.

    What am I missing?
    Thanks
     
    Last edited: Oct 26, 2018
    P_Jong likes this.
  2. z_space

    z_space

    Joined:
    Jul 17, 2016
    Posts:
    10
    Did you ever solve this?
     
  3. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    83
    Nope, it's a bug in Unity. I reported it:
    No more info since then.
     
    P_Jong likes this.
  4. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,045
    Also seeing the same bug, I guess that's why single pass instanced is still in preview...
     
  5. jkieffer-filament

    jkieffer-filament

    Joined:
    Jun 13, 2017
    Posts:
    1
    @stephero Could you post a link to the issue? I'd like to upvote it.
     
  6. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    83