ParticlesLit.shader 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. // ------------------------------------------
  2. // No shadows
  3. Shader "Universal Render Pipeline/Particles/Lit"
  4. {
  5. Properties
  6. {
  7. [MainTexture] _BaseMap("Base Map", 2D) = "white" {}
  8. [MainColor] _BaseColor("Base Color", Color) = (1,1,1,1)
  9. _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
  10. _MetallicGlossMap("Metallic Map", 2D) = "white" {}
  11. [Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
  12. _Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5
  13. _BumpScale("Scale", Float) = 1.0
  14. _BumpMap("Normal Map", 2D) = "bump" {}
  15. [HDR] _EmissionColor("Color", Color) = (0,0,0)
  16. _EmissionMap("Emission", 2D) = "white" {}
  17. [ToggleUI] _ReceiveShadows("Receive Shadows", Float) = 1.0
  18. // -------------------------------------
  19. // Particle specific
  20. _SoftParticlesNearFadeDistance("Soft Particles Near Fade", Float) = 0.0
  21. _SoftParticlesFarFadeDistance("Soft Particles Far Fade", Float) = 1.0
  22. _CameraNearFadeDistance("Camera Near Fade", Float) = 1.0
  23. _CameraFarFadeDistance("Camera Far Fade", Float) = 2.0
  24. _DistortionBlend("Distortion Blend", Range(0.0, 1.0)) = 0.5
  25. _DistortionStrength("Distortion Strength", Float) = 1.0
  26. // -------------------------------------
  27. // Hidden properties - Generic
  28. _Surface("__surface", Float) = 0.0
  29. _Blend("__mode", Float) = 0.0
  30. _Cull("__cull", Float) = 2.0
  31. [ToggleUI] _AlphaClip("__clip", Float) = 0.0
  32. [HideInInspector] _BlendOp("__blendop", Float) = 0.0
  33. [HideInInspector] _SrcBlend("__src", Float) = 1.0
  34. [HideInInspector] _DstBlend("__dst", Float) = 0.0
  35. [HideInInspector] _ZWrite("__zw", Float) = 1.0
  36. // Particle specific
  37. _ColorMode("_ColorMode", Float) = 0.0
  38. [HideInInspector] _BaseColorAddSubDiff("_ColorMode", Vector) = (0,0,0,0)
  39. [ToggleOff] _FlipbookBlending("__flipbookblending", Float) = 0.0
  40. [ToggleUI] _SoftParticlesEnabled("__softparticlesenabled", Float) = 0.0
  41. [ToggleUI] _CameraFadingEnabled("__camerafadingenabled", Float) = 0.0
  42. [ToggleUI] _DistortionEnabled("__distortionenabled", Float) = 0.0
  43. [HideInInspector] _SoftParticleFadeParams("__softparticlefadeparams", Vector) = (0,0,0,0)
  44. [HideInInspector] _CameraFadeParams("__camerafadeparams", Vector) = (0,0,0,0)
  45. [HideInInspector] _DistortionStrengthScaled("Distortion Strength Scaled", Float) = 0.1
  46. // Editmode props
  47. _QueueOffset("Queue offset", Float) = 0.0
  48. // ObsoleteProperties
  49. [HideInInspector] _FlipbookMode("flipbook", Float) = 0
  50. [HideInInspector] _Glossiness("gloss", Float) = 0
  51. [HideInInspector] _Mode("mode", Float) = 0
  52. [HideInInspector] _Color("color", Color) = (1,1,1,1)
  53. }
  54. HLSLINCLUDE
  55. //Particle shaders rely on "write" to CB syntax which is not supported by DXC
  56. #pragma never_use_dxc
  57. ENDHLSL
  58. SubShader
  59. {
  60. Tags
  61. {
  62. "RenderType" = "Opaque"
  63. "IgnoreProjector" = "True"
  64. "PreviewType" = "Plane"
  65. "PerformanceChecks" = "False"
  66. "RenderPipeline" = "UniversalPipeline"
  67. "UniversalMaterialType" = "Lit"
  68. }
  69. // ------------------------------------------------------------------
  70. // Forward pass.
  71. Pass
  72. {
  73. // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
  74. // no LightMode tag are also rendered by Universal Render Pipeline
  75. Name "ForwardLit"
  76. Tags
  77. {
  78. "LightMode" = "UniversalForward"
  79. }
  80. BlendOp[_BlendOp]
  81. Blend[_SrcBlend][_DstBlend]
  82. ZWrite[_ZWrite]
  83. Cull[_Cull]
  84. HLSLPROGRAM
  85. #pragma target 2.0
  86. // -------------------------------------
  87. // Material Keywords
  88. #pragma shader_feature_local _NORMALMAP
  89. #pragma shader_feature_local _RECEIVE_SHADOWS_OFF
  90. #pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
  91. #pragma shader_feature_local_fragment _EMISSION
  92. #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
  93. // -------------------------------------
  94. // Particle Keywords
  95. #pragma shader_feature_local _FLIPBOOKBLENDING_ON
  96. #pragma shader_feature_local _SOFTPARTICLES_ON
  97. #pragma shader_feature_local _FADING_ON
  98. #pragma shader_feature_local _DISTORTION_ON
  99. #pragma shader_feature_local_fragment _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON
  100. #pragma shader_feature_local_fragment _ _ALPHATEST_ON
  101. #pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
  102. // -------------------------------------
  103. // Universal Pipeline keywords
  104. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
  105. #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
  106. #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
  107. #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
  108. #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
  109. #pragma multi_compile_fragment _ _SHADOWS_SOFT
  110. #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
  111. #pragma multi_compile_fragment _ _LIGHT_COOKIES
  112. #pragma multi_compile _ _CLUSTERED_RENDERING
  113. // -------------------------------------
  114. // Unity defined keywords
  115. #pragma multi_compile_fog
  116. #pragma multi_compile_instancing
  117. #pragma multi_compile_fragment _ DEBUG_DISPLAY
  118. #pragma instancing_options procedural:ParticleInstancingSetup
  119. #pragma vertex ParticlesLitVertex
  120. #pragma fragment ParticlesLitFragment
  121. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl"
  122. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitForwardPass.hlsl"
  123. ENDHLSL
  124. }
  125. // ------------------------------------------------------------------
  126. // GBuffer pass.
  127. Pass
  128. {
  129. // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
  130. // no LightMode tag are also rendered by Universal Render Pipeline
  131. Name "GBuffer"
  132. Tags{"LightMode" = "UniversalGBuffer"}
  133. ZWrite[_ZWrite]
  134. Cull[_Cull]
  135. HLSLPROGRAM
  136. #pragma exclude_renderers gles
  137. #pragma target 2.0
  138. // -------------------------------------
  139. // Material Keywords
  140. #pragma shader_feature_local _NORMALMAP
  141. #pragma shader_feature_local_fragment _EMISSION
  142. #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
  143. #pragma shader_feature_local _RECEIVE_SHADOWS_OFF
  144. // -------------------------------------
  145. // Particle Keywords
  146. //#pragma shader_feature _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON
  147. #pragma shader_feature_local_fragment _ALPHATEST_ON
  148. #pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
  149. #pragma shader_feature_local _FLIPBOOKBLENDING_ON
  150. //#pragma shader_feature _SOFTPARTICLES_ON
  151. //#pragma shader_feature _FADING_ON
  152. //#pragma shader_feature _DISTORTION_ON
  153. // -------------------------------------
  154. // Universal Pipeline keywords
  155. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
  156. //#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
  157. //#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
  158. #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
  159. #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
  160. #pragma multi_compile_fragment _ _SHADOWS_SOFT
  161. #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
  162. #pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
  163. // -------------------------------------
  164. // Unity defined keywords
  165. #pragma multi_compile_instancing
  166. #pragma instancing_options procedural:ParticleInstancingSetup
  167. #pragma vertex ParticlesGBufferVertex
  168. #pragma fragment ParticlesGBufferFragment
  169. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl"
  170. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitGbufferPass.hlsl"
  171. ENDHLSL
  172. }
  173. // ------------------------------------------------------------------
  174. // Depth Only pass.
  175. Pass
  176. {
  177. Name "DepthOnly"
  178. Tags{"LightMode" = "DepthOnly"}
  179. ZWrite On
  180. ColorMask 0
  181. Cull[_Cull]
  182. HLSLPROGRAM
  183. #pragma target 2.0
  184. // -------------------------------------
  185. // Material Keywords
  186. #pragma shader_feature_local _ _ALPHATEST_ON
  187. #pragma shader_feature_local _ _FLIPBOOKBLENDING_ON
  188. #pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
  189. // -------------------------------------
  190. // Unity defined keywords
  191. #pragma multi_compile_instancing
  192. #pragma instancing_options procedural:ParticleInstancingSetup
  193. #pragma vertex DepthOnlyVertex
  194. #pragma fragment DepthOnlyFragment
  195. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl"
  196. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl"
  197. ENDHLSL
  198. }
  199. // This pass is used when drawing to a _CameraNormalsTexture texture
  200. Pass
  201. {
  202. Name "DepthNormals"
  203. Tags{"LightMode" = "DepthNormals"}
  204. ZWrite On
  205. Cull[_Cull]
  206. HLSLPROGRAM
  207. #pragma target 2.0
  208. // -------------------------------------
  209. // Material Keywords
  210. #pragma shader_feature_local _ _NORMALMAP
  211. #pragma shader_feature_local _ _FLIPBOOKBLENDING_ON
  212. #pragma shader_feature_local _ _ALPHATEST_ON
  213. #pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
  214. // -------------------------------------
  215. // Unity defined keywords
  216. #pragma multi_compile_instancing
  217. #pragma instancing_options procedural:ParticleInstancingSetup
  218. #pragma vertex DepthNormalsVertex
  219. #pragma fragment DepthNormalsFragment
  220. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl"
  221. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl"
  222. ENDHLSL
  223. }
  224. // ------------------------------------------------------------------
  225. // Scene view outline pass.
  226. Pass
  227. {
  228. Name "SceneSelectionPass"
  229. Tags { "LightMode" = "SceneSelectionPass" }
  230. BlendOp Add
  231. Blend One Zero
  232. ZWrite On
  233. Cull Off
  234. HLSLPROGRAM
  235. #define PARTICLES_EDITOR_META_PASS
  236. #pragma target 2.0
  237. // -------------------------------------
  238. // Particle Keywords
  239. #pragma shader_feature_local_fragment _ALPHATEST_ON
  240. #pragma shader_feature_local _FLIPBOOKBLENDING_ON
  241. // -------------------------------------
  242. // Unity defined keywords
  243. #pragma multi_compile_instancing
  244. #pragma instancing_options procedural:ParticleInstancingSetup
  245. #pragma vertex vertParticleEditor
  246. #pragma fragment fragParticleSceneHighlight
  247. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl"
  248. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesEditorPass.hlsl"
  249. ENDHLSL
  250. }
  251. // ------------------------------------------------------------------
  252. // Scene picking buffer pass.
  253. Pass
  254. {
  255. Name "ScenePickingPass"
  256. Tags{ "LightMode" = "Picking" }
  257. BlendOp Add
  258. Blend One Zero
  259. ZWrite On
  260. Cull Off
  261. HLSLPROGRAM
  262. #define PARTICLES_EDITOR_META_PASS
  263. #pragma target 2.0
  264. // -------------------------------------
  265. // Particle Keywords
  266. #pragma shader_feature_local_fragment _ALPHATEST_ON
  267. #pragma shader_feature_local _FLIPBOOKBLENDING_ON
  268. // -------------------------------------
  269. // Unity defined keywords
  270. #pragma multi_compile_instancing
  271. #pragma instancing_options procedural:ParticleInstancingSetup
  272. #pragma vertex vertParticleEditor
  273. #pragma fragment fragParticleScenePicking
  274. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl"
  275. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesEditorPass.hlsl"
  276. ENDHLSL
  277. }
  278. Pass
  279. {
  280. Name "Universal2D"
  281. Tags{ "LightMode" = "Universal2D" }
  282. Blend[_SrcBlend][_DstBlend]
  283. ZWrite[_ZWrite]
  284. Cull[_Cull]
  285. HLSLPROGRAM
  286. #pragma vertex vert
  287. #pragma fragment frag
  288. #pragma shader_feature_local_fragment _ALPHATEST_ON
  289. #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
  290. #include "Packages/com.unity.render-pipelines.universal/Shaders/UnlitInput.hlsl"
  291. #include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
  292. ENDHLSL
  293. }
  294. Pass
  295. {
  296. Name "MotionVectors"
  297. Tags{ "LightMode" = "MotionVectors"}
  298. Tags { "RenderType" = "Opaque" }
  299. ZWrite[_ZWrite]
  300. Cull[_Cull]
  301. HLSLPROGRAM
  302. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/OculusMotionVectorCore.hlsl"
  303. #pragma vertex vertParticles
  304. #pragma fragment frag
  305. ENDHLSL
  306. }
  307. }
  308. Fallback "Universal Render Pipeline/Particles/Simple Lit"
  309. CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.ParticlesLitShader"
  310. }