Shader works in Editor but not running the game

Hello!

I’ve done a custom shader, and it works great in the editor, but as soon as I press the “Play” button, still in the editor, everything using it goes black :frowning:

Here’s my shader, hope you can help :slight_smile:

Shader "Custom/Mix" {
	Properties {
		_FirstDiffuse ("FirstDiffuse (RGB)", 2D) = "first" {}
		_FirstNormal ("FirstNormal (RGB)", 2D) = "firstBump" {}
		_SecondDiffuse ("SecondDiffuse (RGB)", 2D) = "secondwhite" {}
		_SecondNormal ("SecondNormal (RGB)", 2D) = "secondbump" {}
		_Blender ("Blender (RGB)", 2D) = "blender" {}
	}
	
	SubShader {
		Tags { "RenderType"="Opaque" }
		LOD 200
		
		CGPROGRAM
		#pragma surface surf Lambert

		sampler2D _FirstDiffuse;
		sampler2D _FirstNormal;
		sampler2D _SecondDiffuse;
		sampler2D _SecondNormal;
		sampler2D _Blender;
		
		struct Input {
			float2 uv_FirstDiffuse;
			float2 uv_SecondDiffuse;
			float2 uv2_Blender;
		};

		void surf (Input IN, inout SurfaceOutput o) {
			half4 firstColour = tex2D (_FirstDiffuse, IN.uv_FirstDiffuse);
			half3 firstNormal = UnpackNormal(tex2D (_FirstNormal, IN.uv_FirstDiffuse));

			half4 secondColour = tex2D (_SecondDiffuse, IN.uv_SecondDiffuse);
			half3 secondNormal = UnpackNormal(tex2D (_SecondNormal, IN.uv_SecondDiffuse));			
			
			half blender = tex2D(_Blender, IN.uv2_Blender).x;
			half4 finalColour = lerp(firstColour, secondColour, blender);
			half3 finalNormal = lerp(firstNormal, secondNormal, blender);
																					
			o.Albedo = finalColour.rgb;
			o.Normal = finalNormal.xyz;
			o.Alpha = 1.f;
		}
		ENDCG
	} 
	FallBack "Diffuse"
}

The default values you’ve got in your properties aren’t set right.

Generally you want “white”, “grey” or “black” for RGB textures and “bump” for Normal textures.

Could be it’s defaulting to some wonky values?

Thanks! I tried, but it didn’t work :frowning: : everything goes completely black as soon as I press “play” or I build the game.
This is the updated code:

Shader "Custom/Reveal" {
	Properties {
		_FirstDiffuse ("FirstDiffuse (RGB)", 2D) = "white" {}
		_FirstNormal ("FirstNormal (RGB)", 2D) = "bump" {}
		_SecondDiffuse ("SecondDiffuse (RGB)", 2D) = "white" {}
		_SecondNormal ("SecondNormal (RGB)", 2D) = "bump" {}
		_Blender ("Blender (RGB)", 2D) = "white" {}
	}
	
	SubShader {
		Tags { "RenderType"="Opaque" }
		LOD 200
		
		CGPROGRAM
		#pragma surface surf Lambert

		sampler2D _FirstDiffuse;
		sampler2D _FirstNormal;
		sampler2D _SecondDiffuse;
		sampler2D _SecondNormal;
		sampler2D _Blender;
		
		struct Input {
			float2 uv_FirstDiffuse;
			float2 uv_SecondDiffuse;
			float2 uv2_Blender;
		};

		void surf (Input IN, inout SurfaceOutput o) {
			half4 firstColour = tex2D (_FirstDiffuse, IN.uv_FirstDiffuse);
			half3 firstNormal = UnpackNormal(tex2D (_FirstNormal, IN.uv_FirstDiffuse));

			half4 secondColour = tex2D (_SecondDiffuse, IN.uv_SecondDiffuse);
			half3 secondNormal = UnpackNormal(tex2D (_SecondNormal, IN.uv_SecondDiffuse));			
			
			half blender = tex2D(_Blender, IN.uv2_Blender).x;
			half4 finalColour = lerp(firstColour, secondColour, blender);
			half3 finalNormal = lerp(firstNormal, secondNormal, blender);
																					
			o.Albedo = finalColour.rgb;
			o.Normal = finalNormal.xyz;
			o.Alpha = 1.f;
		}
		ENDCG
	} 
	FallBack "Diffuse"
}

Actually I found out tha no custom shader actually works, not even the dafult one when you create the shader.

This seems to me like a super major bug.

This is totally blocking the whole work we’re doing, so I hope a little “up” will not scare anyone.

Take out the fallback line, does it turn bright pink?

If you take out the LOD line, does the shader work as expected?

Does the shader give any errors in the inspector?

Does the shader work in the editor?