EnviroWeatherParticles.shader 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. Shader "Enviro3/Particles/WeatherParticles"
  2. {
  3. Properties
  4. {
  5. _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
  6. _MainTex ("Particle Texture", 2D) = "white" {}
  7. _lightIntensity ("Light Intensity", Range(0.0,1.0)) = 1.0
  8. }
  9. Category {
  10. Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
  11. Blend SrcAlpha OneMinusSrcAlpha
  12. ColorMask RGBA
  13. Cull Off Lighting Off ZWrite Off
  14. SubShader {
  15. Pass {
  16. CGPROGRAM
  17. #pragma vertex vert
  18. #pragma fragment frag
  19. #pragma target 3.0
  20. #pragma multi_compile_particles
  21. #pragma multi_compile_fog
  22. #pragma exclude_renderers gles
  23. #include "UnityCG.cginc"
  24. #include "../Includes/ParticlesInclude.cginc"
  25. sampler2D _MainTex;
  26. fixed4 _TintColor;
  27. float4 _EnviroLighting;
  28. float _lightIntensity;
  29. struct appdata_t {
  30. float4 vertex : POSITION;
  31. fixed4 color : COLOR;
  32. float2 texcoord : TEXCOORD0;
  33. UNITY_VERTEX_INPUT_INSTANCE_ID
  34. };
  35. struct v2f {
  36. float4 vertex : SV_POSITION;
  37. fixed4 color : COLOR;
  38. float2 texcoord : TEXCOORD0;
  39. UNITY_FOG_COORDS(1)
  40. float4 projPos : TEXCOORD2;
  41. float3 posWorld : TEXCOORD3;
  42. UNITY_VERTEX_OUTPUT_STEREO
  43. };
  44. float4 _MainTex_ST;
  45. v2f vert (appdata_t v)
  46. {
  47. v2f o;
  48. UNITY_SETUP_INSTANCE_ID(v);
  49. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  50. o.vertex = UnityObjectToClipPos(v.vertex);
  51. o.posWorld = mul(unity_ObjectToWorld, v.vertex);
  52. o.projPos = ComputeScreenPos (o.vertex);
  53. COMPUTE_EYEDEPTH(o.projPos.z);
  54. o.color = v.color;
  55. o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  56. UNITY_TRANSFER_FOG(o,o.vertex);
  57. return o;
  58. }
  59. UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
  60. fixed4 frag (v2f i) : SV_Target
  61. {
  62. float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
  63. #ifdef SOFTPARTICLES_ON
  64. float partZ = i.projPos.z;
  65. float fade = saturate (0.5 * (sceneZ-partZ));
  66. i.color.a *= fade;
  67. #endif
  68. float4 col = 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord);
  69. //col *= _EnviroLighting * _lightIntensity;
  70. UNITY_APPLY_FOG(i.fogCoord, col);
  71. //float4 fog = TransparentFog(col,i.posWorld,i.projPos.xy,sceneZ);
  72. float blend = 1.0;
  73. WeatherEllipsoids(i.posWorld,blend);
  74. return float4(col.rgb,col.a * blend);
  75. }
  76. ENDCG
  77. }
  78. }
  79. }
  80. }