Shader "Custom/FlowColor" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_FlowColor("Flow Color", Color) = (1,1,1,1)
_FlowRange("Flow Range", Float) = 0.01
}
SubShader {
Pass
{
Tags { "Queue" = "Geometry" }
CGPROGRAM
#include "UnityCG.cginc"
struct v2f
{
float4 vertex:POSITION;
float2 uv:TEXCOORD0;
float nr:TEXCOORD1;
};
sampler2D _MainTex;
float4 _FlowColor;
float _FlowRange;
v2f vert(appdata_base v)
{
v2f o;
o.uv = v.texcoord;
o.vertex = mul(UNITY_MATRIX_MVP,v.vertex);
float2 dir = normalize(float2(cos(_Time.y),sin(_Time.y)));
float2 worldNormal = normalize(mul((float3x3)_Object2World,v.normal)).xz;
o.nr = dot(dir,worldNormal);
return o;
}
fixed4 frag (v2f IN):COLOR
{
//fixed4 c = tex2D(_MainTex, IN.uv);
fixed fac = saturate(sign(IN.nr *(IN.nr-_FlowRange)));
fixed4 c=fac*tex2D(_MainTex, IN.uv) +(1-fac)*_FlowColor;
return c;
}
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
FallBack "Diffuse"
}