Additive.shader 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. Shader "Immersal/Samples/Additive"
  2. {
  3. Properties
  4. {
  5. _MainTex("Color Gradient Texture", 2D) = "white" {}
  6. _AlphaTex("Alpha Texture", 2D) = "white" {}
  7. _Tint("Tint", Color) = (1.0, 1.0, 1.0, 1.0)
  8. _Intensity("Intensity", Range(0, 5)) = 1.0
  9. _TrailSpeed("Trail Speed", Range(-1.0, 1.0)) = 0.0
  10. }
  11. SubShader
  12. {
  13. Tags
  14. {
  15. "RenderType" = "Transparent"
  16. "Queue" = "Transparent"
  17. "IgnoreProjector" = "True"
  18. }
  19. LOD 100
  20. Lighting Off
  21. Pass
  22. {
  23. Blend One One
  24. Cull Off
  25. ZTest LEqual
  26. ZWrite Off
  27. //Offset 0, -1
  28. CGPROGRAM
  29. #pragma target 3.0
  30. #pragma vertex vert
  31. #pragma fragment frag
  32. // make fog work
  33. #pragma multi_compile_fog
  34. #include "UnityCG.cginc"
  35. struct appdata
  36. {
  37. float4 vertex : POSITION;
  38. float2 uv0 : TEXCOORD0;
  39. float2 uv1 : TEXCOORD2;
  40. };
  41. struct v2f
  42. {
  43. float4 vertex : SV_POSITION;
  44. float2 uv0 : TEXCOORD0;
  45. float2 uv1 : TEXCOORD2;
  46. UNITY_FOG_COORDS(1)
  47. };
  48. sampler2D _MainTex;
  49. sampler2D _AlphaTex;
  50. float4 _MainTex_ST;
  51. float4 _AlphaTex_ST;
  52. fixed4 _Tint;
  53. half _Intensity;
  54. half _TrailSpeed;
  55. v2f vert(appdata v)
  56. {
  57. v2f o;
  58. UNITY_INITIALIZE_OUTPUT(v2f, o);
  59. o.vertex = UnityObjectToClipPos(v.vertex);
  60. o.uv0 = TRANSFORM_TEX(v.uv0, _AlphaTex);
  61. o.uv1 = TRANSFORM_TEX(v.uv1, _MainTex);
  62. UNITY_TRANSFER_FOG(o,o.vertex);
  63. return o;
  64. }
  65. fixed4 frag(v2f i) : SV_Target
  66. {
  67. half2 uv0_anim = half2(i.uv0.x + _Time.y * _TrailSpeed, i.uv0.y);
  68. fixed alpha = tex2D(_AlphaTex, uv0_anim);
  69. fixed4 col = tex2D(_MainTex, i.uv1);
  70. col *= _Tint * _Intensity * alpha;
  71. // apply fog
  72. UNITY_APPLY_FOG(i.fogCoord, col);
  73. return col;
  74. }
  75. ENDCG
  76. }
  77. }
  78. Fallback "Diffuse"
  79. }