TerrainLitAdd.shader 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. Shader "Hidden/Universal Render Pipeline/Terrain/Lit (Add Pass)"
  2. {
  3. Properties
  4. {
  5. // Layer count is passed down to guide height-blend enable/disable, due
  6. // to the fact that heigh-based blend will be broken with multipass.
  7. [HideInInspector] [PerRendererData] _NumLayersCount ("Total Layer Count", Float) = 1.0
  8. // set by terrain engine
  9. [HideInInspector] _Control("Control (RGBA)", 2D) = "red" {}
  10. [HideInInspector] _Splat3("Layer 3 (A)", 2D) = "white" {}
  11. [HideInInspector] _Splat2("Layer 2 (B)", 2D) = "white" {}
  12. [HideInInspector] _Splat1("Layer 1 (G)", 2D) = "white" {}
  13. [HideInInspector] _Splat0("Layer 0 (R)", 2D) = "white" {}
  14. [HideInInspector] _Normal3("Normal 3 (A)", 2D) = "bump" {}
  15. [HideInInspector] _Normal2("Normal 2 (B)", 2D) = "bump" {}
  16. [HideInInspector] _Normal1("Normal 1 (G)", 2D) = "bump" {}
  17. [HideInInspector] _Normal0("Normal 0 (R)", 2D) = "bump" {}
  18. [HideInInspector][Gamma] _Metallic0("Metallic 0", Range(0.0, 1.0)) = 0.0
  19. [HideInInspector][Gamma] _Metallic1("Metallic 1", Range(0.0, 1.0)) = 0.0
  20. [HideInInspector][Gamma] _Metallic2("Metallic 2", Range(0.0, 1.0)) = 0.0
  21. [HideInInspector][Gamma] _Metallic3("Metallic 3", Range(0.0, 1.0)) = 0.0
  22. [HideInInspector] _Mask3("Mask 3 (A)", 2D) = "grey" {}
  23. [HideInInspector] _Mask2("Mask 2 (B)", 2D) = "grey" {}
  24. [HideInInspector] _Mask1("Mask 1 (G)", 2D) = "grey" {}
  25. [HideInInspector] _Mask0("Mask 0 (R)", 2D) = "grey" {}
  26. [HideInInspector] _Smoothness0("Smoothness 0", Range(0.0, 1.0)) = 1.0
  27. [HideInInspector] _Smoothness1("Smoothness 1", Range(0.0, 1.0)) = 1.0
  28. [HideInInspector] _Smoothness2("Smoothness 2", Range(0.0, 1.0)) = 1.0
  29. [HideInInspector] _Smoothness3("Smoothness 3", Range(0.0, 1.0)) = 1.0
  30. // used in fallback on old cards & base map
  31. [HideInInspector] _BaseMap("BaseMap (RGB)", 2D) = "white" {}
  32. [HideInInspector] _BaseColor("Main Color", Color) = (1,1,1,1)
  33. [HideInInspector] _TerrainHolesTexture("Holes Map (RGB)", 2D) = "white" {}
  34. }
  35. HLSLINCLUDE
  36. #pragma multi_compile_fragment __ _ALPHATEST_ON
  37. ENDHLSL
  38. SubShader
  39. {
  40. Tags { "Queue" = "Geometry-99" "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "Lit" "IgnoreProjector" = "True"}
  41. Pass
  42. {
  43. Name "TerrainAddLit"
  44. Tags { "LightMode" = "UniversalForward" }
  45. Blend One One
  46. HLSLPROGRAM
  47. #pragma target 3.0
  48. #pragma vertex SplatmapVert
  49. #pragma fragment SplatmapFragment
  50. // -------------------------------------
  51. // Universal Pipeline keywords
  52. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
  53. #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
  54. #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
  55. #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
  56. #pragma multi_compile_fragment _ _SHADOWS_SOFT
  57. #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
  58. #pragma multi_compile _ SHADOWS_SHADOWMASK
  59. #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
  60. #pragma multi_compile_fragment _ _LIGHT_LAYERS
  61. #pragma multi_compile_fragment _ _LIGHT_COOKIES
  62. #pragma multi_compile _ _CLUSTERED_RENDERING
  63. // -------------------------------------
  64. // Unity defined keywords
  65. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  66. #pragma multi_compile _ LIGHTMAP_ON
  67. #pragma multi_compile_fog
  68. #pragma multi_compile_instancing
  69. #pragma instancing_options norenderinglayer assumeuniformscaling nomatrices nolightprobe nolightmap
  70. #pragma multi_compile_fragment _ DEBUG_DISPLAY
  71. #pragma shader_feature_local_fragment _TERRAIN_BLEND_HEIGHT
  72. #pragma shader_feature_local _NORMALMAP
  73. #pragma shader_feature_local_fragment _MASKMAP
  74. // Sample normal in pixel shader when doing instancing
  75. #pragma shader_feature_local _TERRAIN_INSTANCED_PERPIXEL_NORMAL
  76. #define TERRAIN_SPLAT_ADDPASS
  77. #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitInput.hlsl"
  78. #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitPasses.hlsl"
  79. ENDHLSL
  80. }
  81. Pass
  82. {
  83. Name "GBuffer"
  84. Tags{"LightMode" = "UniversalGBuffer"}
  85. Blend One One
  86. HLSLPROGRAM
  87. #pragma exclude_renderers gles
  88. #pragma target 3.0
  89. #pragma vertex SplatmapVert
  90. #pragma fragment SplatmapFragment
  91. // -------------------------------------
  92. // Universal Pipeline keywords
  93. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
  94. //#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
  95. //#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
  96. #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
  97. #pragma multi_compile_fragment _ _SHADOWS_SOFT
  98. #pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
  99. #pragma multi_compile_fragment _ _LIGHT_LAYERS
  100. // -------------------------------------
  101. // Unity defined keywords
  102. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  103. #pragma multi_compile _ LIGHTMAP_ON
  104. #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
  105. #pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
  106. //#pragma multi_compile_fog
  107. #pragma multi_compile_instancing
  108. #pragma instancing_options norenderinglayer assumeuniformscaling nomatrices nolightprobe nolightmap
  109. #pragma shader_feature_local _TERRAIN_BLEND_HEIGHT
  110. #pragma shader_feature_local _NORMALMAP
  111. #pragma shader_feature_local _MASKMAP
  112. // Sample normal in pixel shader when doing instancing
  113. #pragma shader_feature_local _TERRAIN_INSTANCED_PERPIXEL_NORMAL
  114. #define TERRAIN_SPLAT_ADDPASS 1
  115. #define TERRAIN_GBUFFER 1
  116. #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitInput.hlsl"
  117. #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitPasses.hlsl"
  118. ENDHLSL
  119. }
  120. }
  121. Fallback "Hidden/Universal Render Pipeline/FallbackError"
  122. }