| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
- Shader "MoleGame/Particles/EffectDissolveAddSide"
- {
- Properties
- {
- _MainTex ("Texture", 2D) = "white" {}
- _TintColor("Tint Color", Color) = (1, 1, 1, 1)
- _SideColor("Side Color", Color) = (1, 1, 1, 1)
- _SideStep("Side Step", float) = 5
- _DissolveTex("DissolveTex", 2D) = "white" {}
- _Dissolve("Dissolve", Range(0, 1)) = 0
- }
- SubShader
- {
- Tags { "IgnoreProjector"="True"
- "Queue"="Transparent"
- "RenderType"="Transparent" }
- LOD 100
- Pass
- {
- Cull Off
- ZWrite off
- Lighting Off
- Blend SrcAlpha One
- CGPROGRAM
- #pragma fragmentoption ARB_precision_hint_fastest
- #pragma vertex vert
- #pragma fragment frag
- #pragma multi_compile_particles
-
- #include "UnityCG.cginc"
- struct appdata
- {
- half4 vertex : POSITION;
- fixed4 color : COLOR;
- half2 uv : TEXCOORD0;
- };
- struct v2f
- {
- half4 vertex : SV_POSITION;
- fixed4 color : COLOR;
- half2 uv : TEXCOORD0;
- half2 uv2 : TEXCOORD1;
- };
- sampler2D _MainTex;
- sampler2D _DissolveTex;
- fixed4 _MainTex_ST;
- fixed4 _DissolveTex_ST;
-
- v2f vert (appdata v)
- {
- v2f o;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.uv = TRANSFORM_TEX(v.uv, _MainTex);
- o.uv2 = TRANSFORM_TEX(v.uv, _DissolveTex);
- o.color = v.color;
- return o;
- }
-
- fixed4 _TintColor;
- fixed _Dissolve;
- fixed4 _SideColor;
- fixed _SideStep;
- fixed4 frag (v2f i) : SV_Target
- {
- fixed4 disov = tex2D(_DissolveTex, i.uv2);
- disov.r += i.color.a - 1;
- fixed clip_amount = disov.r - _Dissolve;
- clip(clip_amount);
- // sample the texture
- fixed4 col = tex2D(_MainTex, i.uv) * _TintColor;
- clip_amount = clamp(clip_amount * _SideStep, 0, 1);
- col.rgb = lerp(_SideColor, col.rgb, clip_amount); // clip_amount * col.rgb + (1 - clip_amount) * _SideColor;
- col.rgb *= i.color.rgb;
- return col;
- }
- ENDCG
- }
- }
- SubShader {
- Lighting Off
- ZWrite off
- Blend SrcAlpha One
- Pass {
- Name "BASE"
- SetTexture [_MainTex] {
- constantColor [_TintColor]
- combine texture * constant
- }
- SetTexture [_MainTex] {
- combine previous * Primary
- }
- }
- }
- }
|