InTerra_TerrainLit_Tessellation_2022_2.shader 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  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) 2022.2"
  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":"[14.0.0,14.99.99]" }
  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 _ DEBUG_DISPLAY
  160. #pragma multi_compile _ LIGHTMAP_ON
  161. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  162. #pragma multi_compile _ DYNAMICLIGHTMAP_ON
  163. #pragma multi_compile_fragment _ SHADOWS_SHADOWMASK
  164. #pragma multi_compile_fragment PROBE_VOLUMES_OFF PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
  165. // Setup DECALS_OFF so the shader stripper can remove variants
  166. #pragma multi_compile_fragment DECALS_OFF DECALS_3RT DECALS_4RT
  167. #pragma multi_compile_fragment _ DECAL_SURFACE_GRADIENT
  168. #pragma multi_compile_fragment _ LIGHT_LAYERS
  169. #define SHADERPASS SHADERPASS_GBUFFER
  170. #include "InTerra_HDRP_DefinedGlobalKeywords.hlsl"
  171. #include "InTerra_TerrainLitTemplate.hlsl"
  172. #include "InTerra_TerrainLit_Splatmap.hlsl"
  173. ENDHLSL
  174. }
  175. // Extracts information for lightmapping, GI (emission, albedo, ...)
  176. // This pass it not used during regular rendering.
  177. Pass
  178. {
  179. Name "META"
  180. Tags{ "LightMode" = "META" }
  181. Cull Off
  182. HLSLPROGRAM
  183. #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
  184. // All our shaders use same name for entry point
  185. #pragma vertex Vert
  186. #pragma fragment Frag
  187. //enable GPU instancing support
  188. #pragma multi_compile_instancing
  189. #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
  190. // No tessellation for Meta pass
  191. #undef TESSELLATION_ON
  192. // Lightmap memo
  193. // 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,
  194. // both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON.
  195. #define SHADERPASS SHADERPASS_LIGHT_TRANSPORT
  196. #pragma shader_feature EDITOR_VISUALIZATION
  197. #include "InTerra_HDRP_DefinedGlobalKeywords.hlsl"
  198. #include "InTerra_TerrainLitTemplate.hlsl"
  199. #include "InTerra_TerrainLit_Splatmap.hlsl"
  200. ENDHLSL
  201. }
  202. Pass
  203. {
  204. Name "ShadowCaster"
  205. Tags{ "LightMode" = "ShadowCaster" }
  206. Cull[_CullMode]
  207. ZClip [_ZClip]
  208. ZWrite On
  209. ZTest LEqual
  210. ColorMask 0
  211. HLSLPROGRAM
  212. #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
  213. // All our shaders use same name for entry point
  214. #pragma vertex Vert
  215. #pragma fragment Frag
  216. #pragma hull Hull
  217. #pragma domain Domain
  218. //enable GPU instancing support
  219. #pragma multi_compile_instancing
  220. #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
  221. #define SHADERPASS SHADERPASS_SHADOWS
  222. #include "InTerra_HDRP_DefinedGlobalKeywords.hlsl"
  223. #include "InTerra_TerrainLitTemplate.hlsl"
  224. #include "InTerra_TerrainLit_Splatmap.hlsl"
  225. ENDHLSL
  226. }
  227. Pass
  228. {
  229. Name "DepthOnly"
  230. Tags{ "LightMode" = "DepthOnly" }
  231. Cull[_CullMode]
  232. // To be able to tag stencil with disableSSR information for forward
  233. Stencil
  234. {
  235. WriteMask [_StencilWriteMaskDepth]
  236. Ref [_StencilRefDepth]
  237. Comp Always
  238. Pass Replace
  239. }
  240. ZWrite On
  241. HLSLPROGRAM
  242. #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
  243. // All our shaders use same name for entry point
  244. #pragma vertex Vert
  245. #pragma fragment Frag
  246. #pragma hull Hull
  247. #pragma domain Domain
  248. //enable GPU instancing support
  249. #pragma multi_compile_instancing
  250. #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
  251. // In deferred, depth only pass don't output anything.
  252. // In forward it output the normal buffer
  253. #pragma multi_compile _ WRITE_NORMAL_BUFFER
  254. #pragma multi_compile_fragment _ WRITE_DECAL_BUFFER
  255. #pragma multi_compile _ WRITE_MSAA_DEPTH
  256. #define SHADERPASS SHADERPASS_DEPTH_ONLY
  257. #include "InTerra_HDRP_DefinedGlobalKeywords.hlsl"
  258. #include "InTerra_TerrainLitTemplate.hlsl"
  259. #ifdef WRITE_NORMAL_BUFFER
  260. #if defined(_NORMALMAP)
  261. #define OVERRIDE_SPLAT_SAMPLER_NAME sampler_Normal0
  262. #elif defined(_MASKMAP)
  263. #define OVERRIDE_SPLAT_SAMPLER_NAME sampler_Mask0
  264. #endif
  265. #endif
  266. #include "InTerra_TerrainLit_Splatmap.hlsl"
  267. ENDHLSL
  268. }
  269. Pass
  270. {
  271. Name "Forward"
  272. Tags { "LightMode" = "Forward" } // This will be only for transparent object based on the RenderQueue index
  273. Stencil
  274. {
  275. WriteMask [_StencilWriteMask]
  276. Ref [_StencilRef]
  277. Comp Always
  278. Pass Replace
  279. }
  280. // In case of forward we want to have depth equal for opaque mesh
  281. ZTest [_ZTestDepthEqualForOpaque]
  282. ZWrite [_ZWrite]
  283. Cull [_CullMode]
  284. HLSLPROGRAM
  285. #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
  286. // All our shaders use same name for entry point
  287. #pragma vertex Vert
  288. #pragma fragment Frag
  289. #pragma hull Hull
  290. #pragma domain Domain
  291. //enable GPU instancing support
  292. #pragma multi_compile_instancing
  293. #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
  294. #pragma multi_compile _ DEBUG_DISPLAY
  295. #pragma multi_compile _ LIGHTMAP_ON
  296. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  297. #pragma multi_compile _ DYNAMICLIGHTMAP_ON
  298. #pragma multi_compile_fragment _ SHADOWS_SHADOWMASK
  299. #pragma multi_compile_fragment PROBE_VOLUMES_OFF PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
  300. #pragma multi_compile_fragment SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON
  301. // Setup DECALS_OFF so the shader stripper can remove variants
  302. #pragma multi_compile_fragment DECALS_OFF DECALS_3RT DECALS_4RT
  303. #pragma multi_compile_fragment _ DECAL_SURFACE_GRADIENT
  304. // Supported shadow modes per light type
  305. #pragma multi_compile_fragment SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH
  306. #pragma multi_compile_fragment AREA_SHADOW_MEDIUM AREA_SHADOW_HIGH
  307. #pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST
  308. #define SHADERPASS SHADERPASS_FORWARD
  309. #include "InTerra_HDRP_DefinedGlobalKeywords.hlsl"
  310. #include "InTerra_TerrainLitTemplate.hlsl"
  311. #include "InTerra_TerrainLit_Splatmap.hlsl"
  312. ENDHLSL
  313. }
  314. Pass
  315. {
  316. Name "SceneSelectionPass"
  317. Tags { "LightMode" = "SceneSelectionPass" }
  318. Cull Off
  319. HLSLPROGRAM
  320. #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
  321. // All our shaders use same name for entry point
  322. #pragma vertex Vert
  323. #pragma fragment Frag
  324. //enable GPU instancing support
  325. #pragma multi_compile_instancing
  326. #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
  327. #undef TESSELLATION_ON
  328. #pragma editor_sync_compilation
  329. #define SHADERPASS SHADERPASS_DEPTH_ONLY
  330. #define SCENESELECTIONPASS
  331. #include "InTerra_HDRP_DefinedGlobalKeywords.hlsl"
  332. #include "InTerra_TerrainLitTemplate.hlsl"
  333. #include "InTerra_TerrainLit_Splatmap.hlsl"
  334. ENDHLSL
  335. }
  336. UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
  337. }
  338. SubShader
  339. {
  340. PackageRequirements { "com.unity.render-pipelines.high-definition":"[14.0.0,16.0.0]" }
  341. // This tags allow to use the shader replacement features
  342. Tags
  343. {
  344. "RenderPipeline" = "HDRenderPipeline"
  345. "RenderType" = "Opaque"
  346. "SplatCount" = "8"
  347. "MaskMapR" = "Metallic"
  348. "MaskMapG" = "AO"
  349. "MaskMapB" = "Height"
  350. "MaskMapA" = "Smoothness"
  351. "DiffuseA" = "Smoothness (becomes Density when Mask map is assigned)" // when MaskMap is disabled
  352. "DiffuseA_MaskMapUsed" = "Density" // when MaskMap is enabled
  353. "TerrainCompatible" = "True"
  354. }
  355. Pass
  356. {
  357. Name "IndirectDXR"
  358. Tags{ "LightMode" = "IndirectDXR" }
  359. HLSLPROGRAM
  360. #pragma only_renderers d3d11 xboxseries ps5
  361. #pragma raytracing surface_shader
  362. #undef TESSELLATION_ON
  363. #pragma multi_compile _ DEBUG_DISPLAY
  364. #pragma multi_compile _ LIGHTMAP_ON
  365. #pragma multi_compile _ DYNAMICLIGHTMAP_ON
  366. #pragma multi_compile PROBE_VOLUMES_OFF PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
  367. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  368. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  369. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
  370. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
  371. #define SHADERPASS SHADERPASS_RAYTRACING_INDIRECT
  372. // multi compile that allows us to strip the recursive code
  373. #pragma multi_compile _ MULTI_BOUNCE_INDIRECT
  374. #define SHADOW_LOW
  375. #include "InTerra_HDRP_DefinedGlobalKeywords.hlsl"
  376. #undef _TERRAIN_PARALLAX
  377. #undef PARALLAX
  378. #include "InTerra_TerrainLitTemplateRayTracing.hlsl"
  379. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingIndirect.hlsl"
  380. ENDHLSL
  381. }
  382. Pass
  383. {
  384. Name "ForwardDXR"
  385. Tags{ "LightMode" = "ForwardDXR" }
  386. HLSLPROGRAM
  387. #pragma only_renderers d3d11 xboxseries ps5
  388. #pragma raytracing surface_shader
  389. #undef TESSELLATION_ON
  390. #pragma multi_compile _ DEBUG_DISPLAY
  391. #pragma multi_compile _ LIGHTMAP_ON
  392. #pragma multi_compile _ DYNAMICLIGHTMAP_ON
  393. #pragma multi_compile PROBE_VOLUMES_OFF PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
  394. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  395. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  396. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
  397. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
  398. #define SHADERPASS SHADERPASS_RAYTRACING_FORWARD
  399. // multi compile that allows us to strip the recursive code
  400. #include "InTerra_HDRP_DefinedGlobalKeywords.hlsl"
  401. #undef _TERRAIN_PARALLAX
  402. #undef PARALLAX
  403. #define SHADOW_LOW
  404. #include "InTerra_TerrainLitTemplateRayTracing.hlsl"
  405. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingForward.hlsl"
  406. ENDHLSL
  407. }
  408. Pass
  409. {
  410. Name "GBufferDXR"
  411. Tags{ "LightMode" = "GBufferDXR" }
  412. HLSLPROGRAM
  413. #pragma only_renderers d3d11 xboxseries ps5
  414. #pragma raytracing surface_shader
  415. #undef TESSELLATION_ON
  416. #pragma multi_compile _ DEBUG_DISPLAY
  417. #pragma multi_compile _ LIGHTMAP_ON
  418. #pragma multi_compile _ DYNAMICLIGHTMAP_ON
  419. #pragma multi_compile PROBE_VOLUMES_OFF PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
  420. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  421. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  422. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
  423. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
  424. #define SHADERPASS SHADERPASS_RAYTRACING_GBUFFER
  425. #pragma multi_compile _ MINIMAL_GBUFFER
  426. #include "InTerra_HDRP_DefinedGlobalKeywords.hlsl"
  427. #undef _TERRAIN_PARALLAX
  428. #undef PARALLAX
  429. #include "InTerra_TerrainLitTemplateRayTracing.hlsl"
  430. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingGBuffer.hlsl"
  431. ENDHLSL
  432. }
  433. Pass
  434. {
  435. Name "VisibilityDXR"
  436. Tags{ "LightMode" = "VisibilityDXR" }
  437. HLSLPROGRAM
  438. #pragma only_renderers d3d11 xboxseries ps5
  439. #pragma raytracing surface_shader
  440. #undef TESSELLATION_ON
  441. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  442. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
  443. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
  444. #define SHADERPASS SHADERPASS_RAYTRACING_VISIBILITY
  445. #pragma multi_compile _ TRANSPARENT_COLOR_SHADOW
  446. #include "InTerra_HDRP_DefinedGlobalKeywords.hlsl"
  447. #undef _TERRAIN_PARALLAX
  448. #undef PARALLAX
  449. #include "InTerra_TerrainLitTemplateRayTracing.hlsl"
  450. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingVisibility.hlsl"
  451. ENDHLSL
  452. }
  453. Pass
  454. {
  455. Name "DebugDXR"
  456. Tags{ "LightMode" = "DebugDXR" }
  457. HLSLPROGRAM
  458. #pragma only_renderers d3d11 xboxseries ps5
  459. #pragma raytracing surface_shader
  460. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  461. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
  462. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
  463. #define SHADERPASS SHADERPASS_RAYTRACING_DEBUG
  464. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingMacros.hlsl"
  465. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/ShaderVariablesRaytracing.hlsl"
  466. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
  467. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingIntersection.hlsl"
  468. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RayTracingCommon.hlsl"
  469. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingDebug.hlsl"
  470. ENDHLSL
  471. }
  472. Pass
  473. {
  474. Name "PathTracingDXR"
  475. Tags{ "LightMode" = "PathTracingDXR" }
  476. HLSLPROGRAM
  477. #pragma only_renderers d3d11 xboxseries ps5
  478. #pragma raytracing surface_shader
  479. #undef TESSELLATION_ON
  480. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  481. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
  482. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
  483. #define SHADERPASS SHADERPASS_PATH_TRACING
  484. #pragma multi_compile _ DEBUG_DISPLAY
  485. #pragma multi_compile _ SENSORSDK_OVERRIDE_REFLECTANCE
  486. #ifdef SENSORSDK_OVERRIDE_REFLECTANCE
  487. #define SENSORSDK_ENABLE_LIDAR
  488. #endif
  489. // This is just because it needs to be defined, shadow maps are not used.
  490. #define SHADOW_LOW
  491. // For all single-sided, refractive materials, we want to force a thin refraction model.
  492. #if !defined(_DOUBLESIDED_ON) && (defined(_REFRACTION_PLANE) || defined(_REFRACTION_SPHERE))
  493. #undef _REFRACTION_PLANE
  494. #undef _REFRACTION_SPHERE
  495. #define _REFRACTION_THIN
  496. #endif
  497. #include "InTerra_HDRP_DefinedGlobalKeywords.hlsl"
  498. #undef _TERRAIN_PARALLAX
  499. #undef PARALLAX
  500. #include "InTerra_TerrainLitTemplateRayTracing.hlsl"
  501. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassPathTracing.hlsl"
  502. ENDHLSL
  503. }
  504. }
  505. Dependency "BaseMapShader" = "Hidden/InTerra/HDRP/TerrainLit_Basemap_2022_2"
  506. Dependency "BaseMapGenShader" = "Hidden/InTerra/HDRP/TerrainLit_BasemapGen"
  507. CustomEditor "InTerra.InTerra_TerrainShaderGUI"
  508. }