Shader doesn't work in target 2.0 but work in 3.0. why ?

Hi !

To work, this code needs to be in target 3.0. Why? The code is simple right?

I’m on Graphics emulation OpenGL ES 2

           half4 frag (fragInput f) : COLOR
				{

					half4 retour;
					half4 tex = tex2D(_MainTex,(f.uv.xy * _Tile));
					half4 texAlpha = tex2D(_textureAlpha,f.uv.xy).a;
					
					retour.xyz = tex.xyz;
				    retour.a = texAlpha.a;
					return retour;
				}

The fragment of code you posted should not have any problems on SM2.

Check compiler output in the console window or post the rest of the shader. You could have too many texture interpolators or something going on in the vertex shader.

Shader "Custom/BouclierAImpact" {
	Properties {
		_MainTex ("Main Tex", 2D) = "white" {}
		_TextureAlpha("Alpha Tex",2D) = "white" {}
		_Tile("_Tile", Range(0.1,5) ) = 0
	}

	SubShader 
	{
		Tags
		{
			"Queue" = "Transparent"
			"IgnoreProjector" = "True"
			"RenderType" = "Transparent"
		}

		LOD 200

		Lighting off
	
		ZWrite off

		Fog { Mode Off }

		Cull off

		Blend SrcAlpha OneMinusSrcAlpha
	
		Pass
		{
			CGPROGRAM
			#pragma target 3.0
			#pragma vertex vert
			#pragma fragment frag
			#pragma glsl_no_auto_normalization
			#pragma fragmentoption ARB_precision_hint_fastest 

						
				uniform	sampler2D_half _MainTex;
				uniform	sampler2D_half _TextureAlpha;
				uniform fixed2 _factor;
				uniform	half _Tile;

				struct vertInput 
				{
					fixed4 pos : POSITION;
					fixed4 uv : TEXCOORD0;
				};

				struct fragInput 
				{
					fixed4 pos : SV_POSITION;
					fixed4 uv : TEXCOORD0;
				};
			
				fragInput vert (vertInput v)
				{
					fragInput o;

					o.pos = mul( UNITY_MATRIX_MVP, v.pos );
					o.uv =  v.uv;
					return o;
				}

				half4 frag (fragInput f) : COLOR
				{

					half4 retour;
					half4 tex = tex2D(_MainTex,(f.uv.xy * _Tile));
					half4 texAlpha = tex2D(_TextureAlpha,f.uv.xy).a;
					
					retour.xyz = tex.xyz;
				    retour.a = texAlpha.a;
					return retour;
				}

			ENDCG
		}
	}

	Fallback "Transparent/Diffuse",1
}

No log for this shader, that’s why I do not understand

I didnt try it but you can try to initialize retour, maybe it will work.
half4 retour = 0;

Strangely finishing my shader, my problem no longer appears.
So thank you for help even if I wanted to know why it does not work

The problem appears even if I do

                half4 frag (fragInput f) : COLOR

                {

                    half4 tex = tex2D(_MainTex,(f.uv.xy * _Tile));

                    half4 texAlpha = tex2D(_TextureAlpha,f.uv.xy).a;

                    
                    tex.a = texAlpha.a;

                    return tex;

Strangely finishing my shader, my problem no longer appears.
So thank you for help even if I wanted to know why it does not work

The shader appears to work for me in Unity 4.1.2f1 using OGLES 2 emulation, whether #pragma 3.0 is in there or not.

(I wrote this before the previous post, based on the earlier post that presented the whole shader)

Very strange ! But never mind it works now :smile: thx

One thing worth noting is that you should never use the Fallback command until you’ve finished the parts of the shader you’re writing yourself. Otherwise you will receive no warning as long as one of the fallbacks works.

you mean put Fallback out of Shader “ffff” { } ? Because it’s after subshader

No, you’ve got it in the right place. It’s just that when testing, you should comment it out because otherwise Unity will silently use the fallback if your shader isn’t working properly.

I understand now ^^ It’s a good idea indeed !