Skip to content

Instantly share code, notes, and snippets.

@ArturoNereu
Created October 11, 2016 22:32
Show Gist options
  • Save ArturoNereu/99c2446a53846ee11592446229080448 to your computer and use it in GitHub Desktop.
Save ArturoNereu/99c2446a53846ee11592446229080448 to your computer and use it in GitHub Desktop.
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
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment