Shader "Custom/YanlingShader" { Properties { _MainTex ("贴图", 2D) = "white" {} _Cutout("透明剔除值",Float) = 0.1 _SwirlArea("区域", Vector) = (400,800,0,0) _SwirlCenterXPercent("扭曲中心X偏移比例", Range(0,1)) = 0.5 _SwirlCenterYPercent("扭曲中心Y偏移比例", Range(0,1)) = 0.3 _Radius("扭曲半径", Float) = 400 _SwirlValue("扭曲程度", Float) = 1 } SubShader { Blend SrcAlpha OneMinusSrcAlpha Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag sampler2D _MainTex; fixed4 _SwirlArea; fixed _SwirlCenterXPercent; fixed _SwirlCenterYPercent; fixed _Radius; fixed _SwirlValue; fixed _Cutout; struct vin_vct { fixed4 vertex : POSITION; fixed4 color : COLOR; fixed2 texcoord : TEXCOORD0; }; struct v2f_vct { fixed4 vertex : SV_POSITION; fixed4 color : COLOR; fixed2 texcoord : TEXCOORD0; }; v2f_vct vert(vin_vct v) { v2f_vct o; o.vertex = UnityObjectToClipPos(v.vertex); o.color = v.color; o.texcoord = v.texcoord; return o; } fixed4 frag(v2f_vct i) : SV_Target { fixed2 swirlArea = fixed2(_SwirlArea.x, _SwirlArea.y); fixed2 center = fixed2(_SwirlArea.x * _SwirlCenterXPercent, _SwirlArea.y * _SwirlCenterYPercent); fixed2 targetPlace = i.texcoord * swirlArea; targetPlace -= center; fixed dis = length(targetPlace); if(dis < _Radius) { fixed percent = (_Radius - dis) / _Radius; fixed delta = percent * _SwirlValue; fixed s = sin(delta); fixed c = cos(delta); targetPlace = fixed2(dot(targetPlace, fixed2(c, -s)), dot(targetPlace, fixed2(s, c))); } targetPlace += center; fixed4 c = tex2D(_MainTex, targetPlace/swirlArea) * i.color; clip(c.a - _Cutout); c.a = 0.7f; c.b += 0.3f; return c; } ENDCG } } FallBack "Mobile/Particles/Addtive" }