You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
3.7 KiB

5 years ago
  1. Shader "Hidden/FogVolume"
  2. {
  3. Properties
  4. {
  5. [hideininspector]_SrcBlend("__src", Float) = 1.0
  6. [hideininspector]_NoiseVolume("_NoiseVolume", 3D)= "white" {}
  7. [hideininspector]_NoiseVolume2("_NoiseVolume2", 3D) = "white" {}
  8. [hideininspector]_Gradient("_Gradient", 2D) = "white" {}
  9. [hideininspector]CoverageTex("CoverageTex", 2D) = "grey" {}
  10. //[hideininspector]_ShadowTexture("_ShadowTexture", 2D) = "white" {}
  11. }
  12. CGINCLUDE
  13. //#define COVERAGE
  14. //#define EARTH_CLOUD_STYLE
  15. //#define VOLUMETRIC_SHADOWS _VolumetricShadowsEnabled
  16. //#define CONVOLVE_VOLUMETRIC_SHADOWS
  17. //custom depth input
  18. //#define ExternalDepth
  19. #define AMBIENT_AFFECTS_FOG_COLOR _AmbientAffectsFogColor
  20. //#define DEBUG_PRIMITIVES
  21. #define VOLUMETRIC_SHADOWS _VolumetricShadowsEnabled
  22. #define FOG_TINTS_INSCATTER VolumeFogInscatterColorAffectedWithFogColor
  23. #include "UnityCG.cginc"
  24. #include "CommonInputs.cginc"
  25. #include "Integrations.cginc"
  26. #define PROBES _ProxyVolume
  27. half NoiseAtten = 1;
  28. int _SrcBlend;
  29. int _ztest;
  30. #include "FogVolumeCommon.cginc"
  31. #define DEBUG_ITERATIONS 1
  32. #define DEBUG_INSCATTERING 2
  33. #define DEBUG_VOLUMETRIC_SHADOWS 3
  34. #define DEBUG_VOLUME_FOG_INSCATTER_CLAMP 4
  35. #define DEBUG_VOLUME_FOG_PHASE 5
  36. #include "FogVolumeFragment.cginc"
  37. ENDCG
  38. //normal pass
  39. SubShader
  40. {
  41. Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "None" }
  42. LOD 600
  43. //Blend SrcAlpha OneMinusSrcAlpha
  44. //Blend One OneMinusSrcAlpha
  45. Blend[_SrcBlend] OneMinusSrcAlpha
  46. Fog{ Mode Off }
  47. Cull Front
  48. Lighting Off
  49. ZWrite Off
  50. ZTest [_ztest]
  51. Pass
  52. {
  53. CGPROGRAM
  54. //#pragma multi_compile _ ExternalDepth
  55. #pragma multi_compile _ _FOG_LOWRES_RENDERER
  56. #pragma shader_feature _INSCATTERING
  57. #pragma shader_feature VOLUME_FOG
  58. #pragma shader_feature _VOLUME_FOG_INSCATTERING
  59. #pragma shader_feature _FOG_GRADIENT
  60. #pragma shader_feature _FOG_VOLUME_NOISE
  61. // #pragma shader_feature _COLLISION
  62. //#pragma multi_compile _ DEBUG
  63. //#pragma shader_feature SAMPLING_METHOD_ViewAligned
  64. #pragma shader_feature HEIGHT_GRAD
  65. //#pragma shader_feature _TONEMAP
  66. #pragma shader_feature JITTER
  67. #pragma shader_feature ColorAdjust
  68. #pragma shader_feature ABSORPTION
  69. #pragma multi_compile _ Twirl_X Twirl_Y Twirl_Z
  70. #pragma shader_feature _SHADE
  71. #pragma shader_feature DF
  72. #pragma shader_feature DIRECTIONAL_LIGHTING
  73. #pragma multi_compile _ ATTEN_METHOD_1 ATTEN_METHOD_2 ATTEN_METHOD_3
  74. #pragma shader_feature SPHERICAL_FADE
  75. //#pragma shader_feature _LAMBERT_SHADING
  76. #pragma multi_compile _ VOLUME_SHADOWS
  77. #pragma shader_feature LIGHT_ATTACHED
  78. #pragma shader_feature HALO
  79. //Unity define for stereo is not working. Had to do it manually
  80. #pragma multi_compile _ FOG_VOLUME_STEREO_ON
  81. #pragma exclude_renderers d3d9
  82. //#pragma only_renderers d3d11
  83. #pragma vertex vert
  84. #pragma fragment frag
  85. #pragma target 3.0
  86. ENDCG
  87. }
  88. }
  89. //opacity pass . Only for shadow rt
  90. SubShader
  91. {
  92. Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "None" }
  93. LOD 100
  94. Blend SrcAlpha OneMinusSrcAlpha
  95. Fog{ Mode Off }
  96. Cull Front
  97. Lighting Off
  98. ZWrite Off
  99. ZTest Always
  100. Pass
  101. {
  102. Fog{ Mode Off }
  103. CGPROGRAM
  104. #define SHADOW_PASS
  105. #pragma shader_feature _FOG_GRADIENT
  106. #pragma shader_feature _FOG_VOLUME_NOISE
  107. // #pragma shader_feature _COLLISION
  108. #pragma shader_feature SAMPLING_METHOD_ViewAligned
  109. #pragma shader_feature HEIGHT_GRAD
  110. #pragma multi_compile Twirl_X Twirl_Y Twirl_Z
  111. #pragma shader_feature DF
  112. //#pragma multi_compile SHADOW_PASS
  113. #pragma shader_feature SPHERICAL_FADE
  114. #pragma exclude_renderers d3d9
  115. //#pragma only_renderers d3d11
  116. #pragma glsl
  117. #pragma vertex vert
  118. #pragma fragment frag
  119. #pragma target 3.0
  120. ENDCG
  121. }
  122. }
  123. }