Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Grab pass + VR is Broken

Discussion in '2017.2 Beta' started by matan_onehamsa, Sep 21, 2017.

  1. matan_onehamsa

    matan_onehamsa

    Joined:
    Feb 28, 2017
    Posts:
    2
    I'm trying to update my project from Unity 5.5.4p4 to Unity 2017.2.0b11 (I need this to target Windows MR)
    I'm stuck with a problem with some shaders that use Grab pass.
    To illustrate the problem I've created this simple project.
    It includes the SteamVR 1.2.2 plugin.
    In the scene I have the SteamVR Camera Rig prefab, some cubes and a Plane that has a material with the following shader on it (that I've created with Shader Forge):
    Code (CSharp):
    1. Shader "Shader Forge/test" {
    2.     Properties {
    3.     }
    4.     SubShader {
    5.         Tags {
    6.             "IgnoreProjector"="True"
    7.             "Queue"="Transparent"
    8.             "RenderType"="Transparent"
    9.         }
    10.         GrabPass{ }
    11.         Pass {
    12.             Name "FORWARD"
    13.             Tags {
    14.                 "LightMode"="ForwardBase"
    15.             }
    16.             ZWrite Off
    17.            
    18.             CGPROGRAM
    19.             #pragma vertex vert
    20.             #pragma fragment frag
    21.             #define UNITY_PASS_FORWARDBASE
    22.             #include "UnityCG.cginc"
    23.             #pragma multi_compile_fwdbase
    24.             #pragma only_renderers d3d9 d3d11 glcore gles
    25.             #pragma target 3.0
    26.             uniform sampler2D _GrabTexture;
    27.             struct VertexInput {
    28.                 float4 vertex : POSITION;
    29.                 float2 texcoord0 : TEXCOORD0;
    30.             };
    31.             struct VertexOutput {
    32.                 float4 pos : SV_POSITION;
    33.                 float2 uv0 : TEXCOORD0;
    34.                 float4 projPos : TEXCOORD1;
    35.             };
    36.             VertexOutput vert (VertexInput v) {
    37.                 VertexOutput o = (VertexOutput)0;
    38.                 o.uv0 = v.texcoord0;
    39.                 o.pos = UnityObjectToClipPos( v.vertex );
    40.                 o.projPos = ComputeScreenPos (o.pos);
    41.                 COMPUTE_EYEDEPTH(o.projPos.z);
    42.                 return o;
    43.             }
    44.             float4 frag(VertexOutput i) : COLOR {
    45.                 float2 sceneUVs = (i.projPos.xy / i.projPos.w);
    46.                 float4 sceneColor = tex2D(_GrabTexture, sceneUVs);
    47. ////// Lighting:
    48. ////// Emissive:
    49.                 float3 emissive = tex2D( _GrabTexture, i.uv0).rgb;
    50.                 float3 finalColor = emissive;
    51.                 return fixed4(finalColor,1);
    52.             }
    53.             ENDCG
    54.         }
    55.     }
    56.     FallBack "Diffuse"
    57.     CustomEditor "ShaderForgeMaterialInspector"
    58. }
    59.  
    Running this project on Unity 5.5.4p4 I see this view of the Plane in the game viewport:


    Running the same project on Unity 2017.2.0b11 gives me this view:


    As you can see, in 2017 we only see one eye (with some black bars) instead of both eyes.
     
  2. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    Hi matan_onehamsa,
    Could you please file a bug report with a minimal reproduction case and reply in here with the case #?
     
  3. matan_onehamsa

    matan_onehamsa

    Joined:
    Feb 28, 2017
    Posts:
    2
    I already did, here is the case number:
    Case 953360
     
    LeonhardP likes this.