Lux URP Terrain Add.shader 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. Shader "Hidden/Lux URP/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] _Smoothness0("Smoothness 0", Range(0.0, 1.0)) = 1.0
  23. [HideInInspector] _Smoothness1("Smoothness 1", Range(0.0, 1.0)) = 1.0
  24. [HideInInspector] _Smoothness2("Smoothness 2", Range(0.0, 1.0)) = 1.0
  25. [HideInInspector] _Smoothness3("Smoothness 3", Range(0.0, 1.0)) = 1.0
  26. // used in fallback on old cards & base map
  27. [HideInInspector] _BaseMap("BaseMap (RGB)", 2D) = "white" {}
  28. [HideInInspector] _BaseColor("Main Color", Color) = (1,1,1,1)
  29. }
  30. // NOTE: Here we skip alpha testing (this is the add pass) and fully rely on Ztesting (ZTest Equal)
  31. HLSLINCLUDE
  32. //#pragma multi_compile_fragment __ _ALPHATEST_ON
  33. ENDHLSL
  34. SubShader
  35. {
  36. Tags { "Queue" = "Geometry-99" "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "IgnoreProjector" = "True"}
  37. Pass
  38. {
  39. Name "TerrainAddLit"
  40. Tags { "LightMode" = "UniversalForward" }
  41. // This handles deph and clip holes!
  42. ZTest Equal
  43. Blend One One
  44. HLSLPROGRAM
  45. // Required to compile gles 2.0 with standard srp library
  46. #pragma prefer_hlslcc gles
  47. #pragma exclude_renderers d3d11_9x
  48. #pragma target 3.0
  49. #pragma vertex SplatmapVert
  50. #pragma fragment SplatmapFragment
  51. // -------------------------------------
  52. // Lightweight Pipeline keywords
  53. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS
  54. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
  55. #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
  56. #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
  57. #pragma multi_compile_fragment _ _SHADOWS_SOFT
  58. #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
  59. #pragma multi_compile _ SHADOWS_SHADOWMASK
  60. #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
  61. // -------------------------------------
  62. // Unity defined keywords
  63. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  64. #pragma multi_compile _ LIGHTMAP_ON
  65. #pragma multi_compile_fog
  66. #pragma multi_compile_instancing
  67. #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
  68. #pragma shader_feature_local _NORMALMAP
  69. // Sample normal in pixel shader when doing instancing
  70. #pragma shader_feature_local _TERRAIN_INSTANCED_PERPIXEL_NORMAL
  71. #define TERRAIN_SPLAT_ADDPASS
  72. #include "Includes/TerrainLitInput.hlsl"
  73. #include "Includes/TerrainLitPasses.hlsl"
  74. ENDHLSL
  75. }
  76. }
  77. Fallback "Hidden/InternalErrorShader"
  78. }