Android Single-pass stereo rendering with post-process effect not working

Hi,
I’m trying to get Single-pass rendering working on android with a simple post-process effect.

I’ve been following the manual for “Single-pass stereo rendering for android” (Unity - Manual: Single-pass stereo rendering for Android), but have not been able to get it to display properly on device.

It displays correctly for the left eye, but the right eye flickers the “made with unity” display. (see attachment for screenshot).

The image effect is currently just a simple invert colors for an example.

The image effect uses Graphics.Blit, with the following shader:

Shader "Hidden/TestImageEffect"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
    }
   
    SubShader
    {
        // No culling or depth
        Cull Off ZWrite Off ZTest Always

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
            float4 _MainTex_ST;

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
                UNITY_VERTEX_OUTPUT_STEREO
            };

            v2f vert (appdata v)
            {
                v2f o;
                UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                return o;
            }
           

            fixed4 frag (v2f i) : SV_Target
            {
                UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
                fixed4 col = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
                // just invert the colors
                col = 1 - col;
                return col;
            }
            ENDCG
        }
    }
}

It works as expected in the editor, but when deployed on android it only displays for the left eye. Any suggestions would be most appreciated!

So after further investigation, this appears to be a bug in 2017.1. It works in 2017.2 beta, and appears in the 2017.2 change log:
“XR: Fixed incorrect viewport in Single-Pass Stereo when blitting between different sized render textures. (945940)”

1 Like