Lux URP Particles Simple Lit.shader 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. Shader "Lux URP/Particles/Simple Lit"
  2. {
  3. // ------------------------------------------
  4. // All lights are supported for lit particles
  5. // Per pixel or per vertex shadows
  6. Properties
  7. {
  8. [HeaderHelpLuxURP_URL(hgrc26wf1x5s)]
  9. [Header(Surface Options)]
  10. [Space(8)]
  11. [Enum(UnityEngine.Rendering.CompareFunction)]
  12. _ZTest ("ZTest", Float) = 4 // "LessEqual"
  13. [Enum(UnityEngine.Rendering.CullMode)]
  14. _Cull ("Cull", Float) = 2.0
  15. [HideInInspector]
  16. [Enum(Off,0,On,1)]_ZWrite ("ZWrite", Float) = 0.0
  17. [Space(5)]
  18. [Enum(Alpha,0,Premultiply,1,Additive,2,Multiply,3)]
  19. _Blend ("Blending Mode", Float) = 0
  20. [Enum(Multiply,0,Additive,1,Subtractive,2,Overlay,3,Color,4,Difference,5)]
  21. _ColorMode ("Color Mode", Float) = 0.0
  22. [Space(5)]
  23. [ToggleOff(_RECEIVE_SHADOWS_OFF)]
  24. _ReceiveShadows ("Receive Shadows", Float) = 0.0
  25. [Toggle(_ADDITIONALLIGHT_SHADOWS)]
  26. _AdditionalLightShadows ("Additional Light Shadows", Float) = 1.0
  27. [Toggle(_PERVERTEX_SHADOWS)]
  28. _PerVertexShadows (" Per Vertex Shadows", Float) = 0.0
  29. _SampleOffset (" Sample Offset", Range(0, 2)) = 0.1
  30. [Header(Surface Inputs)]
  31. [Space(8)]
  32. _BaseColor ("Base Color", Color) = (1,1,1,1)
  33. _BaseMap ("Base Map", 2D) = "white" {}
  34. [Space(5)]
  35. [ToggleOff] _SpecularHighlights ("Specular Highlights", Float) = 1.0
  36. [Toggle]
  37. _EnableSpecGloss (" Enable Spec Gloss Map", Float) = 0.0
  38. [NoScaleOffset] _SpecGlossMap (" Spec Gloss Map", 2D) = "white" {}
  39. _SpecColor (" Specular (RGB) Smoothness(A)", Color) = (1.0, 1.0, 1.0, .5)
  40. //_Smoothness (" Smoothness", Range(0.0, 1.0)) = 0.5
  41. [Space(5)]
  42. [Toggle(_NORMALMAP)]
  43. _ApplyNormal ("Enable Normal Map", Float) = 0.0
  44. [NoScaleOffset] _BumpMap (" Normal Map", 2D) = "bump" {}
  45. //_BumpScale (" Scale", Float) = 1.0
  46. [Space(5)]
  47. [Toggle(_EMISSION)]
  48. _EnableEmission ("Enable Emission", Float) = 0.0
  49. [NoScaleOffset] _EmissionMap (" Emission Map", 2D) = "white" {}
  50. [HDR]_EmissionColor (" Color", Color) = (1,1,1)
  51. [Space(5)]
  52. [Toggle(_TRANSMISSION)]
  53. _EnableTransmission ("Enable Transmission", Float) = 0.0
  54. _Transmission (" Transmission", Range(0.0, 1.0)) = 0.5
  55. _TransmissionDistortion (" Distortion", Range(0.01, 0.5)) = 0.01
  56. // Hidden properties - Generic
  57. [HideInInspector] _BlendOp("__blendop", Float) = 0.0
  58. // Particle specific
  59. [Header(Particle Options)]
  60. [Space(8)]
  61. [Toggle(_FLIPBOOKBLENDING_ON)]
  62. _FlipbookBlending ("Enable Flipbook Blending", Float) = 0.0
  63. [Space(5)]
  64. [Toggle(_DISTORTION_ON)]
  65. _DistortionEnabled ("Enable Distortion", Float) = 0.0
  66. _DistortionStrength (" Strength", Float) = 1.0
  67. _DistortionBlend (" Blend", Range(0.0, 1.0)) = 0.5
  68. [HideInInspector]
  69. _DistortionStrengthScaled (" Distortion Strength Scaled", Float) = 0.1
  70. [Space(5)]
  71. [Toggle(_SOFTPARTICLES_ON)]
  72. _SoftParticlesEnabled ("Enable Soft Particles", Float) = 0.0
  73. [LuxURPVectorTwoDrawer]
  74. _SoftParticleFadeParams (" Near (X) Far (Y)", Vector) = (0,1,0,0)
  75. [Space(5)]
  76. [Toggle(_FADING_ON)]
  77. _CameraFadingEnabled ("Enable Camera Fading", Float) = 0.0
  78. [LuxURPVectorTwoDrawer]
  79. _CameraFadeParamsRaw (" Near (X) Far (Y)", Vector) = (1,2,0,0)
  80. [HideInInspector]_CameraFadeParams (" Near (X) Far (Y)", Vector) = (1,1,0,0)
  81. // Hidden props
  82. [HideInInspector] _Surface("__surface", Float) = 0.0
  83. [HideInInspector] _AlphaClip("__clip", Float) = 0.0
  84. [HideInInspector] [Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend("__src", Float) = 1.0
  85. [HideInInspector] [Enum(UnityEngine.Rendering.BlendMode)] _DstBlend("__dst", Float) = 0.0
  86. [HideInInspector] _BaseColorAddSubDiff ("_ColorMode", Vector) = (0,0,0,0)
  87. // Editmode props
  88. [HideInInspector] _QueueOffset("Queue offset", Float) = 0.0
  89. // ObsoleteProperties
  90. [HideInInspector] _FlipbookMode("flipbook", Float) = 0
  91. [HideInInspector] _Glossiness("gloss", Float) = 0
  92. [HideInInspector] _Mode("mode", Float) = 0
  93. [HideInInspector] _Color("color", Color) = (1,1,1,1)
  94. // Lightmapper and outline selection shader need _MainTex, _Color and _Cutoff
  95. [HideInInspector] _MainTex ("Albedo", 2D) = "white" {}
  96. [HideInInspector] _Color ("Color", Color) = (1,1,1,1)
  97. [HideInInspector] _Cutoff ("Alpha Cutoff", Range(0.0, 1.0)) = 0.0
  98. }
  99. SubShader
  100. {
  101. Tags {
  102. "RenderType" = "Transparent"
  103. "Queue" = "Transparent"
  104. "IgnoreProjector" = "True"
  105. "PreviewType" = "Plane"
  106. "PerformanceChecks" = "False"
  107. "RenderPipeline" = "UniversalPipeline"
  108. }
  109. // ------------------------------------------------------------------
  110. // Forward pass.
  111. Pass
  112. {
  113. // Lightmode matches the ShaderPassName set in LightweightRenderPipeline.cs. SRPDefaultUnlit and passes with
  114. // no LightMode tag are also rendered by Lightweight Render Pipeline
  115. Name "ForwardLit"
  116. Tags {"LightMode" = "UniversalForward"}
  117. BlendOp[_BlendOp]
  118. Blend[_SrcBlend][_DstBlend]
  119. ZWrite[_ZWrite]
  120. Cull[_Cull]
  121. HLSLPROGRAM
  122. // Required to compile gles 2.0 with standard SRP library
  123. // All shaders must be compiled with HLSLcc and currently only gles is not using HLSLcc by default
  124. #pragma prefer_hlslcc gles
  125. #pragma exclude_renderers d3d11_9x
  126. #pragma target 2.0
  127. // -------------------------------------
  128. // Material Keywords
  129. #pragma shader_feature_local _NORMALMAP
  130. #pragma shader_feature_local_fragment _EMISSION
  131. //#pragma shader_feature _SPECULARHIGHLIGHTS_OFF
  132. #pragma shader_feature _SPECULARHIGHLIGHTS_OFF _SPECGLOSSMAP _SPECULAR_COLOR
  133. // _RECEIVE_SHADOWS_OFF drives AdditionalLightRealtimeShadow() in shadows.hlsl. Without it being set no sampling will happen
  134. // shadows.hlsl differs in LWRP and URP
  135. #pragma shader_feature _RECEIVE_SHADOWS_OFF
  136. #pragma shader_feature_local _PERVERTEX_SHADOWS
  137. #pragma shader_feature_local _PERVERTEX_SAMPLEOFFSET
  138. #pragma shader_feature_local _ADDITIONALLIGHT_SHADOWS
  139. #pragma shader_feature_local_fragment _TRANSMISSION
  140. // -------------------------------------
  141. // Particle Keywords
  142. #pragma shader_feature _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON _ADDITIVE
  143. //#pragma shader_feature _ALPHATEST_ON
  144. #pragma shader_feature _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
  145. #pragma shader_feature _FLIPBOOKBLENDING_ON
  146. #pragma shader_feature _SOFTPARTICLES_ON
  147. #pragma shader_feature _FADING_ON
  148. #pragma shader_feature _DISTORTION_ON
  149. // -------------------------------------
  150. // Universal Pipeline keywords
  151. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS
  152. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
  153. #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
  154. #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
  155. #pragma multi_compile_fragment _ _SHADOWS_SOFT
  156. #if defined(_SHADOWS_SOFT) && defined(_PERVERTEX_SHADOWS)
  157. #undef _SHADOWS_SOFT
  158. #endif
  159. //--------------------------------------
  160. // GPU Instancing
  161. #pragma multi_compile_instancing
  162. // #pragma multi_compile _ DOTS_INSTANCING_ON // needs shader target 4.5
  163. // -------------------------------------
  164. // Unity defined keywords
  165. #pragma multi_compile_fog
  166. #pragma vertex ParticlesLitVertex
  167. #pragma fragment ParticlesLitFragment
  168. #define BUMP_SCALE_NOT_SUPPORTED 1
  169. #include "Includes/Lux URP Particles Simple Lit Inputs.hlsl"
  170. #include "Includes/Lux URP Particles Simple Lit Forward Pass.hlsl"
  171. ENDHLSL
  172. }
  173. }
  174. Fallback "Lightweight Render Pipeline/Particles/Unlit"
  175. CustomEditor "LuxURPParticlesCustomShaderGUI"
  176. }