The basic shader for Unity. A template to make more advanced ones.
Shader "CustomShaders/BareBoneShader"
{
//Properties
Properties
{
_Color("Main Color", Color) = (1,1,1,1)
}
//Subshaders
SubShader
{
//A pass for this subshader
Pass
{
//CG CODE SECTION
CGPROGRAM
//Define and register the vert and fragment functions
#pragma vertex vert
#pragma fragment frag
//Variables declaration inside CG, plugged into - the properties
uniform half4 _Color;
//The pack sent to the vertex shader
struct vertexInput
{
float4 vertex : POSITION;
};
//The pack resulted from the vertex shader, that will be sent to the fragment/pixel shader
struct vertexOutput
{
float4 pos : SV_POSITION;
};
vertexOutput vert(vertexInput v)
{
vertexOutput o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
return o;
}
half4 frag(vertexOutput i) : COLOR
{
return _Color;
}
ENDCG
//END OF CG CODE SECTION
}
}
}