assignment among incompatible concrete types

I’m getting some persistently irritating error messages for a shader I am working on. Despite the ease of reaching this error state, scouring Google for the error message yields little.

Here is the message I am getting:

Shader error in 'Custom/Flicker': Program 'SurfShaderInternalFunc', assignment among incompatible concrete types at line 22

Here is my shader:

Shader "Custom/Flicker" {
	Properties {
		_MainTex ("Texture", 2D) = "white" {}
		_NoiseTex ("Noise Texture", 2D) = "white" {}
	}
	SubShader {
		Tags { "RenderType" = "Opaque" }
		CGPROGRAM
		#pragma surface surf Lambert
		struct Input {
			float2 uv_MainTex;
		};
		sampler2D _MainTex;
		sampler2D _NoiseTex;
		
		float noiseChurn (float2 uv, float t) {
			return tex2D (_NoiseTex, uv+t);
		}
		
		float flicker (float2 uv) {
			float r;
			r = noiseChurn(uv, _Time.y); // *** This is the offending line
			r = noiseChurn(uv*10, r*100);
			return r;
		}
		
		void surf (Input IN, inout SurfaceOutput o) {
			o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb * flicker(IN.uv_MainTex);
		}
		ENDCG
	} 
	Fallback "Diffuse"
}

What is weird is that I am assigning a float to a float, so I don’t know where the incompatibility lies. It looks to me like Cg really seems to hate assignment to local variables. Can anyone help me diagnose what’s going on?
Cheers!

i think it’s caused by adding the float to a float2.
Maybe instead of line17 using “return tex2D (_NoiseTex, float2(uv.x+t, uv.y+t));” will solve your problem?
or maybe it’s caused by noiseChurn actually putting out a float4 instead of a float?

Thank you for your helpful response!
It ultimately did turn out to be caused by noiseChurn not returning the correct type. I solved the problem by replacing line 17 with “return tex2D (_NoiseTex, uv+t).x;”

The automatic cast in adding a float2 to a float does not seem to be problematic.
I am used to typed languages that tell you when a function is returning a type inconsistent with its signature, rather than a message saying that the resulting value is wrong. I suppose that Cg compile time treats function return types as “guidelines” :slight_smile: