标签:newUV Angle 扫光 vertex LightTex unity ui Off float2
_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
}
}
}
}
标签:newUV,Angle,扫光,vertex,LightTex,unity,ui,Off,float2 来源: https://blog.csdn.net/qqo_aa/article/details/119183280
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。