先上效果图:
资源
shader代码如下:
Shader "Unlit/LightMoveShader"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_LightTex("LightTex",2D)="white"{}
_LightColor("Light Color",color)=(1,1,1,1)
_Value("value",Range(0,1))=0.2
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
sampler2D _LightTex;
fixed4 _LightColor;
float _Value;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
// sample the texture
float2 uv=i.uv;
//uv.x-=_Value;
uv.x+=_Value+_Time.z;
fixed4 lightcol=tex2D(_LightTex,uv)*_LightColor;
fixed4 col = tex2D(_MainTex, i.uv);
return col+lightcol;
}
ENDCG
}
}
}
将col+lightcol换成col*lightcol,会只显示流光的图像,