effect_distortadd.shader 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. _HeatTime ("Heat Time", range (-1,1)) = 0
  8. _ForceX ("Strength X", range (0,1)) = 0.1
  9. _ForceY ("Strength Y", range (0,1)) = 0.1
  10. }
  11. Category {
  12. Tags { "Queue"="Transparent" "RenderType"="Transparent" }
  13. Blend SrcAlpha One
  14. Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }
  15. BindChannels {
  16. Bind "Color", color
  17. Bind "Vertex", vertex
  18. Bind "TexCoord", texcoord
  19. }
  20. SubShader {
  21. Pass {
  22. CGPROGRAM
  23. #pragma vertex vert
  24. #pragma fragment frag
  25. #pragma fragmentoption ARB_precision_hint_fastest
  26. #pragma multi_compile_particles
  27. #include "UnityCG.cginc"
  28. struct appdata_t {
  29. float4 vertex : POSITION;
  30. fixed4 color : COLOR;
  31. float2 texcoord: TEXCOORD0;
  32. };
  33. struct v2f {
  34. float4 vertex : POSITION;
  35. fixed4 color : COLOR;
  36. float2 uvmain : TEXCOORD1;
  37. };
  38. fixed4 _TintColor;
  39. fixed _ForceX;
  40. fixed _ForceY;
  41. fixed _HeatTime;
  42. float4 _MainTex_ST;
  43. float4 _NoiseTex_ST;
  44. sampler2D _NoiseTex;
  45. sampler2D _MainTex;
  46. v2f vert (appdata_t v)
  47. {
  48. v2f o;
  49. o.vertex = UnityObjectToClipPos(v.vertex);
  50. o.color = v.color;
  51. o.uvmain = TRANSFORM_TEX( v.texcoord, _MainTex );
  52. return o;
  53. }
  54. fixed4 frag( v2f i ) : COLOR
  55. {
  56. //noise effect
  57. fixed4 offsetColor1 = tex2D(_NoiseTex, i.uvmain + _Time.xz*_HeatTime);
  58. fixed4 offsetColor2 = tex2D(_NoiseTex, i.uvmain + _Time.yx*_HeatTime);
  59. i.uvmain.x += ((offsetColor1.r + offsetColor2.r) - 1) * _ForceX;
  60. i.uvmain.y += ((offsetColor1.r + offsetColor2.r) - 1) * _ForceY;
  61. return 2.0f * i.color * _TintColor * tex2D( _MainTex, i.uvmain);
  62. }
  63. ENDCG
  64. }
  65. }
  66. // ------------------------------------------------------------------
  67. // Fallback for older cards and Unity non-Pro
  68. SubShader {
  69. Blend DstColor Zero
  70. Pass {
  71. Name "BASE"
  72. SetTexture [_MainTex] { combine texture }
  73. }
  74. }
  75. }
  76. }