Vertex color blending shader

Hi,

i’m trying to create a 3 layer terrain shader that uses the vertex colors in the mesh painted by the vertex painter modifier in 3ds max

Now i tried to make this shader but it gives me errors that doesn’t make any sense to me.

So here’s the shader:

Shader "Debug/Vertex color" {
Properties {
		_Color ("Color", Color) = (0,0,0,1)
		_Layer1 ("Layer1", 2D) = "white" {}
		_Layer2 ("Layer2", 2D) = "white" {}
		_Layer3 ("Layer3", 2D) = "white" {}
	}
SubShader {
    Pass {
        Fog { Mode Off }
        CGPROGRAM

        #pragma vertex vert
        #pragma fragment frag

		sampler2D _Layer1;
		sampler2D _Layer2;
		sampler2D _Layer3;
		float _Color;

        // vertex input: position, color
        struct appdata {
            float4 vertex : POSITION;
            fixed4 color : COLOR;
        };

        struct v2f {
            float4 pos : SV_POSITION;
            fixed4 color : COLOR;
			float2 uv_Layer1 : TEXCOORD0;
			float2 uv_Layer2 : TEXCOORD0;
			float2 uv_Layer3 : TEXCOORD0;
        };
        
        v2f vert (appdata v) {
            v2f o;
            o.pos = mul( UNITY_MATRIX_MVP, v.vertex );
            o.color = v.color;
            return o;
        }
        
        float4 frag (v2f i) : COLOR0
		{ 
			half4 l1 = tex2D (_Layer1, i.uv_Layer1);
			half4 l2 = tex2D (_Layer2, i.uv_Layer2);
			half4 l3 = tex2D (_Layer3, i.uv_Layer3);

			float4 out;

			out = (l1.rgb * i.color.r) + (l2.rgb * i.color.g) + (l3.rgb * i.color.b);

			return out; 
		}
        ENDCG
    }
}
}

and this is the error log:

Shader error in 'Debug/Vertex color': Shader program had errors at line 12

Shader error in 'Debug/Vertex color': Program 'frag', cast not allowed at line 50

Shader error in 'Debug/Vertex color': Program 'frag', syntax error, unexpected '=' at token "=" at line 50

Shader error in 'Debug/Vertex color': Program 'frag', type name expected at token "=" at line 50

Shader error in 'Debug/Vertex color': Program 'vert', cast not allowed at line 50

Shader error in 'Debug/Vertex color': Program 'vert', syntax error, unexpected '=' at token "=" at line 50

Shader error in 'Debug/Vertex color': Program 'vert', type name expected at token "=" at line 50

Shader error in 'Debug/Vertex color': Program 'frag', syntax error, unexpected ';' at token ";" at line 52

Shader error in 'Debug/Vertex color': Program 'frag', type name expected at token ";" at line 52

Shader error in 'Debug/Vertex color': Program 'vert', syntax error, unexpected ';' at token ";" at line 52

Shader error in 'Debug/Vertex color': Program 'vert', type name expected at token ";" at line 52

I would appreciate some corrections here.

Thanks!

Here you have no more errors:
As @Bunny83 said the out keyword was causing the error.

Shader "Debug/Vertex color" {
    Properties
    {
	    _Color	("Color", Color) = (0,0,0,1)
	    _Layer1 ("Layer1", 2D) = "white" {}
	    _Layer2 ("Layer2", 2D) = "white" {}
	    _Layer3 ("Layer3", 2D) = "white" {}
    }
    SubShader
	{
	    Pass
	    {
		    Fog { Mode Off }
		    CGPROGRAM
		    #pragma vertex vert
		    #pragma fragment frag
		     
		    sampler2D	_Layer1;
		    sampler2D	_Layer2;
		    sampler2D	_Layer3;
		    float 		_Color;
		    
		    struct appdata
		    {
			    float4 vertex : POSITION;
			    fixed4 color : COLOR;
		    };
		     
		    struct v2f
		    {
			    float4 pos : SV_POSITION;
			    fixed4 color : COLOR;
			    float2 uv_Layer1 : TEXCOORD0;
			    float2 uv_Layer2 : TEXCOORD1;
			    float2 uv_Layer3 : TEXCOORD2;
		    };
		     
		    v2f vert (appdata v)
		    {
			    v2f o;
			    o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
			    o.color = v.color;
			    return o;
		    }
		     
		    float4 frag (v2f i) : COLOR
		    {
			    half4 l1 = tex2D (_Layer1, i.uv_Layer1);
			    half4 l2 = tex2D (_Layer2, i.uv_Layer2);
			    half4 l3 = tex2D (_Layer3, i.uv_Layer3);
			     
			    float4 color = float4(1, 1, 1, 1);
			    color.rgb = (l1.rgb * i.color.r) + (l2.rgb * i.color.g) + (l3.rgb * i.color.b);
			    return color;
	    	}
	    ENDCG
	    }
    }
}