_LightTex 1:扫光贴图
_Color 2:扫光颜色
_Intensity 3:强度
_Speed 4:运动速度
_Angle 5:扫光贴图uv中心点旋转
Shader "Unlit/UIWalklight"
{
Properties
{
_MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {}
_LightTex ("Light", 2D) = "black" {}
_Color ("Color", Color) = (255,255,255,1)
_Intensity("Intensity", Float) = 1
_Speed("Speed", Float) = 1
_Angle("Angle", Float) = 0
}
SubShader
{
LOD 100
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
}
Pass
{
Cull Off
Lighting Off
ZWrite Off
Fog { Mode Off }
Offset -1, -1
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
float4 _MainTex_ST;
sampler2D _LightTex;
float4 _LightTex_ST;
float4 _Color;
float _Speed,_Angle,_Intensity;
struct appdata_t
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
//float2 texcoord1 : TEXCOORD1;
fixed4 color : COLOR;
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
//float2 texcoord1 : TEXCOORD1;
fixed4 color : COLOR;
//half2 posInPanel : TEXCOORD3;
};
v2f o;
v2f vert (appdata_t v)
{
o.vertex = UnityObjectToClipPos(v.vertex);
//float2 clipSpace = o.vertex.xy / o.vertex.w;
//o.posInPanel = (clipSpace.xy + 1) * 0.5 - _PanelRect.xy;// Fix to 0-1//
o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
//o.texcoord1 = v.texcoord1;
o.color = v.color;
return o;
}
fixed4 frag (v2f IN) : COLOR
{
fixed4 main = tex2D(_MainTex, IN.texcoord);
float2 newUV = IN.texcoord.xy-float2(0.5,0.5);
newUV = float2(newUV.x*cos(_Angle)-newUV.y*sin(_Angle),newUV.y*cos(_Angle) + newUV.x*sin(_Angle));
newUV += float2(0.5,0.5);
half lightU = newUV.x - frac(_Time.y*_Speed);
half2 lightUV = half2(lightU, newUV.y) * _LightTex_ST.xy + _LightTex_ST.zw;
fixed4 light = tex2D(_LightTex, lightUV)*_Intensity;
fixed4 col = main + main * light.r*_Color;
return col * IN.color;
return col;
}
ENDCG
}
}
SubShader
{
LOD 100
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
}
Pass
{
Cull Off
Lighting Off
ZWrite Off
Fog { Mode Off }
Offset -1, -1
ColorMask RGB
Blend SrcAlpha OneMinusSrcAlpha
ColorMaterial AmbientAndDiffuse
SetTexture [_MainTex]
{
Combine Texture * Primary
}
}
}
}