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):
Shader "Shader Forge/test" {
Properties {
}
SubShader {
Tags {
"IgnoreProjector"="True"
"Queue"="Transparent"
"RenderType"="Transparent"
}
GrabPass{ }
Pass {
Name "FORWARD"
Tags {
"LightMode"="ForwardBase"
}
ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_FORWARDBASE
#include "UnityCG.cginc"
#pragma multi_compile_fwdbase
#pragma only_renderers d3d9 d3d11 glcore gles
#pragma target 3.0
uniform sampler2D _GrabTexture;
struct VertexInput {
float4 vertex : POSITION;
float2 texcoord0 : TEXCOORD0;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
float4 projPos : TEXCOORD1;
};
VertexOutput vert (VertexInput v) {
VertexOutput o = (VertexOutput)0;
o.uv0 = v.texcoord0;
o.pos = UnityObjectToClipPos( v.vertex );
o.projPos = ComputeScreenPos (o.pos);
COMPUTE_EYEDEPTH(o.projPos.z);
return o;
}
float4 frag(VertexOutput i) : COLOR {
float2 sceneUVs = (i.projPos.xy / i.projPos.w);
float4 sceneColor = tex2D(_GrabTexture, sceneUVs);
////// Lighting:
////// Emissive:
float3 emissive = tex2D( _GrabTexture, i.uv0).rgb;
float3 finalColor = emissive;
return fixed4(finalColor,1);
}
ENDCG
}
}
FallBack "Diffuse"
CustomEditor "ShaderForgeMaterialInspector"
}
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.