Lit.shader 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. Shader "Universal Render Pipeline/Lit"
  2. {
  3. Properties
  4. {
  5. // Specular vs Metallic workflow
  6. _WorkflowMode("WorkflowMode", Float) = 1.0
  7. [MainTexture] _BaseMap("Albedo", 2D) = "white" {}
  8. [MainColor] _BaseColor("Color", Color) = (1,1,1,1)
  9. _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
  10. _Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5
  11. _SmoothnessTextureChannel("Smoothness texture channel", Float) = 0
  12. _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
  13. _MetallicGlossMap("Metallic", 2D) = "white" {}
  14. _SpecColor("Specular", Color) = (0.2, 0.2, 0.2)
  15. _SpecGlossMap("Specular", 2D) = "white" {}
  16. [ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
  17. [ToggleOff] _EnvironmentReflections("Environment Reflections", Float) = 1.0
  18. _BumpScale("Scale", Float) = 1.0
  19. _BumpMap("Normal Map", 2D) = "bump" {}
  20. _Parallax("Scale", Range(0.005, 0.08)) = 0.005
  21. _ParallaxMap("Height Map", 2D) = "black" {}
  22. _OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
  23. _OcclusionMap("Occlusion", 2D) = "white" {}
  24. [HDR] _EmissionColor("Color", Color) = (0,0,0)
  25. _EmissionMap("Emission", 2D) = "white" {}
  26. _DetailMask("Detail Mask", 2D) = "white" {}
  27. _DetailAlbedoMapScale("Scale", Range(0.0, 2.0)) = 1.0
  28. _DetailAlbedoMap("Detail Albedo x2", 2D) = "linearGrey" {}
  29. _DetailNormalMapScale("Scale", Range(0.0, 2.0)) = 1.0
  30. [Normal] _DetailNormalMap("Normal Map", 2D) = "bump" {}
  31. // SRP batching compatibility for Clear Coat (Not used in Lit)
  32. [HideInInspector] _ClearCoatMask("_ClearCoatMask", Float) = 0.0
  33. [HideInInspector] _ClearCoatSmoothness("_ClearCoatSmoothness", Float) = 0.0
  34. // Blending state
  35. _Surface("__surface", Float) = 0.0
  36. _Blend("__blend", Float) = 0.0
  37. _Cull("__cull", Float) = 2.0
  38. [ToggleUI] _AlphaClip("__clip", Float) = 0.0
  39. [HideInInspector] _SrcBlend("__src", Float) = 1.0
  40. [HideInInspector] _DstBlend("__dst", Float) = 0.0
  41. [HideInInspector] _ZWrite("__zw", Float) = 1.0
  42. [ToggleUI] _ReceiveShadows("Receive Shadows", Float) = 1.0
  43. // Editmode props
  44. _QueueOffset("Queue offset", Float) = 0.0
  45. // ObsoleteProperties
  46. [HideInInspector] _MainTex("BaseMap", 2D) = "white" {}
  47. [HideInInspector] _Color("Base Color", Color) = (1, 1, 1, 1)
  48. [HideInInspector] _GlossMapScale("Smoothness", Float) = 0.0
  49. [HideInInspector] _Glossiness("Smoothness", Float) = 0.0
  50. [HideInInspector] _GlossyReflections("EnvironmentReflections", Float) = 0.0
  51. [HideInInspector][NoScaleOffset]unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {}
  52. [HideInInspector][NoScaleOffset]unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {}
  53. [HideInInspector][NoScaleOffset]unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {}
  54. }
  55. SubShader
  56. {
  57. // Universal Pipeline tag is required. If Universal render pipeline is not set in the graphics settings
  58. // this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this
  59. // material work with both Universal Render Pipeline and Builtin Unity Pipeline
  60. Tags{"RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "Lit" "IgnoreProjector" = "True" "ShaderModel"="4.5"}
  61. LOD 300
  62. // ------------------------------------------------------------------
  63. // Forward pass. Shades all light in a single pass. GI + emission + Fog
  64. Pass
  65. {
  66. // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
  67. // no LightMode tag are also rendered by Universal Render Pipeline
  68. Name "ForwardLit"
  69. Tags{"LightMode" = "UniversalForward"}
  70. Blend[_SrcBlend][_DstBlend]
  71. ZWrite[_ZWrite]
  72. Cull[_Cull]
  73. HLSLPROGRAM
  74. #pragma exclude_renderers gles gles3 glcore
  75. #pragma target 4.5
  76. // -------------------------------------
  77. // Material Keywords
  78. #pragma shader_feature_local _NORMALMAP
  79. #pragma shader_feature_local _PARALLAXMAP
  80. #pragma shader_feature_local _RECEIVE_SHADOWS_OFF
  81. #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
  82. #pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
  83. #pragma shader_feature_local_fragment _ALPHATEST_ON
  84. #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
  85. #pragma shader_feature_local_fragment _EMISSION
  86. #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
  87. #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
  88. #pragma shader_feature_local_fragment _OCCLUSIONMAP
  89. #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
  90. #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
  91. #pragma shader_feature_local_fragment _SPECULAR_SETUP
  92. // -------------------------------------
  93. // Universal Pipeline keywords
  94. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
  95. #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
  96. #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
  97. #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
  98. #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
  99. #pragma multi_compile_fragment _ _SHADOWS_SOFT
  100. #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
  101. #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
  102. #pragma multi_compile_fragment _ _LIGHT_LAYERS
  103. #pragma multi_compile_fragment _ _LIGHT_COOKIES
  104. #pragma multi_compile _ _CLUSTERED_RENDERING
  105. // -------------------------------------
  106. // Unity defined keywords
  107. #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
  108. #pragma multi_compile _ SHADOWS_SHADOWMASK
  109. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  110. #pragma multi_compile _ LIGHTMAP_ON
  111. #pragma multi_compile _ DYNAMICLIGHTMAP_ON
  112. #pragma multi_compile_fog
  113. #pragma multi_compile_fragment _ DEBUG_DISPLAY
  114. //--------------------------------------
  115. // GPU Instancing
  116. #pragma multi_compile_instancing
  117. #pragma instancing_options renderinglayer
  118. #pragma multi_compile _ DOTS_INSTANCING_ON
  119. #pragma vertex LitPassVertex
  120. #pragma fragment LitPassFragment
  121. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
  122. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl"
  123. ENDHLSL
  124. }
  125. Pass
  126. {
  127. Name "ShadowCaster"
  128. Tags{"LightMode" = "ShadowCaster"}
  129. ZWrite On
  130. ZTest LEqual
  131. ColorMask 0
  132. Cull[_Cull]
  133. HLSLPROGRAM
  134. #pragma exclude_renderers gles gles3 glcore
  135. #pragma target 4.5
  136. // -------------------------------------
  137. // Material Keywords
  138. #pragma shader_feature_local_fragment _ALPHATEST_ON
  139. #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
  140. //--------------------------------------
  141. // GPU Instancing
  142. #pragma multi_compile_instancing
  143. #pragma multi_compile _ DOTS_INSTANCING_ON
  144. // -------------------------------------
  145. // Universal Pipeline keywords
  146. // This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias
  147. #pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
  148. #pragma vertex ShadowPassVertex
  149. #pragma fragment ShadowPassFragment
  150. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
  151. #include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
  152. ENDHLSL
  153. }
  154. Pass
  155. {
  156. // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
  157. // no LightMode tag are also rendered by Universal Render Pipeline
  158. Name "GBuffer"
  159. Tags{"LightMode" = "UniversalGBuffer"}
  160. ZWrite[_ZWrite]
  161. ZTest LEqual
  162. Cull[_Cull]
  163. HLSLPROGRAM
  164. #pragma exclude_renderers gles gles3 glcore
  165. #pragma target 4.5
  166. // -------------------------------------
  167. // Material Keywords
  168. #pragma shader_feature_local _NORMALMAP
  169. #pragma shader_feature_local_fragment _ALPHATEST_ON
  170. //#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
  171. #pragma shader_feature_local_fragment _EMISSION
  172. #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
  173. #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
  174. #pragma shader_feature_local_fragment _OCCLUSIONMAP
  175. #pragma shader_feature_local _PARALLAXMAP
  176. #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
  177. #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
  178. #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
  179. #pragma shader_feature_local_fragment _SPECULAR_SETUP
  180. #pragma shader_feature_local _RECEIVE_SHADOWS_OFF
  181. // -------------------------------------
  182. // Universal Pipeline keywords
  183. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
  184. //#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
  185. //#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
  186. #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
  187. #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
  188. #pragma multi_compile_fragment _ _SHADOWS_SOFT
  189. #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
  190. #pragma multi_compile_fragment _ _LIGHT_LAYERS
  191. #pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
  192. // -------------------------------------
  193. // Unity defined keywords
  194. #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
  195. #pragma multi_compile _ SHADOWS_SHADOWMASK
  196. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  197. #pragma multi_compile _ LIGHTMAP_ON
  198. #pragma multi_compile _ DYNAMICLIGHTMAP_ON
  199. #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
  200. //--------------------------------------
  201. // GPU Instancing
  202. #pragma multi_compile_instancing
  203. #pragma instancing_options renderinglayer
  204. #pragma multi_compile _ DOTS_INSTANCING_ON
  205. #pragma vertex LitGBufferPassVertex
  206. #pragma fragment LitGBufferPassFragment
  207. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
  208. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitGBufferPass.hlsl"
  209. ENDHLSL
  210. }
  211. Pass
  212. {
  213. Name "DepthOnly"
  214. Tags{"LightMode" = "DepthOnly"}
  215. ZWrite On
  216. ColorMask 0
  217. Cull[_Cull]
  218. HLSLPROGRAM
  219. #pragma exclude_renderers gles gles3 glcore
  220. #pragma target 4.5
  221. #pragma vertex DepthOnlyVertex
  222. #pragma fragment DepthOnlyFragment
  223. // -------------------------------------
  224. // Material Keywords
  225. #pragma shader_feature_local_fragment _ALPHATEST_ON
  226. #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
  227. //--------------------------------------
  228. // GPU Instancing
  229. #pragma multi_compile_instancing
  230. #pragma multi_compile _ DOTS_INSTANCING_ON
  231. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
  232. #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
  233. ENDHLSL
  234. }
  235. // This pass is used when drawing to a _CameraNormalsTexture texture
  236. Pass
  237. {
  238. Name "DepthNormals"
  239. Tags{"LightMode" = "DepthNormals"}
  240. ZWrite On
  241. Cull[_Cull]
  242. HLSLPROGRAM
  243. #pragma exclude_renderers gles gles3 glcore
  244. #pragma target 4.5
  245. #pragma vertex DepthNormalsVertex
  246. #pragma fragment DepthNormalsFragment
  247. // -------------------------------------
  248. // Material Keywords
  249. #pragma shader_feature_local _NORMALMAP
  250. #pragma shader_feature_local _PARALLAXMAP
  251. #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
  252. #pragma shader_feature_local_fragment _ALPHATEST_ON
  253. #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
  254. //--------------------------------------
  255. // GPU Instancing
  256. #pragma multi_compile_instancing
  257. #pragma multi_compile _ DOTS_INSTANCING_ON
  258. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
  259. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitDepthNormalsPass.hlsl"
  260. ENDHLSL
  261. }
  262. // This pass it not used during regular rendering, only for lightmap baking.
  263. Pass
  264. {
  265. Name "Meta"
  266. Tags{"LightMode" = "Meta"}
  267. Cull Off
  268. HLSLPROGRAM
  269. #pragma exclude_renderers gles gles3 glcore
  270. #pragma target 4.5
  271. #pragma vertex UniversalVertexMeta
  272. #pragma fragment UniversalFragmentMetaLit
  273. #pragma shader_feature EDITOR_VISUALIZATION
  274. #pragma shader_feature_local_fragment _SPECULAR_SETUP
  275. #pragma shader_feature_local_fragment _EMISSION
  276. #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
  277. #pragma shader_feature_local_fragment _ALPHATEST_ON
  278. #pragma shader_feature_local_fragment _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
  279. #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
  280. #pragma shader_feature_local_fragment _SPECGLOSSMAP
  281. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
  282. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitMetaPass.hlsl"
  283. ENDHLSL
  284. }
  285. Pass
  286. {
  287. Name "Universal2D"
  288. Tags{ "LightMode" = "Universal2D" }
  289. Blend[_SrcBlend][_DstBlend]
  290. ZWrite[_ZWrite]
  291. Cull[_Cull]
  292. HLSLPROGRAM
  293. #pragma exclude_renderers gles gles3 glcore
  294. #pragma target 4.5
  295. #pragma vertex vert
  296. #pragma fragment frag
  297. #pragma shader_feature_local_fragment _ALPHATEST_ON
  298. #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
  299. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
  300. #include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
  301. ENDHLSL
  302. }
  303. Pass
  304. {
  305. Name "MotionVectors"
  306. Tags{ "LightMode" = "MotionVectors"}
  307. Tags { "RenderType" = "Opaque" }
  308. ZWrite[_ZWrite]
  309. Cull[_Cull]
  310. HLSLPROGRAM
  311. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/OculusMotionVectorCore.hlsl"
  312. #pragma vertex vert
  313. #pragma fragment frag
  314. ENDHLSL
  315. }
  316. }
  317. SubShader
  318. {
  319. // Universal Pipeline tag is required. If Universal render pipeline is not set in the graphics settings
  320. // this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this
  321. // material work with both Universal Render Pipeline and Builtin Unity Pipeline
  322. Tags{"RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "Lit" "IgnoreProjector" = "True" "ShaderModel"="2.0"}
  323. LOD 300
  324. // ------------------------------------------------------------------
  325. // Forward pass. Shades all light in a single pass. GI + emission + Fog
  326. Pass
  327. {
  328. // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
  329. // no LightMode tag are also rendered by Universal Render Pipeline
  330. Name "ForwardLit"
  331. Tags{"LightMode" = "UniversalForward"}
  332. Blend[_SrcBlend][_DstBlend]
  333. ZWrite[_ZWrite]
  334. Cull[_Cull]
  335. HLSLPROGRAM
  336. #pragma only_renderers gles gles3 glcore d3d11
  337. #pragma target 2.0
  338. //--------------------------------------
  339. // GPU Instancing
  340. #pragma multi_compile_instancing
  341. #pragma instancing_options renderinglayer
  342. // -------------------------------------
  343. // Material Keywords
  344. #pragma shader_feature_local _NORMALMAP
  345. #pragma shader_feature_local _PARALLAXMAP
  346. #pragma shader_feature_local _RECEIVE_SHADOWS_OFF
  347. #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
  348. #pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
  349. #pragma shader_feature_local_fragment _ALPHATEST_ON
  350. #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
  351. #pragma shader_feature_local_fragment _EMISSION
  352. #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
  353. #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
  354. #pragma shader_feature_local_fragment _OCCLUSIONMAP
  355. #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
  356. #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
  357. #pragma shader_feature_local_fragment _SPECULAR_SETUP
  358. // -------------------------------------
  359. // Universal Pipeline keywords
  360. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
  361. #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
  362. #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
  363. #pragma multi_compile_fragment _ _SHADOWS_SOFT
  364. #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
  365. #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
  366. #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
  367. #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
  368. #pragma multi_compile_fragment _ _LIGHT_LAYERS
  369. #pragma multi_compile_fragment _ _LIGHT_COOKIES
  370. #pragma multi_compile _ _CLUSTERED_RENDERING
  371. // -------------------------------------
  372. // Unity defined keywords
  373. #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
  374. #pragma multi_compile _ SHADOWS_SHADOWMASK
  375. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  376. #pragma multi_compile _ LIGHTMAP_ON
  377. #pragma multi_compile_fog
  378. #pragma multi_compile_fragment _ DEBUG_DISPLAY
  379. #pragma vertex LitPassVertex
  380. #pragma fragment LitPassFragment
  381. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
  382. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl"
  383. ENDHLSL
  384. }
  385. Pass
  386. {
  387. Name "ShadowCaster"
  388. Tags{"LightMode" = "ShadowCaster"}
  389. ZWrite On
  390. ZTest LEqual
  391. ColorMask 0
  392. Cull[_Cull]
  393. HLSLPROGRAM
  394. #pragma only_renderers gles gles3 glcore d3d11
  395. #pragma target 2.0
  396. //--------------------------------------
  397. // GPU Instancing
  398. #pragma multi_compile_instancing
  399. // -------------------------------------
  400. // Material Keywords
  401. #pragma shader_feature_local_fragment _ALPHATEST_ON
  402. #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
  403. // -------------------------------------
  404. // Universal Pipeline keywords
  405. // This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias
  406. #pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
  407. #pragma vertex ShadowPassVertex
  408. #pragma fragment ShadowPassFragment
  409. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
  410. #include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
  411. ENDHLSL
  412. }
  413. Pass
  414. {
  415. Name "DepthOnly"
  416. Tags{"LightMode" = "DepthOnly"}
  417. ZWrite On
  418. ColorMask 0
  419. Cull[_Cull]
  420. HLSLPROGRAM
  421. #pragma only_renderers gles gles3 glcore d3d11
  422. #pragma target 2.0
  423. //--------------------------------------
  424. // GPU Instancing
  425. #pragma multi_compile_instancing
  426. #pragma vertex DepthOnlyVertex
  427. #pragma fragment DepthOnlyFragment
  428. // -------------------------------------
  429. // Material Keywords
  430. #pragma shader_feature_local_fragment _ALPHATEST_ON
  431. #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
  432. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
  433. #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
  434. ENDHLSL
  435. }
  436. // This pass is used when drawing to a _CameraNormalsTexture texture
  437. Pass
  438. {
  439. Name "DepthNormals"
  440. Tags{"LightMode" = "DepthNormals"}
  441. ZWrite On
  442. Cull[_Cull]
  443. HLSLPROGRAM
  444. #pragma only_renderers gles gles3 glcore d3d11
  445. #pragma target 2.0
  446. #pragma vertex DepthNormalsVertex
  447. #pragma fragment DepthNormalsFragment
  448. // -------------------------------------
  449. // Material Keywords
  450. #pragma shader_feature_local _NORMALMAP
  451. #pragma shader_feature_local _PARALLAXMAP
  452. #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
  453. #pragma shader_feature_local_fragment _ALPHATEST_ON
  454. #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
  455. //--------------------------------------
  456. // GPU Instancing
  457. #pragma multi_compile_instancing
  458. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
  459. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitDepthNormalsPass.hlsl"
  460. ENDHLSL
  461. }
  462. // This pass it not used during regular rendering, only for lightmap baking.
  463. Pass
  464. {
  465. Name "Meta"
  466. Tags{"LightMode" = "Meta"}
  467. Cull Off
  468. HLSLPROGRAM
  469. #pragma only_renderers gles gles3 glcore d3d11
  470. #pragma target 2.0
  471. #pragma vertex UniversalVertexMeta
  472. #pragma fragment UniversalFragmentMetaLit
  473. #pragma shader_feature EDITOR_VISUALIZATION
  474. #pragma shader_feature_local_fragment _SPECULAR_SETUP
  475. #pragma shader_feature_local_fragment _EMISSION
  476. #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
  477. #pragma shader_feature_local_fragment _ALPHATEST_ON
  478. #pragma shader_feature_local_fragment _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
  479. #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
  480. #pragma shader_feature_local_fragment _SPECGLOSSMAP
  481. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
  482. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitMetaPass.hlsl"
  483. ENDHLSL
  484. }
  485. Pass
  486. {
  487. Name "Universal2D"
  488. Tags{ "LightMode" = "Universal2D" }
  489. Blend[_SrcBlend][_DstBlend]
  490. ZWrite[_ZWrite]
  491. Cull[_Cull]
  492. HLSLPROGRAM
  493. #pragma only_renderers gles gles3 glcore d3d11
  494. #pragma target 2.0
  495. #pragma vertex vert
  496. #pragma fragment frag
  497. #pragma shader_feature_local_fragment _ALPHATEST_ON
  498. #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
  499. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
  500. #include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
  501. ENDHLSL
  502. }
  503. }
  504. FallBack "Hidden/Universal Render Pipeline/FallbackError"
  505. CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.LitShader"
  506. }