解决跑酷之前项目特效不能扭曲太大问题,引起的特效偏移问题,还有特效输入的颜色值Alpha 值渐变问题。
Shader "Custom/Curveds" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_QOffset ("Offset", Vector) = (0,0,0,0)
_Color ("Main Color", Color) = (1,1,1,1)
_Brightness ("Brightness", Float) = 0.0
_Dist ("Distance", Float) = 100.0
}
SubShader {
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
Blend SrcAlpha One
ColorMask RGB
Cull Off Lighting Off ZWrite Off
CGPROGRAM
#pragma surface surf Lambert vertex:vert alphatest:_Cut
struct Input
{
float2 uv_MainTex;
float4 color :COLOR;
};
sampler2D _MainTex;
float4 _QOffset;
float _Dist;
float _Brightness;
float4 _Color;
void vert (inout appdata_full v)
{
float4 vPos = mul (UNITY_MATRIX_MV, v.vertex);
float xsmeh=sin(_WorldSpaceCameraPos.z/120);
float zOff = vPos.z/_Dist;
vPos += _QOffset*zOff*zOff;
v.vertex = mul(transpose(UNITY_MATRIX_IT_MV), vPos);
#if SHADER_API_GLES
v.vertex.xyz*= 1.0;
#endif
}
void surf (Input IN, inout SurfaceOutput o)
{
o.Albedo =2.0 * tex2D(_MainTex, IN.uv_MainTex).rgb * _Brightness * _Color.rgb;
float alpha = 2.0* tex2D(_MainTex, IN.uv_MainTex).a * _Color.a * IN.color.a;
o.Alpha = alpha;
}
ENDCG
}
Fallback "Diffuse"
}