Skip to content

Instantly share code, notes, and snippets.

@prucha
Created April 1, 2016 20:54
Show Gist options
  • Save prucha/6c3b9b768e916e8ba8f29603750735d2 to your computer and use it in GitHub Desktop.
Save prucha/6c3b9b768e916e8ba8f29603750735d2 to your computer and use it in GitHub Desktop.
Basic Texture Shader
Shader "Milan/Texture Unlit"
{
Properties
{
_Color("Main Color", Color) = (1,1,1,1)
_MainTex("Main Texture", 2D) = "white" {}
}
SubShader
{
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
struct appdata
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct v2f
{
float4 pos : SV_POSITION;
float2 texcoord : TEXCOORD0;
};
fixed4 _Color;
sampler2D _MainTex;
//Vertex Shader Function
v2f vert(appdata IN)
{
v2f OUT;
OUT.pos = mul(UNITY_MATRIX_MVP, IN.vertex);
OUT.texcoord = IN.texcoord;
return OUT;
}
//Fragment Shader Function
fixed4 frag(v2f IN) : COLOR
{
fixed4 texColor = tex2D(_MainTex, IN.texcoord);
return texColor;
//return _Color; //fixed4(1,1,0,1);
}
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment