ParticlesUnlit.shader 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. Shader "Universal Render Pipeline/Particles/Unlit"
  2. {
  3. Properties
  4. {
  5. [MainTexture] _BaseMap("Base Map", 2D) = "white" {}
  6. [MainColor] _BaseColor("Base Color", Color) = (1,1,1,1)
  7. _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
  8. _BumpMap("Normal Map", 2D) = "bump" {}
  9. [HDR] _EmissionColor("Color", Color) = (0,0,0)
  10. _EmissionMap("Emission", 2D) = "white" {}
  11. // -------------------------------------
  12. // Particle specific
  13. _SoftParticlesNearFadeDistance("Soft Particles Near Fade", Float) = 0.0
  14. _SoftParticlesFarFadeDistance("Soft Particles Far Fade", Float) = 1.0
  15. _CameraNearFadeDistance("Camera Near Fade", Float) = 1.0
  16. _CameraFarFadeDistance("Camera Far Fade", Float) = 2.0
  17. _DistortionBlend("Distortion Blend", Range(0.0, 1.0)) = 0.5
  18. _DistortionStrength("Distortion Strength", Float) = 1.0
  19. // -------------------------------------
  20. // Hidden properties - Generic
  21. _Surface("__surface", Float) = 0.0
  22. _Blend("__mode", Float) = 0.0
  23. _Cull("__cull", Float) = 2.0
  24. [ToggleUI] _AlphaClip("__clip", Float) = 0.0
  25. [HideInInspector] _BlendOp("__blendop", Float) = 0.0
  26. [HideInInspector] _SrcBlend("__src", Float) = 1.0
  27. [HideInInspector] _DstBlend("__dst", Float) = 0.0
  28. [HideInInspector] _ZWrite("__zw", Float) = 1.0
  29. // Particle specific
  30. _ColorMode("_ColorMode", Float) = 0.0
  31. [HideInInspector] _BaseColorAddSubDiff("_ColorMode", Vector) = (0,0,0,0)
  32. [ToggleOff] _FlipbookBlending("__flipbookblending", Float) = 0.0
  33. [ToggleUI] _SoftParticlesEnabled("__softparticlesenabled", Float) = 0.0
  34. [ToggleUI] _CameraFadingEnabled("__camerafadingenabled", Float) = 0.0
  35. [ToggleUI] _DistortionEnabled("__distortionenabled", Float) = 0.0
  36. [HideInInspector] _SoftParticleFadeParams("__softparticlefadeparams", Vector) = (0,0,0,0)
  37. [HideInInspector] _CameraFadeParams("__camerafadeparams", Vector) = (0,0,0,0)
  38. [HideInInspector] _DistortionStrengthScaled("Distortion Strength Scaled", Float) = 0.1
  39. // Editmode props
  40. _QueueOffset("Queue offset", Float) = 0.0
  41. // ObsoleteProperties
  42. [HideInInspector] _FlipbookMode("flipbook", Float) = 0
  43. [HideInInspector] _Mode("mode", Float) = 0
  44. [HideInInspector] _Color("color", Color) = (1,1,1,1)
  45. }
  46. HLSLINCLUDE
  47. //Particle shaders rely on "write" to CB syntax which is not supported by DXC
  48. #pragma never_use_dxc
  49. ENDHLSL
  50. SubShader
  51. {
  52. Tags{"RenderType" = "Opaque" "IgnoreProjector" = "True" "PreviewType" = "Plane" "PerformanceChecks" = "False" "RenderPipeline" = "UniversalPipeline"}
  53. // ------------------------------------------------------------------
  54. // Forward pass.
  55. Pass
  56. {
  57. Name "ForwardLit"
  58. BlendOp[_BlendOp]
  59. Blend[_SrcBlend][_DstBlend]
  60. ZWrite[_ZWrite]
  61. Cull[_Cull]
  62. HLSLPROGRAM
  63. #pragma target 2.0
  64. // -------------------------------------
  65. // Material Keywords
  66. #pragma shader_feature_local _NORMALMAP
  67. #pragma shader_feature_local_fragment _EMISSION
  68. // -------------------------------------
  69. // Particle Keywords
  70. #pragma shader_feature_local _FLIPBOOKBLENDING_ON
  71. #pragma shader_feature_local _SOFTPARTICLES_ON
  72. #pragma shader_feature_local _FADING_ON
  73. #pragma shader_feature_local _DISTORTION_ON
  74. #pragma shader_feature_local_fragment _ALPHATEST_ON
  75. #pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
  76. #pragma shader_feature_local_fragment _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON
  77. #pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
  78. // -------------------------------------
  79. // Unity defined keywords
  80. #pragma multi_compile_fog
  81. #pragma multi_compile_instancing
  82. #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
  83. #pragma multi_compile_fragment _ DEBUG_DISPLAY
  84. #pragma instancing_options procedural:ParticleInstancingSetup
  85. #pragma vertex vertParticleUnlit
  86. #pragma fragment fragParticleUnlit
  87. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl"
  88. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitForwardPass.hlsl"
  89. ENDHLSL
  90. }
  91. // ------------------------------------------------------------------
  92. // Depth Only pass.
  93. Pass
  94. {
  95. Name "DepthOnly"
  96. Tags{"LightMode" = "DepthOnly"}
  97. ZWrite On
  98. ColorMask 0
  99. Cull[_Cull]
  100. HLSLPROGRAM
  101. #pragma target 2.0
  102. // -------------------------------------
  103. // Material Keywords
  104. #pragma shader_feature_local _ _ALPHATEST_ON
  105. #pragma shader_feature_local _ _FLIPBOOKBLENDING_ON
  106. #pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
  107. // -------------------------------------
  108. // Unity defined keywords
  109. #pragma multi_compile_instancing
  110. #pragma instancing_options procedural:ParticleInstancingSetup
  111. #pragma vertex DepthOnlyVertex
  112. #pragma fragment DepthOnlyFragment
  113. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl"
  114. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl"
  115. ENDHLSL
  116. }
  117. // This pass is used when drawing to a _CameraNormalsTexture texture with the forward renderer or the depthNormal prepass with the deferred renderer.
  118. Pass
  119. {
  120. Name "DepthNormalsOnly"
  121. Tags{"LightMode" = "DepthNormalsOnly"}
  122. ZWrite On
  123. Cull[_Cull]
  124. HLSLPROGRAM
  125. #pragma exclude_renderers gles gles3 glcore
  126. #pragma target 4.5
  127. #pragma vertex DepthNormalsVertex
  128. #pragma fragment DepthNormalsFragment
  129. // -------------------------------------
  130. // Material Keywords
  131. #pragma shader_feature_local _ _NORMALMAP
  132. #pragma shader_feature_local _ _ALPHATEST_ON
  133. #pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
  134. // -------------------------------------
  135. // Unity defined keywords
  136. #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT // forward-only variant
  137. //--------------------------------------
  138. // GPU Instancing
  139. #pragma multi_compile_instancing
  140. #pragma multi_compile _ DOTS_INSTANCING_ON
  141. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl"
  142. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl"
  143. ENDHLSL
  144. }
  145. // ------------------------------------------------------------------
  146. // Scene view outline pass.
  147. Pass
  148. {
  149. Name "SceneSelectionPass"
  150. Tags { "LightMode" = "SceneSelectionPass" }
  151. BlendOp Add
  152. Blend One Zero
  153. ZWrite On
  154. Cull Off
  155. HLSLPROGRAM
  156. #define PARTICLES_EDITOR_META_PASS
  157. #pragma target 2.0
  158. // -------------------------------------
  159. // Particle Keywords
  160. #pragma shader_feature_local_fragment _ALPHATEST_ON
  161. #pragma shader_feature_local _FLIPBOOKBLENDING_ON
  162. // -------------------------------------
  163. // Unity defined keywords
  164. #pragma multi_compile_instancing
  165. #pragma instancing_options procedural:ParticleInstancingSetup
  166. #pragma vertex vertParticleEditor
  167. #pragma fragment fragParticleSceneHighlight
  168. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl"
  169. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesEditorPass.hlsl"
  170. ENDHLSL
  171. }
  172. // ------------------------------------------------------------------
  173. // Scene picking buffer pass.
  174. Pass
  175. {
  176. Name "ScenePickingPass"
  177. Tags{ "LightMode" = "Picking" }
  178. BlendOp Add
  179. Blend One Zero
  180. ZWrite On
  181. Cull Off
  182. HLSLPROGRAM
  183. #define PARTICLES_EDITOR_META_PASS
  184. #pragma target 2.0
  185. // -------------------------------------
  186. // Particle Keywords
  187. #pragma shader_feature_local_fragment _ALPHATEST_ON
  188. #pragma shader_feature_local _FLIPBOOKBLENDING_ON
  189. // -------------------------------------
  190. // Unity defined keywords
  191. #pragma multi_compile_instancing
  192. #pragma instancing_options procedural:ParticleInstancingSetup
  193. #pragma vertex vertParticleEditor
  194. #pragma fragment fragParticleScenePicking
  195. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl"
  196. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesEditorPass.hlsl"
  197. ENDHLSL
  198. }
  199. Pass
  200. {
  201. Name "MotionVectors"
  202. Tags{ "LightMode" = "MotionVectors"}
  203. Tags { "RenderType" = "Opaque" }
  204. ZWrite[_ZWrite]
  205. Cull[_Cull]
  206. HLSLPROGRAM
  207. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/OculusMotionVectorCore.hlsl"
  208. #pragma vertex vertParticles
  209. #pragma fragment frag
  210. ENDHLSL
  211. }
  212. }
  213. CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.ParticlesUnlitShader"
  214. }