BakedLit.shader 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. Shader "Universal Render Pipeline/Baked Lit"
  2. {
  3. Properties
  4. {
  5. [MainTexture] _BaseMap("Texture", 2D) = "white" {}
  6. [MainColor] _BaseColor("Color", Color) = (1, 1, 1, 1)
  7. _Cutoff("AlphaCutout", Range(0.0, 1.0)) = 0.5
  8. _BumpMap("Normal Map", 2D) = "bump" {}
  9. // BlendMode
  10. _Surface("__surface", Float) = 0.0
  11. _Blend("__mode", Float) = 0.0
  12. _Cull("__cull", Float) = 2.0
  13. [ToggleUI] _AlphaClip("__clip", Float) = 0.0
  14. [HideInInspector] _BlendOp("__blendop", Float) = 0.0
  15. [HideInInspector] _SrcBlend("__src", Float) = 1.0
  16. [HideInInspector] _DstBlend("__dst", Float) = 0.0
  17. [HideInInspector] _ZWrite("__zw", Float) = 1.0
  18. // Editmode props
  19. _QueueOffset("Queue offset", Float) = 0.0
  20. [HideInInspector][NoScaleOffset]unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {}
  21. [HideInInspector][NoScaleOffset]unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {}
  22. [HideInInspector][NoScaleOffset]unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {}
  23. }
  24. SubShader
  25. {
  26. Tags { "RenderType" = "Opaque" "IgnoreProjector" = "True" "RenderPipeline" = "UniversalPipeline" "ShaderModel"="4.5"}
  27. LOD 100
  28. Blend [_SrcBlend][_DstBlend]
  29. ZWrite [_ZWrite]
  30. Cull [_Cull]
  31. Pass
  32. {
  33. Name "BakedLit"
  34. Tags{ "LightMode" = "UniversalForwardOnly" }
  35. HLSLPROGRAM
  36. #pragma exclude_renderers gles gles3 glcore
  37. #pragma target 4.5
  38. // -------------------------------------
  39. // Material Keywords
  40. #pragma shader_feature_local _NORMALMAP
  41. #pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
  42. #pragma shader_feature_local_fragment _ALPHATEST_ON
  43. #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
  44. // -------------------------------------
  45. // Universal Pipeline keywords
  46. #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
  47. #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
  48. // -------------------------------------
  49. // Unity defined keywords
  50. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  51. #pragma multi_compile _ LIGHTMAP_ON
  52. #pragma multi_compile_fog
  53. #pragma multi_compile _ DEBUG_DISPLAY
  54. //--------------------------------------
  55. // GPU Instancing
  56. #pragma multi_compile_instancing
  57. #pragma multi_compile _ DOTS_INSTANCING_O
  58. #pragma vertex BakedLitForwardPassVertex
  59. #pragma fragment BakedLitForwardPassFragment
  60. // Lighting include is needed because of GI
  61. #include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
  62. #include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitForwardPass.hlsl"
  63. ENDHLSL
  64. }
  65. Pass
  66. {
  67. Tags{"LightMode" = "DepthOnly"}
  68. ZWrite On
  69. ColorMask 0
  70. HLSLPROGRAM
  71. #pragma exclude_renderers gles gles3 glcore
  72. #pragma target 4.5
  73. #pragma vertex DepthOnlyVertex
  74. #pragma fragment DepthOnlyFragment
  75. // -------------------------------------
  76. // Material Keywords
  77. #pragma shader_feature_local_fragment _ALPHATEST_ON
  78. //--------------------------------------
  79. // GPU Instancing
  80. #pragma multi_compile_instancing
  81. #pragma multi_compile _ DOTS_INSTANCING_ON
  82. #include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
  83. #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
  84. ENDHLSL
  85. }
  86. // This pass is used when drawing to a _CameraNormalsTexture texture with the forward renderer or the depthNormal prepass with the deferred renderer.
  87. Pass
  88. {
  89. Name "DepthNormalsOnly"
  90. Tags{"LightMode" = "DepthNormalsOnly"}
  91. ZWrite On
  92. Cull[_Cull]
  93. HLSLPROGRAM
  94. #pragma exclude_renderers gles gles3 glcore
  95. #pragma target 4.5
  96. #pragma vertex DepthNormalsVertex
  97. #pragma fragment DepthNormalsFragment
  98. // -------------------------------------
  99. // Material Keywords
  100. #pragma shader_feature_local _ _NORMALMAP
  101. #pragma shader_feature_local_fragment _ALPHATEST_ON
  102. // -------------------------------------
  103. // Unity defined keywords
  104. #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT // forward-only variant
  105. //--------------------------------------
  106. // GPU Instancing
  107. #pragma multi_compile_instancing
  108. #pragma multi_compile _ DOTS_INSTANCING_ON
  109. #include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
  110. #include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitDepthNormalsPass.hlsl"
  111. ENDHLSL
  112. }
  113. // Same as DepthNormals pass, but used for deferred renderer and forwardOnly materials.
  114. Pass
  115. {
  116. Name "DepthNormalsOnly"
  117. Tags{"LightMode" = "DepthNormalsOnly"}
  118. ZWrite On
  119. Cull[_Cull]
  120. HLSLPROGRAM
  121. #pragma exclude_renderers gles gles3 glcore
  122. #pragma target 4.5
  123. #pragma vertex DepthNormalsVertex
  124. #pragma fragment DepthNormalsFragment
  125. // -------------------------------------
  126. // Material Keywords
  127. #pragma shader_feature_local _ _NORMALMAP
  128. #pragma shader_feature_local_fragment _ALPHATEST_ON
  129. // -------------------------------------
  130. // Unity defined keywords
  131. #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT // forward-only variant
  132. //--------------------------------------
  133. // Defines
  134. #define BUMP_SCALE_NOT_SUPPORTED 1
  135. //--------------------------------------
  136. // GPU Instancing
  137. #pragma multi_compile_instancing
  138. #pragma multi_compile _ DOTS_INSTANCING_ON
  139. #include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
  140. #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl"
  141. ENDHLSL
  142. }
  143. // This pass it not used during regular rendering, only for lightmap baking.
  144. Pass
  145. {
  146. Name "Meta"
  147. Tags{"LightMode" = "Meta"}
  148. Cull Off
  149. HLSLPROGRAM
  150. #pragma exclude_renderers gles gles3 glcore
  151. #pragma target 4.5
  152. #pragma vertex UniversalVertexMeta
  153. #pragma fragment UniversalFragmentMetaUnlit
  154. #pragma shader_feature EDITOR_VISUALIZATION
  155. #include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
  156. #include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitMetaPass.hlsl"
  157. ENDHLSL
  158. }
  159. Pass
  160. {
  161. Name "Universal2D"
  162. Tags{ "LightMode" = "Universal2D" }
  163. Blend[_SrcBlend][_DstBlend]
  164. ZWrite[_ZWrite]
  165. Cull[_Cull]
  166. HLSLPROGRAM
  167. #pragma exclude_renderers gles gles3 glcore
  168. #pragma target 4.5
  169. #pragma vertex vert
  170. #pragma fragment frag
  171. #pragma shader_feature_local_fragment _ALPHATEST_ON
  172. #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
  173. #include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
  174. #include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
  175. ENDHLSL
  176. }
  177. }
  178. SubShader
  179. {
  180. Tags { "RenderType" = "Opaque" "IgnoreProjector" = "True" "RenderPipeline" = "UniversalPipeline" "ShaderModel"="2.0"}
  181. LOD 100
  182. Blend [_SrcBlend][_DstBlend]
  183. ZWrite [_ZWrite]
  184. Cull [_Cull]
  185. Pass
  186. {
  187. Name "BakedLit"
  188. Tags{ "LightMode" = "UniversalForwardOnly" }
  189. HLSLPROGRAM
  190. #pragma only_renderers gles gles3 glcore d3d11
  191. #pragma target 2.0
  192. // -------------------------------------
  193. // Material Keywords
  194. #pragma shader_feature_local _NORMALMAP
  195. #pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
  196. #pragma shader_feature_local_fragment _ALPHATEST_ON
  197. #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
  198. // -------------------------------------
  199. // Universal Pipeline keywords
  200. #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
  201. // -------------------------------------
  202. // Unity defined keywords
  203. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  204. #pragma multi_compile _ LIGHTMAP_ON
  205. #pragma multi_compile_fog
  206. #pragma multi_compile _ DEBUG_DISPLAY
  207. //--------------------------------------
  208. // GPU Instancing
  209. #pragma multi_compile_instancing
  210. #pragma vertex BakedLitForwardPassVertex
  211. #pragma fragment BakedLitForwardPassFragment
  212. // Lighting include is needed because of GI
  213. #include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
  214. #include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitForwardPass.hlsl"
  215. ENDHLSL
  216. }
  217. Pass
  218. {
  219. Tags{"LightMode" = "DepthOnly"}
  220. ZWrite On
  221. ColorMask 0
  222. HLSLPROGRAM
  223. #pragma only_renderers gles gles3 glcore d3d11
  224. #pragma target 2.0
  225. //--------------------------------------
  226. // GPU Instancing
  227. #pragma multi_compile_instancing
  228. #pragma vertex DepthOnlyVertex
  229. #pragma fragment DepthOnlyFragment
  230. // -------------------------------------
  231. // Material Keywords
  232. #pragma shader_feature_local_fragment _ALPHATEST_ON
  233. #include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
  234. #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
  235. ENDHLSL
  236. }
  237. // This pass is used when drawing to a _CameraNormalsTexture texture
  238. Pass
  239. {
  240. Name "DepthNormals"
  241. Tags{"LightMode" = "DepthNormals"}
  242. ZWrite On
  243. Cull[_Cull]
  244. HLSLPROGRAM
  245. #pragma only_renderers gles gles3 glcore d3d11
  246. #pragma target 2.0
  247. #pragma vertex DepthNormalsVertex
  248. #pragma fragment DepthNormalsFragment
  249. // -------------------------------------
  250. // Material Keywords
  251. #pragma shader_feature_local _ _NORMALMAP
  252. #pragma shader_feature_local_fragment _ALPHATEST_ON
  253. //--------------------------------------
  254. // GPU Instancing
  255. #pragma multi_compile_instancing
  256. #include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
  257. #include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitDepthNormalsPass.hlsl"
  258. ENDHLSL
  259. }
  260. // This pass it not used during regular rendering, only for lightmap baking.
  261. Pass
  262. {
  263. Name "Meta"
  264. Tags{"LightMode" = "Meta"}
  265. Cull Off
  266. HLSLPROGRAM
  267. #pragma only_renderers gles gles3 glcore d3d11
  268. #pragma target 2.0
  269. #pragma vertex UniversalVertexMeta
  270. #pragma fragment UniversalFragmentMetaUnlit
  271. #pragma shader_feature EDITOR_VISUALIZATION
  272. #include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
  273. #include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitMetaPass.hlsl"
  274. ENDHLSL
  275. }
  276. Pass
  277. {
  278. Name "Universal2D"
  279. Tags{ "LightMode" = "Universal2D" }
  280. Blend[_SrcBlend][_DstBlend]
  281. ZWrite[_ZWrite]
  282. Cull[_Cull]
  283. HLSLPROGRAM
  284. #pragma only_renderers gles gles3 glcore d3d11
  285. #pragma target 2.0
  286. #pragma vertex vert
  287. #pragma fragment frag
  288. #pragma shader_feature_local_fragment _ALPHATEST_ON
  289. #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
  290. #include "Packages/com.unity.render-pipelines.universal/Shaders/BakedLitInput.hlsl"
  291. #include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
  292. ENDHLSL
  293. }
  294. }
  295. FallBack "Universal Render Pipeline/Unlit"
  296. CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.BakedLitShader"
  297. }