WarpTunnel.shader 2.0 KB

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