Instantly share code, notes, and snippets.

What would you like to do?
Vertex gradient shader that interpolates between 2 colours based on every vertex Y position.
Shader "Vertex/Gradient" {
Properties {
_TopColor("Top Color", Color) = (1,1,1,1)
_BottomColor ("Bottom Color", Color) = (1,1,1,1)
_Scale ("Scale", Float) = 1
_Offset ("Offset", Float) = 1
SubShader {
Tags {"Queue"="Transparent" "RenderType"="Transparent" "LightMode"="ForwardBase"}
LOD 100
Lighting Off
ZWrite On
Blend SrcAlpha OneMinusSrcAlpha
Cull Off
Pass {
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
fixed4 _TopColor;
fixed4 _BottomColor;
fixed _Scale;
fixed _Offset;
struct v2f {
float4 pos : SV_POSITION;
fixed4 col : COLOR;
v2f vert (appdata_full v)
v2f o;
o.pos = UnityObjectToClipPos (v.vertex);
o.col = lerp(_BottomColor,_TopColor, (v.vertex.y * _Scale) + _Offset);
return o;
float4 frag (v2f i) : COLOR {
float4 c = i.col;
return c;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment