AnimBlend-Add.shader 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
  2. Shader "Particles/Anim Additive" {
  3. Properties {
  4. _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
  5. _MainTex ("Particle Texture", 2D) = "white" {}
  6. _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
  7. }
  8. Category {
  9. Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
  10. Blend SrcAlpha One
  11. ColorMask RGB
  12. Cull Off Lighting Off ZWrite Off
  13. SubShader {
  14. Pass {
  15. CGPROGRAM
  16. #pragma vertex vert
  17. #pragma fragment frag
  18. #pragma target 2.0
  19. #pragma multi_compile_particles
  20. #pragma multi_compile_fog
  21. #include "UnityCG.cginc"
  22. sampler2D _MainTex;
  23. fixed4 _TintColor;
  24. struct appdata_t {
  25. float4 vertex : POSITION;
  26. fixed4 color : COLOR;
  27. float4 texcoords : TEXCOORD0;
  28. float texcoordBlend : TEXCOORD1;
  29. UNITY_VERTEX_INPUT_INSTANCE_ID
  30. };
  31. struct v2f {
  32. float4 vertex : SV_POSITION;
  33. fixed4 color : COLOR;
  34. float2 texcoord : TEXCOORD0;
  35. float2 texcoord2 : TEXCOORD1;
  36. fixed blend : TEXCOORD2;
  37. UNITY_FOG_COORDS(3)
  38. #ifdef SOFTPARTICLES_ON
  39. float4 projPos : TEXCOORD4;
  40. #endif
  41. UNITY_VERTEX_OUTPUT_STEREO
  42. };
  43. float4 _MainTex_ST;
  44. v2f vert (appdata_t v)
  45. {
  46. v2f o;
  47. UNITY_SETUP_INSTANCE_ID(v);
  48. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  49. o.vertex = UnityObjectToClipPos(v.vertex);
  50. #ifdef SOFTPARTICLES_ON
  51. o.projPos = ComputeScreenPos (o.vertex);
  52. COMPUTE_EYEDEPTH(o.projPos.z);
  53. #endif
  54. o.color = v.color * _TintColor;
  55. o.texcoord = TRANSFORM_TEX(v.texcoords.xy,_MainTex);
  56. o.texcoord2 = TRANSFORM_TEX(v.texcoords.zw,_MainTex);
  57. o.blend = v.texcoordBlend;
  58. UNITY_TRANSFER_FOG(o,o.vertex);
  59. return o;
  60. }
  61. UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
  62. float _InvFade;
  63. fixed4 frag (v2f i) : SV_Target
  64. {
  65. #ifdef SOFTPARTICLES_ON
  66. float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
  67. float partZ = i.projPos.z;
  68. float fade = saturate (_InvFade * (sceneZ-partZ));
  69. i.color.a *= fade;
  70. #endif
  71. fixed4 colA = tex2D(_MainTex, i.texcoord);
  72. fixed4 colB = tex2D(_MainTex, i.texcoord2);
  73. fixed4 col = 2.0f * i.color * lerp(colA, colB, i.blend);
  74. //UNITY_APPLY_FOG(i.fogCoord, col);
  75. UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode
  76. return col;
  77. }
  78. ENDCG
  79. }
  80. }
  81. }
  82. }