Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. Shader "Jove/Forward/Emissive/Particle"
  2. {
  3. Properties
  4. {
  5. _Color ("Color", Color) = (1.0,1.0,1.0,1.0)
  6. _MainTex ("Particle Texture", 2D) = "white" {}
  7. _EmissiveMult ("Emissive multiplier", Float) = 1.0
  8. _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
  9. }
  10.  
  11. SubShader
  12. {
  13. Tags
  14. {
  15. "RenderType" = "Transparent"
  16. "Queue" = "Transparent"
  17. "IgnoreProjector" = "True"
  18. }
  19.  
  20. Pass
  21. {
  22. Cull Off
  23. ZWrite Off
  24. Fog { Mode Off }
  25. ColorMask RGB
  26. Blend One OneMinusSrcAlpha
  27.  
  28. CGPROGRAM
  29. #pragma vertex vert
  30. #pragma fragment frag
  31. #pragma target 4.0
  32.  
  33. #include "JoveCG.cginc"
  34. #include "UnityCG.cginc"
  35.  
  36. sampler2D _MainTex;
  37. float4 _Color;
  38. float _EmissiveMult;
  39. float _InvFade;
  40.  
  41. struct appdata_t {
  42. float4 vertex : POSITION;
  43. float4 color : COLOR;
  44. float2 texcoord : TEXCOORD0;
  45. };
  46.  
  47. struct v2f {
  48. float4 pos : SV_POSITION;
  49. float4 color : COLOR;
  50. float2 texcoord : TEXCOORD0;
  51. #if (SOFT_PARTICLES == SOFT_PARTICLES_ON)
  52. float4 clipPos : TEXCOORD1;
  53. #endif
  54. };
  55.  
  56. float4 _MainTex_ST;
  57.  
  58. v2f vert (appdata_t v)
  59. {
  60. v2f o;
  61. o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
  62. o.color = v.color * _Color;
  63. o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  64.  
  65. #if (SOFT_PARTICLES == SOFT_PARTICLES_ON)
  66. o.clipPos = o.pos;
  67. #endif
  68.  
  69. return o;
  70. }
  71.  
  72. float4 frag (v2f i) : SV_Target
  73. {
  74. #if (SOFT_PARTICLES == SOFT_PARTICLES_ON)
  75. float2 screenUV = i.clipPos.xy / i.clipPos.w;
  76. screenUV.x = screenUV.x * 0.5f + 0.5f;
  77. screenUV.y = 0.5f - screenUV.y * 0.5f;
  78.  
  79. float sceneZ = SampleDepth(screenUV);
  80. float partZ = i.clipPos.z;
  81. float fade = saturate (_InvFade * (sceneZ-partZ));
  82. #else
  83. float fade = 1.0;
  84. #endif
  85.  
  86. float4 clr = i.color * tex2D(_MainTex, i.texcoord);
  87. float alpha = fade * clr.a;
  88.  
  89. return float4(clr.rgb * alpha * _EmissiveMult, alpha);
  90. }
  91. ENDCG
  92. }
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement