Created
January 25, 2016 03:04
-
-
Save sinclairtarget/e78a92f86ef0eeb13cb1 to your computer and use it in GitHub Desktop.
Simple Gradient Shader
This file contains hidden or 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 "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