Skip to content

Instantly share code, notes, and snippets.

@mikelovesrobots
Created August 14, 2017 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikelovesrobots/63bbcf7382fbdb73f635353a356674a7 to your computer and use it in GitHub Desktop.
Save mikelovesrobots/63bbcf7382fbdb73f635353a356674a7 to your computer and use it in GitHub Desktop.
Shader "Hidden/RedOffsetShader" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
float4 frag(v2f_img i) : COLOR {
half4 color = tex2D(_MainTex, i.uv);
for (float y = -0.5; y <= 0; y += 0.025) {
float2 offsetUv = float2(i.uv.x, i.uv.y + y);
half4 offsetColor = tex2D(_MainTex, offsetUv);
if (offsetColor.r > offsetColor.g &&
offsetColor.r > offsetColor.b) {
offsetColor.rgb = lerp(color.rgb, offsetColor.rgb, abs(0.5 + y));
return offsetColor;
}
}
return color;
}
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment