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"
}
- 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?
- I don’t understand what the difference is between " POSITION" and “SV_POSITION”.
- 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!