fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
//边缘外发光
float rim = pow(saturate((1 - dot(normalize(i.normal), normalize(i.objViewDir)))),_RimPower)*_RimIntensity;
fixed4 rimColor = rim * _RimColor;
//流光效果
float2 flowUV = float2(i.uv.x, i.uv.y+_Time.y*_Speed);
fixed4 maskColor = tex2D(_MaskTex, flowUV);
fixed4 finalColor = col + rimColor* maskColor.r;
return finalColor;
//return maskColor;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
//流光效果
//使用纹理坐标,流光可能不是严格的从上到下或从下到上
//float2 flowUV = float2(i.uv.x, i.uv.y+_Time.y*_Speed);
//使用世界坐标偏移
float2 flowUV = float2(i.worldPos.x, i.worldPos.y*_Scale + _Time.y*_Speed);
fixed4 maskColor = tex2D(_MaskTex, flowUV);
fixed4 finalColor = col + _RimColor * maskColor.r;
return finalColor;
//return maskColor;
}
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
if (v.vertex.x<_Top && v.vertex.x>_Top - _Range){
o.litColor = float4(0, 1, 1, 1);
}
else {
o.litColor = float4(0, 0, 0, 0);
}
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv)+i.litColor;
return col;
}
4.溶解消失
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
o.DisVector = fixed2(0, 0);
if (v.vertex.x<_Top && v.vertex.x>_Top - _Range){
o.litColor = float4(0, 1, 1, 1);
}
else if (v.vertex.x >= _Top) {
//o.litColor = float4(1, 0, 0, 1);
o.DisVector = fixed2(1, v.vertex.x - _Top);
}
else {
o.litColor = float4(0, 0, 0, 0);
}
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv)+i.litColor;
if (i.DisVector.x > 0.8) {
clip(_ClipValue - i.DisVector.x * maskCol.a - i.DisVector.y);
}
return col;
}