Advertisement
Guest User

ParticlesAdditiveMasked.shader

a guest
Mar 6th, 2017
2,698
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. Shader "Particles/AdditiveMasked" {
  2. Properties{
  3. _TintColor("Tint Color", Color) = (0.5,0.5,0.5,0.5)
  4. _MainTex("Particle Texture", 2D) = "white" {}
  5. _InvFade("Soft Particles Factor", Range(0.01,3.0)) = 1.0
  6. }
  7.  
  8. Category{
  9. Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
  10. Blend SrcAlpha One
  11. AlphaTest Greater .01
  12. ColorMask RGB
  13. ZTest Greater
  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.  
  21. // ---- Fragment program cards
  22. SubShader{
  23. Pass{
  24.  
  25. CGPROGRAM
  26. #pragma vertex vert
  27. #pragma fragment frag
  28. #pragma fragmentoption ARB_precision_hint_fastest
  29. #pragma multi_compile_particles
  30.  
  31. #include "UnityCG.cginc"
  32.  
  33. sampler2D _MainTex;
  34. fixed4 _TintColor;
  35.  
  36. struct appdata_t {
  37. float4 vertex : POSITION;
  38. fixed4 color : COLOR;
  39. float2 texcoord : TEXCOORD0;
  40. };
  41.  
  42. struct v2f {
  43. float4 vertex : POSITION;
  44. fixed4 color : COLOR;
  45. float2 texcoord : TEXCOORD0;
  46. #ifdef SOFTPARTICLES_ON
  47. float4 projPos : TEXCOORD1;
  48. #endif
  49. };
  50.  
  51. float4 _MainTex_ST;
  52.  
  53. v2f vert(appdata_t v)
  54. {
  55. v2f o;
  56. o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
  57. #ifdef SOFTPARTICLES_ON
  58. o.projPos = ComputeScreenPos(o.vertex);
  59. COMPUTE_EYEDEPTH(o.projPos.z);
  60. #endif
  61. o.color = v.color;
  62. o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  63. return o;
  64. }
  65.  
  66. sampler2D _CameraDepthTexture;
  67. float _InvFade;
  68.  
  69. fixed4 frag(v2f i) : COLOR
  70. {
  71. #ifdef SOFTPARTICLES_ON
  72. float sceneZ = LinearEyeDepth(UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos))));
  73. float partZ = i.projPos.z;
  74. float fade = saturate(_InvFade * (sceneZ - partZ));
  75. i.color.a *= fade;
  76. #endif
  77.  
  78. return 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord);
  79. }
  80. ENDCG
  81. }
  82. }
  83.  
  84. // ---- Dual texture cards
  85. SubShader{
  86. Pass{
  87. SetTexture[_MainTex]{
  88. constantColor[_TintColor]
  89. combine constant * primary
  90. }
  91. SetTexture[_MainTex]{
  92. combine texture * previous DOUBLE
  93. }
  94. }
  95. }
  96.  
  97. // ---- Single texture cards (does not do color tint)
  98. SubShader{
  99. Pass{
  100. SetTexture[_MainTex]{
  101. combine texture * primary
  102. }
  103. }
  104. }
  105. }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement