Understanding my first shader

Oke, so I am writing my first shader and there are some things I don’t understand. This is what I have got so far:

Shader "Custom/Water" {
	Properties {
		_Color ("Test", Color) = (1.0,1.0,1.0,1.0)
	}
	SubShader {
		Pass{
			CGPROGRAM
			#pragma fragment frag
			#pragma vertex vert 
			
			uniform float4 _Color;
			
			struct VertexInput
			{
				float4 v : POSITION; 
			};
			
			struct FragmentInput
			{
				float4 c : SV_POSITION;
			};
			
			FragmentInput vert (VertexInput i)
			{
				FragmentInput o;
				o.c = mul(UNITY_MATRIX_MVP, i.v);
				return o;
			}
			
			float4 frag() : COLOR
			{
				return _Color;
			}

			ENDCG
		}
	} 
	FallBack "Diffuse"
}
  1. I don’t understand why I have to put " : COLOR" behind my frag(). Ik know it tells unity that its doing somthing with color but I don’t understand how it works. How can you assign somthing to a function?
  2. I don’t understand what the difference is between " POSITION" and “SV_POSITION”.
  3. I don’t understand why I need the VertexInput. Can’t I just put “float4 v : POSITION;” inside my FragmentInputy and then do " o.c = mul(UNITY_MATRIX_MVP, v);"?

I hope someone can help me with this, thanks in advance!

Start reading this one The Cg Tutorial - Chapter 1. Introduction

and then move on to that one:

https://en.wikibooks.org/wiki/Cg_Programming/Unity

Now for answer:

1 / those are called semantics. They tell the compiler that this value is glued to the corresponding item in the vertex. So COLOR means the color item in the vertex.

2 / About Cg shaders and parameters - Unity Answers

3 / You can, you also could pas nothing but passing a struct means you are getting many value in one shot. If you start passing independent values, your method signature will end up being really long. It is just anticipating your future needs, as you will be dealing with all kind of data later on.