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

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

Discussion in 'Image Effects' started by zonopus, Sep 12, 2017.

  1. zonopus

    zonopus

    Joined:
    Nov 8, 2016
    Posts:
    4
    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" (https://docs.unity3d.com/Manual/Android-SinglePassStereoRendering.html), 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:

    Code (CSharp):
    1. Shader "Hidden/TestImageEffect"
    2. {
    3.     Properties
    4.     {
    5.         _MainTex ("Texture", 2D) = "white" {}
    6.     }
    7.    
    8.     SubShader
    9.     {
    10.         // No culling or depth
    11.         Cull Off ZWrite Off ZTest Always
    12.  
    13.         Pass
    14.         {
    15.             CGPROGRAM
    16.             #pragma vertex vert
    17.             #pragma fragment frag
    18.  
    19.             #include "UnityCG.cginc"
    20.  
    21.             UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
    22.             float4 _MainTex_ST;
    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 = TRANSFORM_TEX(v.uv, _MainTex);
    43.                 return o;
    44.             }
    45.            
    46.  
    47.             fixed4 frag (v2f i) : SV_Target
    48.             {
    49.                 UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
    50.                 fixed4 col = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
    51.                 // just invert the colors
    52.                 col = 1 - col;
    53.                 return col;
    54.             }
    55.             ENDCG
    56.         }
    57.     }
    58. }
    59.  
    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!
     

    Attached Files:

  2. zonopus

    zonopus

    Joined:
    Nov 8, 2016
    Posts:
    4
    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)"
     
    almaione-sdn likes this.