TerrainLitBase.shader 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. Shader "Hidden/Universal Render Pipeline/Terrain/Lit (Base Pass)"
  2. {
  3. Properties
  4. {
  5. [MainColor] _BaseColor("Color", Color) = (1,1,1,1)
  6. _MainTex("Albedo(RGB), Smoothness(A)", 2D) = "white" {}
  7. _MetallicTex ("Metallic (R)", 2D) = "black" {}
  8. [HideInInspector] _TerrainHolesTexture("Holes Map (RGB)", 2D) = "white" {}
  9. }
  10. HLSLINCLUDE
  11. #pragma multi_compile_fragment __ _ALPHATEST_ON
  12. ENDHLSL
  13. SubShader
  14. {
  15. Tags { "Queue" = "Geometry-100" "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "Lit" "IgnoreProjector" = "True"}
  16. LOD 200
  17. // ------------------------------------------------------------------
  18. // Forward pass. Shades all light in a single pass. GI + emission + Fog
  19. Pass
  20. {
  21. Name "ForwardLit"
  22. // Lightmode matches the ShaderPassName set in UniversalPipeline.cs. SRPDefaultUnlit and passes with
  23. // no LightMode tag are also rendered by Universal Pipeline
  24. Tags{"LightMode" = "UniversalForward"}
  25. HLSLPROGRAM
  26. #pragma target 2.0
  27. // -------------------------------------
  28. // Material Keywords
  29. #define _METALLICSPECGLOSSMAP 1
  30. #define _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 1
  31. // -------------------------------------
  32. // Universal Pipeline keywords
  33. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
  34. #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
  35. #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
  36. #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
  37. #pragma multi_compile_fragment _ _SHADOWS_SOFT
  38. #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
  39. #pragma multi_compile _ SHADOWS_SHADOWMASK
  40. #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
  41. #pragma multi_compile_fragment _ _LIGHT_LAYERS
  42. #pragma multi_compile_fragment _ _LIGHT_COOKIES
  43. #pragma multi_compile _ _CLUSTERED_RENDERING
  44. // -------------------------------------
  45. // Unity defined keywords
  46. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  47. #pragma multi_compile _ LIGHTMAP_ON
  48. #pragma multi_compile _ DYNAMICLIGHTMAP_ON
  49. #pragma multi_compile_fog
  50. #pragma multi_compile_instancing
  51. #pragma instancing_options norenderinglayer assumeuniformscaling nomatrices nolightprobe nolightmap
  52. #pragma multi_compile_fragment _ DEBUG_DISPLAY
  53. #pragma vertex SplatmapVert
  54. #pragma fragment SplatmapFragment
  55. #pragma shader_feature_local _NORMALMAP
  56. // Sample normal in pixel shader when doing instancing
  57. #pragma shader_feature_local _TERRAIN_INSTANCED_PERPIXEL_NORMAL
  58. #define TERRAIN_SPLAT_BASEPASS 1
  59. #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitInput.hlsl"
  60. #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitPasses.hlsl"
  61. ENDHLSL
  62. }
  63. Pass
  64. {
  65. Name "ShadowCaster"
  66. Tags{"LightMode" = "ShadowCaster"}
  67. ZWrite On
  68. ColorMask 0
  69. HLSLPROGRAM
  70. #pragma target 2.0
  71. #pragma multi_compile_instancing
  72. #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
  73. #pragma vertex ShadowPassVertex
  74. #pragma fragment ShadowPassFragment
  75. #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitInput.hlsl"
  76. #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitPasses.hlsl"
  77. ENDHLSL
  78. }
  79. // ------------------------------------------------------------------
  80. // GBuffer pass. Does GI + emission. All additional lights are done deferred as well as fog
  81. Pass
  82. {
  83. Name "GBuffer"
  84. Tags{"LightMode" = "UniversalGBuffer"}
  85. HLSLPROGRAM
  86. #pragma exclude_renderers gles
  87. #pragma target 2.0
  88. // -------------------------------------
  89. // Material Keywords
  90. #define _METALLICSPECGLOSSMAP 1
  91. #define _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 1
  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 _ _ADDITIONAL_LIGHT_SHADOWS
  97. #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
  98. #pragma multi_compile_fragment _ _SHADOWS_SOFT
  99. #pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
  100. #pragma multi_compile_fragment _ _LIGHT_LAYERS
  101. // -------------------------------------
  102. // Unity defined keywords
  103. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  104. #pragma multi_compile _ LIGHTMAP_ON
  105. #pragma multi_compile _ DYNAMICLIGHTMAP_ON
  106. #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
  107. #pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
  108. #pragma multi_compile_instancing
  109. #pragma instancing_options norenderinglayer assumeuniformscaling nomatrices nolightprobe nolightmap
  110. #pragma vertex SplatmapVert
  111. #pragma fragment SplatmapFragment
  112. #pragma shader_feature_local _NORMALMAP
  113. // Sample normal in pixel shader when doing instancing
  114. #pragma shader_feature_local _TERRAIN_INSTANCED_PERPIXEL_NORMAL
  115. #define TERRAIN_SPLAT_BASEPASS 1
  116. #define TERRAIN_GBUFFER 1
  117. #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitInput.hlsl"
  118. #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitPasses.hlsl"
  119. ENDHLSL
  120. }
  121. Pass
  122. {
  123. Name "DepthOnly"
  124. Tags{"LightMode" = "DepthOnly"}
  125. ZWrite On
  126. ColorMask 0
  127. HLSLPROGRAM
  128. #pragma target 2.0
  129. #pragma vertex DepthOnlyVertex
  130. #pragma fragment DepthOnlyFragment
  131. #pragma multi_compile_instancing
  132. #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
  133. #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitInput.hlsl"
  134. #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitPasses.hlsl"
  135. ENDHLSL
  136. }
  137. Pass
  138. {
  139. Name "DepthNormals"
  140. Tags{"LightMode" = "DepthNormals"}
  141. ZWrite On
  142. HLSLPROGRAM
  143. #pragma target 2.0
  144. #pragma vertex DepthNormalOnlyVertex
  145. #pragma fragment DepthNormalOnlyFragment
  146. #pragma multi_compile_instancing
  147. #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
  148. #pragma shader_feature_local _NORMALMAP
  149. #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitInput.hlsl"
  150. #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitDepthNormalsPass.hlsl"
  151. ENDHLSL
  152. }
  153. // This pass it not used during regular rendering, only for lightmap baking.
  154. Pass
  155. {
  156. Name "Meta"
  157. Tags{"LightMode" = "Meta"}
  158. Cull Off
  159. HLSLPROGRAM
  160. #pragma vertex TerrainVertexMeta
  161. #pragma fragment TerrainFragmentMeta
  162. #pragma shader_feature EDITOR_VISUALIZATION
  163. #pragma multi_compile_instancing
  164. #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
  165. #define _METALLICSPECGLOSSMAP 1
  166. #define _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 1
  167. #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitInput.hlsl"
  168. #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitMetaPass.hlsl"
  169. ENDHLSL
  170. }
  171. UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
  172. UsePass "Universal Render Pipeline/Terrain/Lit/SceneSelectionPass"
  173. }
  174. FallBack "Hidden/Universal Render Pipeline/FallbackError"
  175. //CustomEditor "LitShaderGUI"
  176. }