WarpTunnel.shader 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
  2. Shader "FORGE3D/Warp Tunnel" {
  3. Properties {
  4. _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
  5. _MainTex ("Particle Texture", 2D) = "white" {}
  6. _Speed("UV Speed", Float) = 1.0
  7. _WiggleX("_WiggleX", Float) = 1.0
  8. _WiggleY("_WiggleY", Float) = 1.0
  9. _WiggleDist("Wiggle distance", Float) = 1.0
  10. _MaxFadeStart("Max Fade Start", float) = 0
  11. _MaxFadeEnd("Max Fade End", float) = 0
  12. }
  13. Category {
  14. Tags { "Queue"="Transparent+2" "IgnoreProjector"="True" "RenderType"="Transparent" }
  15. Blend One One
  16. ColorMask RGB
  17. Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }
  18. SubShader {
  19. Pass {
  20. CGPROGRAM
  21. #pragma vertex vert
  22. #pragma fragment frag
  23. #pragma multi_compile_particles
  24. #include "UnityCG.cginc"
  25. sampler2D _MainTex;
  26. fixed4 _TintColor;
  27. struct appdata_t {
  28. float4 vertex : POSITION;
  29. fixed4 color : COLOR;
  30. float2 texcoord : TEXCOORD0;
  31. };
  32. struct v2f {
  33. float4 vertex : SV_POSITION;
  34. fixed4 color : COLOR;
  35. float2 texcoord : TEXCOORD0;
  36. float4 posWorld : TEXCOORD1;
  37. };
  38. float4 _MainTex_ST;
  39. float _Speed;
  40. float _MaxFadeStart, _MaxFadeEnd;
  41. float _WiggleX, _WiggleY, _WiggleDist;
  42. v2f vert (appdata_t v)
  43. {
  44. v2f o;
  45. o.posWorld = mul(unity_ObjectToWorld, v.vertex);
  46. o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
  47. o.vertex.x += sin(_Time.y * _WiggleX) * _WiggleDist;
  48. o.vertex.y -= sin(_Time.y * _WiggleY) * _WiggleDist;
  49. o.color = v.color;
  50. o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  51. return o;
  52. }
  53. fixed4 frag (v2f i) : SV_Target
  54. {
  55. i.texcoord.y += _Time.x * _Speed;
  56. float dist = distance(_WorldSpaceCameraPos.xyz, i.posWorld.xyz);
  57. float MaxFade = saturate((_MaxFadeEnd - dist) / (_MaxFadeEnd - _MaxFadeStart));
  58. return (_TintColor.a * 20) * _TintColor * tex2D(_MainTex, i.texcoord) * MaxFade;
  59. }
  60. ENDCG
  61. }
  62. }
  63. }
  64. }