ParticlesSimpleLit.shader 15 KB

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