effect_distortadd.shader 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "effect/distortadd" {
  3. Properties {
  4. _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
  5. _NoiseTex ("Distort Texture (RG)", 2D) = "white" {}
  6. _MainTex ("Alpha (A)", 2D) = "white" {}
  7. _TintTex ("Tint Texture", 2D) = "white" {}
  8. _BlendFactor("Blend Factor", range(1,2)) = 1.5
  9. _HeatTime ("Heat Time", range (-1,1)) = 0
  10. _ForceX ("Strength X", range (0,1)) = 0.1
  11. _ForceY ("Strength Y", range (0,1)) = 0.1
  12. }
  13. Category {
  14. Tags { "Queue"="Transparent" "RenderType"="Transparent" }
  15. Blend SrcAlpha OneMinusSrcAlpha
  16. Cull Off Lighting Off ZWrite Off
  17. Fog{ Mode Linear Color(0.87,0.87,0.87,1) Density 10.1 Range 0,10 }
  18. BindChannels {
  19. Bind "Color", color
  20. Bind "Vertex", vertex
  21. Bind "TexCoord", texcoord
  22. }
  23. SubShader {
  24. Pass {
  25. CGPROGRAM
  26. #pragma vertex vert
  27. #pragma fragment frag
  28. #pragma fragmentoption ARB_precision_hint_fastest
  29. #pragma multi_compile_particles
  30. #pragma multi_compile_fog
  31. #include "UnityCG.cginc"
  32. struct appdata_t {
  33. float4 vertex : POSITION;
  34. fixed4 color : COLOR;
  35. float2 texcoord: TEXCOORD0;
  36. };
  37. struct v2f {
  38. float4 vertex : POSITION;
  39. fixed4 color : COLOR;
  40. float2 uvmain : TEXCOORD1;
  41. float2 uvtint : TEXCOORD2;
  42. UNITY_FOG_COORDS(3)
  43. };
  44. fixed4 _TintColor;
  45. fixed _ForceX;
  46. fixed _ForceY;
  47. fixed _HeatTime;
  48. fixed _BlendFactor;
  49. float4 _MainTex_ST;
  50. float4 _TintTex_ST;
  51. float4 _NoiseTex_ST;
  52. sampler2D _NoiseTex;
  53. sampler2D _MainTex;
  54. sampler2D _TintTex;
  55. v2f vert (appdata_t v)
  56. {
  57. v2f o;
  58. o.vertex = UnityObjectToClipPos(v.vertex);
  59. o.color = v.color;
  60. o.uvmain = TRANSFORM_TEX( v.texcoord, _MainTex );
  61. o.uvtint = TRANSFORM_TEX( v.texcoord, _TintTex );
  62. UNITY_TRANSFER_FOG(o, o.vertex);
  63. return o;
  64. }
  65. fixed4 frag( v2f i ) : COLOR
  66. {
  67. //noise effect
  68. fixed4 offsetColor1 = tex2D(_NoiseTex, i.uvmain + _Time.xz*_HeatTime);
  69. fixed4 offsetColor2 = tex2D(_NoiseTex, i.uvmain + _Time.yx*_HeatTime);
  70. fixed4 tintTexColor = tex2D(_TintTex,i.uvtint);
  71. i.uvmain.x += ((offsetColor1.r + offsetColor2.r) - 1) * _ForceX;
  72. i.uvmain.y += ((offsetColor1.r + offsetColor2.r) - 1) * _ForceY;
  73. fixed4 mainTexColor = tex2D(_MainTex, i.uvmain);
  74. fixed3 fcolor = 2.0f * _TintColor.rgb * i.color.rgb * mainTexColor.rgb;
  75. fixed4 rcolor = fixed4(fcolor, _BlendFactor*tintTexColor.r*_TintColor.a);
  76. UNITY_APPLY_FOG(i.fogCoord, rcolor);
  77. return rcolor;
  78. }
  79. ENDCG
  80. }
  81. }
  82. // ------------------------------------------------------------------
  83. // Fallback for older cards and Unity non-Pro
  84. SubShader {
  85. Blend DstColor Zero
  86. Pass {
  87. Name "BASE"
  88. SetTexture [_MainTex] { combine texture }
  89. }
  90. }
  91. }
  92. }