Lit.shader 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. Shader "Universal Render Pipeline/Lit"
  2. {
  3. Properties
  4. {
  5. // Specular vs Metallic workflow
  6. [HideInInspector] _WorkflowMode("WorkflowMode", Float) = 1.0
  7. [MainColor] _BaseColor("Color", Color) = (1,1,1,1)
  8. [MainTexture] _BaseMap("Albedo", 2D) = "white" {}
  9. _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
  10. _Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5
  11. _GlossMapScale("Smoothness Scale", Range(0.0, 1.0)) = 1.0
  12. _SmoothnessTextureChannel("Smoothness texture channel", Float) = 0
  13. [Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
  14. _MetallicGlossMap("Metallic", 2D) = "white" {}
  15. _SpecColor("Specular", Color) = (0.2, 0.2, 0.2)
  16. _SpecGlossMap("Specular", 2D) = "white" {}
  17. [ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
  18. [ToggleOff] _EnvironmentReflections("Environment Reflections", Float) = 1.0
  19. _BumpScale("Scale", Float) = 1.0
  20. _BumpMap("Normal Map", 2D) = "bump" {}
  21. _OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
  22. _OcclusionMap("Occlusion", 2D) = "white" {}
  23. _EmissionColor("Color", Color) = (0,0,0)
  24. _EmissionMap("Emission", 2D) = "white" {}
  25. // Blending state
  26. [HideInInspector] _Surface("__surface", Float) = 0.0
  27. [HideInInspector] _Blend("__blend", Float) = 0.0
  28. [HideInInspector] _AlphaClip("__clip", Float) = 0.0
  29. [HideInInspector] _SrcBlend("__src", Float) = 1.0
  30. [HideInInspector] _DstBlend("__dst", Float) = 0.0
  31. [HideInInspector] _ZWrite("__zw", Float) = 1.0
  32. [HideInInspector] _Cull("__cull", Float) = 2.0
  33. _ReceiveShadows("Receive Shadows", Float) = 1.0
  34. // Editmode props
  35. [HideInInspector] _QueueOffset("Queue offset", Float) = 0.0
  36. // ObsoleteProperties
  37. [HideInInspector] _MainTex("BaseMap", 2D) = "white" {}
  38. [HideInInspector] _Color("Base Color", Color) = (1, 1, 1, 1)
  39. [HideInInspector] _GlossMapScale("Smoothness", Float) = 0.0
  40. [HideInInspector] _Glossiness("Smoothness", Float) = 0.0
  41. [HideInInspector] _GlossyReflections("EnvironmentReflections", Float) = 0.0
  42. }
  43. SubShader
  44. {
  45. // Universal Pipeline tag is required. If Universal render pipeline is not set in the graphics settings
  46. // this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this
  47. // material work with both Universal Render Pipeline and Builtin Unity Pipeline
  48. Tags{"RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "IgnoreProjector" = "True"}
  49. LOD 300
  50. // ------------------------------------------------------------------
  51. // Forward pass. Shades all light in a single pass. GI + emission + Fog
  52. Pass
  53. {
  54. // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
  55. // no LightMode tag are also rendered by Universal Render Pipeline
  56. Name "ForwardLit"
  57. Tags{"LightMode" = "UniversalForward"}
  58. Blend[_SrcBlend][_DstBlend]
  59. ZWrite[_ZWrite]
  60. Cull[_Cull]
  61. HLSLPROGRAM
  62. // Required to compile gles 2.0 with standard SRP library
  63. // All shaders must be compiled with HLSLcc and currently only gles is not using HLSLcc by default
  64. #pragma prefer_hlslcc gles
  65. #pragma exclude_renderers d3d11_9x
  66. #pragma target 2.0
  67. // -------------------------------------
  68. // Material Keywords
  69. #pragma shader_feature _NORMALMAP
  70. #pragma shader_feature _ALPHATEST_ON
  71. #pragma shader_feature _ALPHAPREMULTIPLY_ON
  72. #pragma shader_feature _EMISSION
  73. #pragma shader_feature _METALLICSPECGLOSSMAP
  74. #pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
  75. #pragma shader_feature _OCCLUSIONMAP
  76. #pragma shader_feature _SPECULARHIGHLIGHTS_OFF
  77. #pragma shader_feature _ENVIRONMENTREFLECTIONS_OFF
  78. #pragma shader_feature _SPECULAR_SETUP
  79. #pragma shader_feature _RECEIVE_SHADOWS_OFF
  80. // -------------------------------------
  81. // Universal Pipeline keywords
  82. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS
  83. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
  84. #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
  85. #pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
  86. #pragma multi_compile _ _SHADOWS_SOFT
  87. #pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
  88. // -------------------------------------
  89. // Unity defined keywords
  90. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  91. #pragma multi_compile _ LIGHTMAP_ON
  92. #pragma multi_compile_fog
  93. //--------------------------------------
  94. // GPU Instancing
  95. #pragma multi_compile_instancing
  96. #pragma vertex LitPassVertex
  97. #pragma fragment LitPassFragment
  98. #include "LitInput.hlsl"
  99. #include "LitForwardPass.hlsl"
  100. ENDHLSL
  101. }
  102. Pass
  103. {
  104. Name "ShadowCaster"
  105. Tags{"LightMode" = "ShadowCaster"}
  106. ZWrite On
  107. ZTest LEqual
  108. Cull[_Cull]
  109. HLSLPROGRAM
  110. // Required to compile gles 2.0 with standard srp library
  111. #pragma prefer_hlslcc gles
  112. #pragma exclude_renderers d3d11_9x
  113. #pragma target 2.0
  114. // -------------------------------------
  115. // Material Keywords
  116. #pragma shader_feature _ALPHATEST_ON
  117. //--------------------------------------
  118. // GPU Instancing
  119. #pragma multi_compile_instancing
  120. #pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
  121. #pragma vertex ShadowPassVertex
  122. #pragma fragment ShadowPassFragment
  123. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
  124. #include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
  125. ENDHLSL
  126. }
  127. Pass
  128. {
  129. Name "DepthOnly"
  130. Tags{"LightMode" = "DepthOnly"}
  131. ZWrite On
  132. ColorMask 0
  133. Cull[_Cull]
  134. HLSLPROGRAM
  135. // Required to compile gles 2.0 with standard srp library
  136. #pragma prefer_hlslcc gles
  137. #pragma exclude_renderers d3d11_9x
  138. #pragma target 2.0
  139. #pragma vertex DepthOnlyVertex
  140. #pragma fragment DepthOnlyFragment
  141. // -------------------------------------
  142. // Material Keywords
  143. #pragma shader_feature _ALPHATEST_ON
  144. #pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
  145. //--------------------------------------
  146. // GPU Instancing
  147. #pragma multi_compile_instancing
  148. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
  149. #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
  150. ENDHLSL
  151. }
  152. // This pass it not used during regular rendering, only for lightmap baking.
  153. Pass
  154. {
  155. Name "Meta"
  156. Tags{"LightMode" = "Meta"}
  157. Cull Off
  158. HLSLPROGRAM
  159. // Required to compile gles 2.0 with standard srp library
  160. #pragma prefer_hlslcc gles
  161. #pragma exclude_renderers d3d11_9x
  162. #pragma vertex UniversalVertexMeta
  163. #pragma fragment UniversalFragmentMeta
  164. #pragma shader_feature _SPECULAR_SETUP
  165. #pragma shader_feature _EMISSION
  166. #pragma shader_feature _METALLICSPECGLOSSMAP
  167. #pragma shader_feature _ALPHATEST_ON
  168. #pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
  169. #pragma shader_feature _SPECGLOSSMAP
  170. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
  171. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitMetaPass.hlsl"
  172. ENDHLSL
  173. }
  174. Pass
  175. {
  176. Name "Universal2D"
  177. Tags{ "LightMode" = "Universal2D" }
  178. Blend[_SrcBlend][_DstBlend]
  179. ZWrite[_ZWrite]
  180. Cull[_Cull]
  181. HLSLPROGRAM
  182. // Required to compile gles 2.0 with standard srp library
  183. #pragma prefer_hlslcc gles
  184. #pragma exclude_renderers d3d11_9x
  185. #pragma vertex vert
  186. #pragma fragment frag
  187. #pragma shader_feature _ALPHATEST_ON
  188. #pragma shader_feature _ALPHAPREMULTIPLY_ON
  189. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
  190. #include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
  191. ENDHLSL
  192. }
  193. }
  194. FallBack "Hidden/Universal Render Pipeline/FallbackError"
  195. CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.LitShader"
  196. }