Skip to content

Instantly share code, notes, and snippets.

@sinclairtarget
Created January 25, 2016 03:04
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sinclairtarget/e78a92f86ef0eeb13cb1 to your computer and use it in GitHub Desktop.
Save sinclairtarget/e78a92f86ef0eeb13cb1 to your computer and use it in GitHub Desktop.
Simple Gradient Shader
Shader "Custom/BasicGradient"
{
Properties
{
_TopColor ("Top Color", Color) = (1, 1, 1, 1)
_BottomColor ("Bottom Color", Color) = (1, 1, 1, 1)
_RampTex ("Ramp Texture", 2D) = "white" {}
}
SubShader
{
Pass
{
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
struct vertexIn {
float4 pos : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
v2f vert(vertexIn input)
{
v2f output;
output.pos = mul(UNITY_MATRIX_MVP, input.pos);
output.uv = input.uv;
return output;
}
fixed4 _TopColor, _BottomColor;
sampler2D _RampTex;
fixed4 frag(v2f input) : COLOR
{
return lerp(_BottomColor, _TopColor, tex2D(_RampTex, input.uv).a);
}
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment