InTerra_TerrainLit_Tessellation_2023_1.shader 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. // NOTE! This file is based on Unity file "TerrainLit.shader" which was used as a template for adding all the InTerra features.
  2. Shader "InTerra/HDRP Tessellation/Terrain (Lit with Features) 2023.1 or Heigher"
  3. {
  4. Properties
  5. {
  6. [HideInInspector] [ToggleUI] _EnableHeightBlend("EnableHeightBlend", Float) = 0.0
  7. _HeightTransition("Height Transition", Range(0, 60)) = 0.0
  8. [HideInInspector] [Enum(Off, 0, From Ambient Occlusion, 1)] _SpecularOcclusionMode("Specular Occlusion Mode", Int) = 1
  9. [HideInInspector][PerRendererData] _NumLayersCount("Total Layer Count", Float) = 1.0
  10. // Following are builtin properties
  11. // Stencil state
  12. // Forward
  13. [HideInInspector] _StencilRef("_StencilRef", Int) = 0 // StencilUsage.Clear
  14. [HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 3 // StencilUsage.RequiresDeferredLighting | StencilUsage.SubsurfaceScattering
  15. // GBuffer
  16. [HideInInspector] _StencilRefGBuffer("_StencilRefGBuffer", Int) = 2 // StencilUsage.RequiresDeferredLighting
  17. [HideInInspector] _StencilWriteMaskGBuffer("_StencilWriteMaskGBuffer", Int) = 3 // StencilUsage.RequiresDeferredLighting | StencilUsage.SubsurfaceScattering
  18. // Depth prepass
  19. [HideInInspector] _StencilRefDepth("_StencilRefDepth", Int) = 0 // Nothing
  20. [HideInInspector] _StencilWriteMaskDepth("_StencilWriteMaskDepth", Int) = 8 // StencilUsage.TraceReflectionRay
  21. // Blending state
  22. [HideInInspector] _ZWrite ("__zw", Float) = 1.0
  23. [HideInInspector][ToggleUI] _TransparentZWrite("_TransparentZWrite", Float) = 0.0
  24. [HideInInspector] _CullMode("__cullmode", Float) = 2.0
  25. [HideInInspector] _ZTestDepthEqualForOpaque("_ZTestDepthEqualForOpaque", Int) = 4 // Less equal
  26. [HideInInspector] _ZTestGBuffer("_ZTestGBuffer", Int) = 4
  27. [ToggleUI] _EnableInstancedPerPixelNormal("Instanced per pixel normal", Float) = 1.0
  28. [HideInInspector] _TerrainHolesTexture("Holes Map (RGB)", 2D) = "white" {}
  29. // Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor"
  30. // value that exist to identify if the GI emission need to be enabled.
  31. // In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it.
  32. // TODO: Fix the code in legacy unity so we can customize the behavior for GI
  33. [HideInInspector] _EmissionColor("Color", Color) = (1, 1, 1)
  34. // HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes.
  35. [HideInInspector] _MainTex("Albedo", 2D) = "white" {}
  36. [HideInInspector] _Color("Color", Color) = (1,1,1,1)
  37. [HideInInspector] [ToggleUI] _SupportDecals("Support Decals", Float) = 1.0
  38. [HideInInspector] [ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0
  39. [HideInInspector] [ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0
  40. //inTerra
  41. _HT_distance("Distance", vector) = (3,10,0,25)
  42. _HT_distance_scale("Scale", Range(0,0.5)) = 0.25
  43. _HT_cover("Cover strenght", Range(0,1)) = 0.6
  44. _Distance_HeightTransition("Distance Height blending Sharpness ", Range(0,60)) = 10
  45. _TriplanarSharpness("Triplanar Sharpness", Range(4,10)) = 9
  46. _ParallaxAffineStepsTerrain("", Float) = 3
  47. _TriplanarOneToAllSteep("", Float) = 0
  48. _TerrainColorTintTexture("Color Tint Texture", 2D) = "white" {}
  49. _TerrainColorTintStrenght("Color Tint Strenght", Range(1, 0)) = 0
  50. _TerrainNormalTintTexture("Additional Normal Texture", 2D) = "bump" {}
  51. _TerrainNormalTintStrenght("Additional Normal Strenght", Range(0, 1)) = 0.0
  52. _TerrainNormalTintDistance("Additional Normal Distance", vector) = (3,10,0,25)
  53. [HideInInspector] _TerrainSizeXZPosY("", Vector) = (0,0,0)
  54. _TessellationFactor("Tessellation Factor", Range(0.0, 64.0)) = 8.0
  55. _TessellationFactorMinDistance("Tessellation start fading distance", Float) = 5.0
  56. _TessellationFactorMaxDistance("Tessellation end fading distance", Float) = 25.0
  57. _TessellationFactorTriangleSize("Tessellation triangle size", Float) = 100.0
  58. _TessellationShapeFactor("Tessellation shape factor", Range(0.0, 1.0)) = 0.75 // Only use with Phong
  59. [HideInInspector]_TessellationBackFaceCullEpsilon("Tessellation back face epsilon", Range(-1, 0)) = -0.25
  60. [HideInInspector]_TessellationMaxDisplacement("The Layers Heighest Amplitude", Float) = 1
  61. _MipMapFade("MipMap fade", vector) = (5,20,-5,35)
  62. _MipMapLevel("MipMap level", Float) = 0
  63. _Tessellation_HeightTransition("Tessellation Height blending Sharpness ", Range(0,60)) = 15
  64. _TessellationShadowQuality("Quality of Tessellation Shadows", Range(0,1)) = 0.5
  65. _TrackTessallationHeightTransition("Track Tessellation Height blending Sharpness ", Range(0,60)) = 15
  66. _TrackTessallationHeightOffset("",Range(-1.0 ,1.0)) = 0
  67. _TrackAO("", Range(0,1)) = 0.8
  68. _TrackTessallation("", Range(0,1)) = 0
  69. _TrackEdgeNormals("Track Edge Normals", Float) = 2
  70. _TrackDetailTexture("Track Color Detail Texture", 2D) = "white" {}
  71. [Normal] _TrackDetailNormalTexture("Track Normal Detail Texture", 2D) = "bump" {}
  72. _TrackDetailNormalStrenght("Track Detail Normal Strenght", Float) = 1
  73. _TrackNormalStrenght("Track Normal Strenght", Float) = 1
  74. _TrackEdgeSharpness("Track Edge Normals", Range(0.001,4)) = 1
  75. _TrackHeightOffset("Track Heightmap Offset", Range(-1,1)) = 0
  76. _TrackMultiplyStrenght("Track Multiply strenght", Float) = 3
  77. _TrackHeightTransition("Track Normal Strenght", Range(0, 60)) = 20
  78. _ParallaxTrackAffineSteps("", Float) = 3
  79. _ParallaxTrackSteps("", Float) = 5
  80. _Gamma("", Float) = 0
  81. _WorldMapping("", Float) = 0
  82. _HeightmapBlending("", Float) = 1
  83. _Terrain_Parallax("", Float) = 0
  84. _Tracks("", Float) = 0
  85. [KeywordEnum(Two, Four, Eight, Sixteen)] _Layers("Layers",int) = 2
  86. }
  87. HLSLINCLUDE
  88. #pragma target 5.0
  89. #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
  90. // Terrain builtin keywords
  91. #pragma shader_feature_local _TERRAIN_8_LAYERS
  92. #define _NORMALMAP
  93. #define _MASKMAP
  94. #pragma shader_feature_local _SPECULAR_OCCLUSION_NONE
  95. // Sample normal in pixel shader when doing instancing
  96. #pragma shader_feature_local _TERRAIN_INSTANCED_PERPIXEL_NORMAL
  97. #pragma shader_feature_local _DISABLE_DECALS
  98. #pragma shader_feature_local _ADD_PRECOMPUTED_VELOCITY
  99. #pragma multi_compile _ _ALPHATEST_ON
  100. //-----------TESSELLATION-------------------------------
  101. #define TESSELLATION_ON
  102. #define HAVE_TESSELLATION_MODIFICATION
  103. #define _TESSELLATION_DISPLACEMENT
  104. #define _HEIGHTMAP
  105. #define _CONSERVATIVE_DEPTH_OFFSET //heightmap
  106. //--------------------------------------------------------------
  107. // Define _DEFERRED_CAPABLE_MATERIAL for shader capable to run in deferred pass
  108. #define _DEFERRED_CAPABLE_MATERIAL
  109. // InTerra Keywords
  110. #pragma shader_feature_local __ _TERRAIN_TRIPLANAR_ONE _TERRAIN_TRIPLANAR
  111. #pragma shader_feature_local_fragment _TERRAIN_DISTANCEBLEND
  112. #pragma shader_feature_local_domain _TESSELLATION_PHONG
  113. #pragma shader_feature_local __ _LAYERS_TWO _LAYERS_EIGHT _LAYERS_SIXTEEN
  114. #define INTERRA_TERRAIN
  115. #define UNITY_2022_2_OR_NEWER
  116. #include "InTerra_TerrainLit_Splatmap_Includes.hlsl"
  117. ENDHLSL
  118. SubShader
  119. {
  120. PackageRequirements { "com.unity.render-pipelines.high-definition":"[15.0.0,18.0.0]" }
  121. // This tags allow to use the shader replacement features
  122. Tags
  123. {
  124. "RenderPipeline" = "HDRenderPipeline"
  125. "RenderType" = "Opaque"
  126. "SplatCount" = "16"
  127. "MaskMapR" = "Metallic"
  128. "MaskMapG" = "AO"
  129. "MaskMapB" = "Height"
  130. "MaskMapA" = "Smoothness"
  131. "DiffuseA" = "Smoothness (becomes Density when Mask map is assigned)" // when MaskMap is disabled
  132. "DiffuseA_MaskMapUsed" = "Density" // when MaskMap is enabled
  133. "TerrainCompatible" = "True"
  134. }
  135. // Caution: The outline selection in the editor use the vertex shader/hull/domain shader of the first pass declare. So it should not bethe meta pass.
  136. Pass
  137. {
  138. Name "GBuffer"
  139. Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index
  140. Cull [_CullMode]
  141. ZTest [_ZTestGBuffer]
  142. Stencil
  143. {
  144. WriteMask [_StencilWriteMaskGBuffer]
  145. Ref [_StencilRefGBuffer]
  146. Comp Always
  147. Pass Replace
  148. }
  149. HLSLPROGRAM
  150. #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
  151. // All our shaders use same name for entry point
  152. #pragma vertex Vert
  153. #pragma fragment Frag
  154. #pragma hull Hull
  155. #pragma domain Domain
  156. //enable GPU instancing support
  157. #pragma multi_compile_instancing
  158. #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
  159. #pragma multi_compile _ LIGHTMAP_ON
  160. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  161. #pragma multi_compile _ DYNAMICLIGHTMAP_ON
  162. #pragma multi_compile_fragment _ SHADOWS_SHADOWMASK
  163. #pragma multi_compile_fragment _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
  164. // Setup DECALS_OFF so the shader stripper can remove variants
  165. #pragma multi_compile_fragment DECALS_OFF DECALS_3RT DECALS_4RT
  166. #pragma multi_compile_fragment _ DECAL_SURFACE_GRADIENT
  167. #pragma multi_compile_fragment _ RENDERING_LAYERS
  168. #define SHADERPASS SHADERPASS_GBUFFER
  169. #include "InTerra_HDRP_DefinedGlobalKeywords.hlsl"
  170. #include "InTerra_TerrainLitTemplate.hlsl"
  171. #include "InTerra_TerrainLit_Splatmap.hlsl"
  172. ENDHLSL
  173. }
  174. // Extracts information for lightmapping, GI (emission, albedo, ...)
  175. // This pass it not used during regular rendering.
  176. Pass
  177. {
  178. Name "META"
  179. Tags{ "LightMode" = "META" }
  180. Cull Off
  181. HLSLPROGRAM
  182. #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
  183. // All our shaders use same name for entry point
  184. #pragma vertex Vert
  185. #pragma fragment Frag
  186. //enable GPU instancing support
  187. #pragma multi_compile_instancing
  188. #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
  189. // No tessellation for Meta pass
  190. #undef TESSELLATION_ON
  191. // Lightmap memo
  192. // DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light,
  193. // both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON.
  194. #define SHADERPASS SHADERPASS_LIGHT_TRANSPORT
  195. #pragma shader_feature EDITOR_VISUALIZATION
  196. #include "InTerra_HDRP_DefinedGlobalKeywords.hlsl"
  197. #include "InTerra_TerrainLitTemplate.hlsl"
  198. #include "InTerra_TerrainLit_Splatmap.hlsl"
  199. ENDHLSL
  200. }
  201. Pass
  202. {
  203. Name "ShadowCaster"
  204. Tags{ "LightMode" = "ShadowCaster" }
  205. Cull[_CullMode]
  206. ZClip [_ZClip]
  207. ZWrite On
  208. ZTest LEqual
  209. ColorMask 0
  210. HLSLPROGRAM
  211. #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
  212. // All our shaders use same name for entry point
  213. #pragma vertex Vert
  214. #pragma fragment Frag
  215. #pragma hull Hull
  216. #pragma domain Domain
  217. //enable GPU instancing support
  218. #pragma multi_compile_instancing
  219. #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
  220. #define SHADERPASS SHADERPASS_SHADOWS
  221. #include "InTerra_HDRP_DefinedGlobalKeywords.hlsl"
  222. #include "InTerra_TerrainLitTemplate.hlsl"
  223. #include "InTerra_TerrainLit_Splatmap.hlsl"
  224. ENDHLSL
  225. }
  226. Pass
  227. {
  228. Name "DepthOnly"
  229. Tags{ "LightMode" = "DepthOnly" }
  230. Cull[_CullMode]
  231. // To be able to tag stencil with disableSSR information for forward
  232. Stencil
  233. {
  234. WriteMask [_StencilWriteMaskDepth]
  235. Ref [_StencilRefDepth]
  236. Comp Always
  237. Pass Replace
  238. }
  239. ZWrite On
  240. HLSLPROGRAM
  241. #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
  242. // All our shaders use same name for entry point
  243. #pragma vertex Vert
  244. #pragma fragment Frag
  245. #pragma hull Hull
  246. #pragma domain Domain
  247. //enable GPU instancing support
  248. #pragma multi_compile_instancing
  249. #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
  250. // In deferred, depth only pass don't output anything.
  251. // In forward it output the normal buffer
  252. #pragma multi_compile _ WRITE_NORMAL_BUFFER
  253. #pragma multi_compile _ WRITE_DECAL_BUFFER WRITE_RENDERING_LAYER
  254. #pragma multi_compile _ WRITE_MSAA_DEPTH
  255. #define SHADERPASS SHADERPASS_DEPTH_ONLY
  256. #include "InTerra_HDRP_DefinedGlobalKeywords.hlsl"
  257. #include "InTerra_TerrainLitTemplate.hlsl"
  258. #ifdef WRITE_NORMAL_BUFFER
  259. #if defined(_NORMALMAP)
  260. #define OVERRIDE_SPLAT_SAMPLER_NAME sampler_Normal0
  261. #elif defined(_MASKMAP)
  262. #define OVERRIDE_SPLAT_SAMPLER_NAME sampler_Mask0
  263. #endif
  264. #endif
  265. #include "InTerra_TerrainLit_Splatmap.hlsl"
  266. ENDHLSL
  267. }
  268. Pass
  269. {
  270. Name "Forward"
  271. Tags { "LightMode" = "Forward" } // This will be only for transparent object based on the RenderQueue index
  272. Stencil
  273. {
  274. WriteMask [_StencilWriteMask]
  275. Ref [_StencilRef]
  276. Comp Always
  277. Pass Replace
  278. }
  279. // In case of forward we want to have depth equal for opaque mesh
  280. ZTest [_ZTestDepthEqualForOpaque]
  281. ZWrite [_ZWrite]
  282. Cull [_CullMode]
  283. HLSLPROGRAM
  284. #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
  285. // All our shaders use same name for entry point
  286. #pragma vertex Vert
  287. #pragma fragment Frag
  288. #pragma hull Hull
  289. #pragma domain Domain
  290. //enable GPU instancing support
  291. #pragma multi_compile_instancing
  292. #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
  293. #pragma multi_compile _ LIGHTMAP_ON
  294. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  295. #pragma multi_compile _ DYNAMICLIGHTMAP_ON
  296. #pragma multi_compile_fragment _ SHADOWS_SHADOWMASK
  297. #pragma multi_compile_fragment _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
  298. #pragma multi_compile_fragment SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON
  299. // Setup DECALS_OFF so the shader stripper can remove variants
  300. #pragma multi_compile_fragment DECALS_OFF DECALS_3RT DECALS_4RT
  301. #pragma multi_compile_fragment _ DECAL_SURFACE_GRADIENT
  302. // Supported shadow modes per light type
  303. #pragma multi_compile_fragment PUNCTUAL_SHADOW_LOW PUNCTUAL_SHADOW_MEDIUM PUNCTUAL_SHADOW_HIGH
  304. #pragma multi_compile_fragment DIRECTIONAL_SHADOW_LOW DIRECTIONAL_SHADOW_MEDIUM DIRECTIONAL_SHADOW_HIGH
  305. #pragma multi_compile_fragment AREA_SHADOW_MEDIUM AREA_SHADOW_HIGH
  306. #pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST
  307. #define SHADERPASS SHADERPASS_FORWARD
  308. #include "InTerra_HDRP_DefinedGlobalKeywords.hlsl"
  309. #include "InTerra_TerrainLitTemplate.hlsl"
  310. #include "InTerra_TerrainLit_Splatmap.hlsl"
  311. ENDHLSL
  312. }
  313. Pass
  314. {
  315. Name "SceneSelectionPass"
  316. Tags { "LightMode" = "SceneSelectionPass" }
  317. Cull Off
  318. HLSLPROGRAM
  319. #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
  320. // All our shaders use same name for entry point
  321. #pragma vertex Vert
  322. #pragma fragment Frag
  323. //enable GPU instancing support
  324. #pragma multi_compile_instancing
  325. #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
  326. #undef TESSELLATION_ON
  327. #pragma editor_sync_compilation
  328. #define SHADERPASS SHADERPASS_DEPTH_ONLY
  329. #define SCENESELECTIONPASS
  330. #include "InTerra_HDRP_DefinedGlobalKeywords.hlsl"
  331. #include "InTerra_TerrainLitTemplate.hlsl"
  332. #include "InTerra_TerrainLit_Splatmap.hlsl"
  333. ENDHLSL
  334. }
  335. UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
  336. }
  337. SubShader
  338. {
  339. PackageRequirements { "com.unity.render-pipelines.high-definition":"[15.0.0,19.0.0]" }
  340. // This tags allow to use the shader replacement features
  341. Tags
  342. {
  343. "RenderPipeline" = "HDRenderPipeline"
  344. "RenderType" = "Opaque"
  345. "SplatCount" = "8"
  346. "MaskMapR" = "Metallic"
  347. "MaskMapG" = "AO"
  348. "MaskMapB" = "Height"
  349. "MaskMapA" = "Smoothness"
  350. "DiffuseA" = "Smoothness (becomes Density when Mask map is assigned)" // when MaskMap is disabled
  351. "DiffuseA_MaskMapUsed" = "Density" // when MaskMap is enabled
  352. "TerrainCompatible" = "True"
  353. }
  354. Pass
  355. {
  356. Name "IndirectDXR"
  357. Tags{ "LightMode" = "IndirectDXR" }
  358. HLSLPROGRAM
  359. #pragma only_renderers d3d11 xboxseries ps5
  360. #pragma raytracing surface_shader
  361. #undef TESSELLATION_ON
  362. #pragma multi_compile _ LIGHTMAP_ON
  363. #pragma multi_compile _ DYNAMICLIGHTMAP_ON
  364. #pragma multi_compile _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
  365. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  366. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  367. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
  368. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
  369. #define SHADERPASS SHADERPASS_RAYTRACING_INDIRECT
  370. // multi compile that allows us to strip the recursive code
  371. #pragma multi_compile _ MULTI_BOUNCE_INDIRECT
  372. #define SHADOW_LOW
  373. #include "InTerra_TerrainLitTemplateRayTracing.hlsl"
  374. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingIndirect.hlsl"
  375. ENDHLSL
  376. }
  377. Pass
  378. {
  379. Name "ForwardDXR"
  380. Tags{ "LightMode" = "ForwardDXR" }
  381. HLSLPROGRAM
  382. #pragma only_renderers d3d11 xboxseries ps5
  383. #pragma raytracing surface_shader
  384. #undef TESSELLATION_ON
  385. #pragma multi_compile _ DEBUG_DISPLAY
  386. #pragma multi_compile _ LIGHTMAP_ON
  387. #pragma multi_compile _ DYNAMICLIGHTMAP_ON
  388. #pragma multi_compile _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
  389. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  390. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  391. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
  392. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
  393. #define SHADERPASS SHADERPASS_RAYTRACING_FORWARD
  394. // multi compile that allows us to strip the recursive code
  395. #define SHADOW_LOW
  396. #include "InTerra_TerrainLitTemplateRayTracing.hlsl"
  397. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingForward.hlsl"
  398. ENDHLSL
  399. }
  400. Pass
  401. {
  402. Name "GBufferDXR"
  403. Tags{ "LightMode" = "GBufferDXR" }
  404. HLSLPROGRAM
  405. #pragma only_renderers d3d11 xboxseries ps5
  406. #pragma raytracing surface_shader
  407. #undef TESSELLATION_ON
  408. #pragma multi_compile _ LIGHTMAP_ON
  409. #pragma multi_compile _ DYNAMICLIGHTMAP_ON
  410. #pragma multi_compile _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
  411. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  412. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  413. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
  414. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
  415. #define SHADERPASS SHADERPASS_RAYTRACING_GBUFFER
  416. #pragma multi_compile _ MINIMAL_GBUFFER
  417. #include "InTerra_TerrainLitTemplateRayTracing.hlsl"
  418. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingGBuffer.hlsl"
  419. ENDHLSL
  420. }
  421. Pass
  422. {
  423. Name "VisibilityDXR"
  424. Tags{ "LightMode" = "VisibilityDXR" }
  425. HLSLPROGRAM
  426. #pragma only_renderers d3d11 xboxseries ps5
  427. #pragma raytracing surface_shader
  428. #undef TESSELLATION_ON
  429. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  430. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
  431. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
  432. #define SHADERPASS SHADERPASS_RAYTRACING_VISIBILITY
  433. #pragma multi_compile _ TRANSPARENT_COLOR_SHADOW
  434. #include "InTerra_TerrainLitTemplateRayTracing.hlsl"
  435. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingVisibility.hlsl"
  436. ENDHLSL
  437. }
  438. Pass
  439. {
  440. Name "DebugDXR"
  441. Tags{ "LightMode" = "DebugDXR" }
  442. HLSLPROGRAM
  443. #pragma only_renderers d3d11 xboxseries ps5
  444. #pragma raytracing surface_shader
  445. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  446. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
  447. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
  448. #define SHADERPASS SHADERPASS_RAYTRACING_DEBUG
  449. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingMacros.hlsl"
  450. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/ShaderVariablesRaytracing.hlsl"
  451. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
  452. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingIntersection.hlsl"
  453. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RayTracingCommon.hlsl"
  454. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingDebug.hlsl"
  455. ENDHLSL
  456. }
  457. Pass
  458. {
  459. Name "PathTracingDXR"
  460. Tags{ "LightMode" = "PathTracingDXR" }
  461. HLSLPROGRAM
  462. #pragma only_renderers d3d11 xboxseries ps5
  463. #pragma raytracing surface_shader
  464. #undef TESSELLATION_ON
  465. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  466. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
  467. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
  468. #define SHADERPASS SHADERPASS_PATH_TRACING
  469. #pragma multi_compile _ DEBUG_DISPLAY
  470. #pragma multi_compile _ SENSORSDK_OVERRIDE_REFLECTANCE
  471. #ifdef SENSORSDK_OVERRIDE_REFLECTANCE
  472. #define SENSORSDK_ENABLE_LIDAR
  473. #endif
  474. // This is just because it needs to be defined, shadow maps are not used.
  475. #define SHADOW_LOW
  476. // For all single-sided, refractive materials, we want to force a thin refraction model.
  477. #if !defined(_DOUBLESIDED_ON) && (defined(_REFRACTION_PLANE) || defined(_REFRACTION_SPHERE))
  478. #undef _REFRACTION_PLANE
  479. #undef _REFRACTION_SPHERE
  480. #define _REFRACTION_THIN
  481. #endif
  482. #include "InTerra_TerrainLitTemplateRayTracing.hlsl"
  483. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassPathTracing.hlsl"
  484. ENDHLSL
  485. }
  486. }
  487. Dependency "BaseMapShader" = "Hidden/InTerra/HDRP/TerrainLit_Basemap_2023_1"
  488. Dependency "BaseMapGenShader" = "Hidden/InTerra/HDRP/TerrainLit_BasemapGen"
  489. CustomEditor "InTerra.InTerra_TerrainShaderGUI"
  490. }