Shader not working in executable and DX11

The title says it all. I use a GrabPass for my shader and it works just fine in the editor, but the second I change for DX11 or I make an executable, the GrabPass dissapears with my gloss and my normals and everything, leaving a grayish texture instead of my shader.

Screen in editor :
http://imageshack.us/a/img850/2373/9xtq.jpg

Screen with DX11/Executable :
http://imageshack.us/a/img132/5568/pcoz.jpg

(The white spots are another material I put on the plane, which is not affected)

And here is my shader :

Shader "Water/CustomWaterShader" {
	Properties {
	    _Color ("Main Color", Color) = (1,1,1,1)
	    _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0)
	    _Shininess ("Shininess", Range (0.01, 1)) = 0.078125
	    _BumpMap ("Normalmap", 2D) = "bump" {}
	    _BumpMap2 ("Normalmap", 2D) = "bump" {}
	    _Distortion ("Distortion", Range (75, 5)) = 40
	}
	     
	SubShader {
	    Tags {"Queue"="Overlay" "IgnoreProjector"="True" "RenderType"="Transparent"}
	    LOD 400
	    GrabPass{"_ScreenTex"}
	    Cull Off
	     
	    CGPROGRAM
	    #pragma surface surf BlinnPhong alpha
	     
	    sampler2D _BumpMap;
	    sampler2D _ScreenTex;
	    sampler2D _BumpMap2;
	    fixed4 _Color;
	    half _Shininess;
	    half _Distortion;
	     
		struct Input {
		    float2 uv_BumpMap;
		    float2 uv_BumpMap2;
		    float4 screenPos;
		};
		     
		void surf (Input IN, inout SurfaceOutput o) {
			float2 customUV;
		    customUV = float2((IN.screenPos.xy/IN.screenPos.w).xyxy);
					    
			#if SHADER_API_D3D9

			if (customUV.y > 0)

			        customUV.y = 1.0f - customUV.y;

			#endif
		 	
		    customUV = customUV + customUV * (UnpackNormal(tex2D(_BumpMap , IN.uv_BumpMap)/2 + tex2D(_BumpMap2 , IN.uv_BumpMap2)/2)/_Distortion);
			fixed4 bg = tex2D(_ScreenTex,customUV);
		    o.Albedo = bg.rgb * _Color.rgb;
		    o.Alpha = 1;
		    o.Gloss = 2;
		    o.Specular = _Shininess;
		    o.Normal = UnpackNormal(tex2D(_BumpMap , IN.uv_BumpMap)/2 + tex2D(_BumpMap2 , IN.uv_BumpMap2)/2);
	    }
	    ENDCG
	}
	     
    FallBack "Transparent/VertexLit"
}

Other things that might help :

-I have Unity Free

-I get these warnings on my shader :

Shader warning in 'Water/CustomWaterShader': Program 'vert_surf', incorrect number of arguments to numeric-type constructor (compiling for d3d11) at line 68
Shader warning in 'Water/CustomWaterShader': Program 'vert_surf', incorrect number of arguments to numeric-type constructor (compiling for d3d11_9x) at line 68

Oh and also, my shader seems to become vertex lit, which is pretty wierd.

1 Answer

1

1.) “…my shader seems to become vertex lit, which is pretty wierd…

That’s because you’ve specified to use VertexLit as the fallback shader on Line 56:

FallBack "Transparent/VertexLit"

I strongly recommend that you only put fallbacks in production shaders - when you’re developing you want to know when shaders are failing, not for them to silently degrade to a different shader :wink: The fact that it is having to use the fallback means that something is failing in your shader code, which brings us onto…

2.) “I have Unity Free

And there’s your problem. GrabPass is a Pro-only feature (as are renderTextures, which offer related functionality).

Huh. Well its not even written anywhere in the wiki that its Pro-Only, and why would it work in the editor and not in the executable?

indieed it isnt written in the reference that it's pro only. I am getting a similar error just now for no obvious reason. it sais it's in surf function. but the line i am changing to get the error is in a different function.