Shader_Integrated Paticle(ValueControl).shader 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "GAPH Custom Shader/Integrated Particle/Integrated Particle (ValueControl)"{
  3. Properties{
  4. [HDR]_TintColor("Tint Color",Color) = (0.5,0.5,0.5,0.5)
  5. _AllColorFactor("All Color Factor",float) = 1.0
  6. _ColorRedFactor("Color Red Factor", float) = 1.0
  7. _ColorGreenFactor("Color Green Factor", float) = 1.0
  8. _ColorBlueFactor("Color Blue Factor",float) = 1.0
  9. _MainTex("Particle Texture", 2D) = "white" {}
  10. [Enum(UnityEngine.Rendering.BlendMode)]_BlendSrc ("BlendSrc", float) = 1
  11. [Enum(UnityEngine.Rendering.BlendMode)]_BlendDst ("BlendDst", float) = 1
  12. _InvFade("Soft Particle Factor", Range(0.01,3.0)) = 1.0
  13. }
  14. Category{
  15. Tags{"Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent"}
  16. Blend [_BlendSrc] [_BlendDst]
  17. ColorMask RGB
  18. Cull Off
  19. Lighting Off
  20. ZWrite Off
  21. SubShader {
  22. Pass{
  23. CGPROGRAM
  24. #pragma vertex vert
  25. #pragma fragment frag
  26. #pragma target 3.0
  27. #pragma multi_compile_particles
  28. #pragma multi_compile_fog
  29. #include "UnityCG.cginc"
  30. sampler2D _MainTex;
  31. fixed4 _TintColor;
  32. float _AllColorFactor;
  33. float _ColorRedFactor;
  34. float _ColorGreenFactor;
  35. float _ColorBlueFactor;
  36. struct appdata_t {
  37. half4 vertex : POSITION;
  38. half4 color : COLOR;
  39. half2 texcoord : TEXCOORD0;
  40. };
  41. struct v2f {
  42. half4 vertex : SV_POSITION;
  43. half4 color : COLOR;
  44. half2 texcoord : TEXCOORD0;
  45. UNITY_FOG_COORDS(1)
  46. #ifdef SOFTPARTICLES_ON
  47. half4 projPos : TEXCOORD2;
  48. #endif
  49. };
  50. float4 _MainTex_ST;
  51. v2f vert(appdata_t v)
  52. {
  53. v2f o;
  54. o.vertex = UnityObjectToClipPos(v.vertex);
  55. #ifdef SOFTPARTICLES_ON
  56. o.projPos = ComputeScreenPos(o.vertex);
  57. COMPUTE_EYEDEPTH(o.projPos.z);
  58. #endif
  59. o.color = v.color;
  60. o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
  61. UNITY_TRANSFER_FOG(o, o.vertex);
  62. return o;
  63. }
  64. sampler2D _CameraDepthTexture;
  65. half _InvFade;
  66. half4 frag(v2f i ) : SV_Target
  67. {
  68. #ifdef SOFTPARTICLES_ON
  69. half sceneZ = LinearEyeDepth(UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture,UNITY_PROJ_COORD(i.projPos))));
  70. half partZ = i.projPos.z;
  71. half fade = saturate(_InvFade * (sceneZ - partZ));
  72. i.color.a *= fade;
  73. #endif
  74. half4 tex = tex2D(_MainTex,i.texcoord);
  75. tex = float4( //Compose each color data using color factors
  76. (tex.r) * _ColorRedFactor * 0.75f,
  77. (tex.g) * _ColorGreenFactor * 0.75f,
  78. (tex.b) * _ColorBlueFactor* 0.75f, tex.a);
  79. half4 res = _AllColorFactor * i.color * _TintColor * tex; //Merge all factor
  80. UNITY_APPLY_FOG_COLOR(i.fogCoord, res, half4(0,0,0,0));
  81. return res;
  82. }
  83. ENDCG
  84. }
  85. }
  86. }
  87. }