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

Hi guys,
I am struggling to properly sample the _CameraDepthTexture when using the VR Stereo Rendering MethodSingle 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: Unity - Manual: Single-pass instanced rendering and custom shaders

In my v2f struct I added:

struct v2f
{
// ...

    UNITY_VERTEX_INPUT_INSTANCE_ID
    UNITY_VERTEX_OUTPUT_STEREO
};

Then I added this in my vertex shader:

 v2f vert(appdata_base v)
{
    v2f o;
    UNITY_SETUP_INSTANCE_ID(v);
    UNITY_INITIALIZE_OUTPUT(v2f, o);
    UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
    // ...

And this in my fragment shader:

half4 frag(v2f i)
{
    UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
    // ...

And this is how I sample my depth map:

UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);

//...

LinearEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, uv));

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: Unity - Manual: Single-pass instanced rendering and custom shaders

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

1 Like

Did you ever solve this?

Nope, it’s a bug in Unity. I reported it:

No more info since then.

1 Like

Also seeing the same bug, I guess that’s why single pass instanced is still in preview…

@stephero Could you post a link to the issue? I’d like to upvote it.

It’s this one (issue ID 1099733): https://issuetracker.unity3d.com/issues/vr-android-depth-map-right-eye-issue-with-vr-single-pass-sampling-cameradepthtexture