-
-
Save nickarthur/6369493f8cae8be819030b2da0eb4eb3 to your computer and use it in GitHub Desktop.
The basic shader for Unity. A template to make more advanced ones.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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