Search Unity

2017.2.0f3 single pass stereo blit

Discussion in 'AR/VR (XR) Discussion' started by pinkwerks, Oct 26, 2017.

  1. pinkwerks

    pinkwerks

    Joined:
    Aug 26, 2014
    Posts:
    5
    I'm seeing this fail in my OnRenderImage() function when the player is set to single pass stereo

    tmp = new RenderTexture(source.width, source.height, 0, RenderTextureFormat.Default);
    tmp.Create();
    Graphics.Blit(source, tmp);
    Graphics.Blit(tmp, source);
    Graphics.Blit(source, destination);


    Where this does not:
    Graphics.Blit(source, destination);

    Am I doing something wrong setting up my tmp texture? I'm pretty sure I had this working in b9.

    I even tried running the blit with a custom material that attempted to do the right thing. FWIW the two UnityStereo* functions seem to do the same thing and I was never clear when to use one versus the other.

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

    Pass
    {
    CGPROGRAM
    #pragma vertex vert_img
    #pragma fragment frag

    #include "UnityCG.cginc"

    sampler2D _MainTex;
    half4 _MainTex_ST;

    fixed4 frag (v2f_img i) : SV_Target
    {
    // fixed4 col = tex2D(_MainTex, UnityStereoTransformScreenSpaceTex(i.uv));
    fixed4 col = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv, _MainTex_ST));
    return col;
    }
    ENDCG
    }
    }
    }


    Any thoughts here?
     
    Last edited: Oct 26, 2017
  2. mordechai30

    mordechai30

    Joined:
    Jun 18, 2017
    Posts:
    3
  3. pinkwerks

    pinkwerks

    Joined:
    Aug 26, 2014
    Posts:
    5
    Interesting - I had seen these (your?) posts.

    The last link to fogbugz is specifically for "single pass instanced" on HoloLens. I'm seeing this for "single pass" (non-instanced) for VR. I'm not saying they aren't the same bug, I just wanted to point that out in case a dev. was looking at this.

    FWIW, blit was working with the pass-through material in 2017.2.b9.
     
  4. syenet

    syenet

    Joined:
    May 13, 2013
    Posts:
    47
    you can try explicitly pass VRTextureUsage.TwoEyes to RenderTexture.GetTemporary(), this will return a doublewide rendertexture which automatically enables single pass stereo when blitting into it.
     
  5. Epic_Cube

    Epic_Cube

    Joined:
    Jul 3, 2012
    Posts:
    100
    @syenet
    similar issue here... is it a try or are you sure that it could be a solution to the problem?
    thx in advance
     
  6. syenet

    syenet

    Joined:
    May 13, 2013
    Posts:
    47
    From my experience, the VRTextureUsage.TwoEyes argument must be passed to make sure the rendertexture works in single pass stereo mode in 2017.2, and it works fine to me.