Created
August 14, 2017 20:18
-
-
Save mikelovesrobots/63bbcf7382fbdb73f635353a356674a7 to your computer and use it in GitHub Desktop.
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 "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