Search Unity

Oculus Quest/Rift Mirror Shader

Discussion in 'VR' started by LiminalTeam, Sep 18, 2019.

  1. LiminalTeam

    LiminalTeam

    Joined:
    Sep 17, 2019
    Posts:
    6
    Hey guys, so I've got a mirror effect that works for the Oculus Go, but enabling Head Tracking on the Quest will cause double images/offset.

    From what I've read it could be because of the introduction of Asymmetric Fov.

    Code (CSharp):
    1.             v2f vert(float4 pos : POSITION, float2 uv : TEXCOORD0)
    2.             {
    3.                 v2f o;
    4.                 o.pos = UnityObjectToClipPos (pos);
    5.                 o.uv = TRANSFORM_TEX(uv, _MainTex);
    6.                 o.screenPos = ComputeNonStereoScreenPos(o.pos); //ComputeScreenPos
    7.  
    8.                 return o;
    9.             }
    10.  
    11.             fixed4 frag(v2f i) : SV_Target
    12.             {
    13.                 float2 uvRefl = i.screenPos.xy / i.screenPos.w;
    14.                 fixed4 refl = tex2D(_ReflectionTex, uvRefl) * _ReflectionStrength;
    15.  
    16.                 // Combine main color and reflection
    17.                 fixed4 col = saturate(_Color + refl);
    18.                 return col;
    19.             }

    Does anyone have a working mirror shader?
     
    Last edited: Sep 18, 2019