InTerra_TerrainLitTemplate.hlsl 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // NOTE! Almost all code in this file and the file InTerra_TerrainLitData is written by Unity and are used because there is no longer the possibility to use the Standard Shader and there would be need to write basically the same Template/LitData for InTerra Shader Functions.
  2. #define HAVE_MESH_MODIFICATION
  3. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  4. #ifdef TESSELLATION_ON
  5. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl"
  6. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl"
  7. #endif
  8. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
  9. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
  10. #if SHADERPASS == SHADERPASS_GBUFFER && !defined(DEBUG_DISPLAY)
  11. // When we have alpha test, we will force a depth prepass so we always bypass the clip instruction in the GBuffer
  12. // Don't do it with debug display mode as it is possible there is no depth prepass in this case
  13. #define SHADERPASS_GBUFFER_BYPASS_ALPHA_TEST
  14. #endif
  15. #if SHADERPASS == SHADERPASS_FORWARD && !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(DEBUG_DISPLAY)
  16. // In case of opaque we don't want to perform the alpha test, it is done in depth prepass and we use depth equal for ztest (setup from UI)
  17. // Don't do it with debug display mode as it is possible there is no depth prepass in this case
  18. #define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST
  19. #endif
  20. #if defined(_ALPHATEST_ON)
  21. #define ATTRIBUTES_NEED_TEXCOORD0
  22. #define VARYINGS_NEED_TEXCOORD0
  23. #endif
  24. #if defined(_TERRAIN_NORMAL_IN_MASK)
  25. #undef _NORMALMAP
  26. #define _NORMALMAP
  27. #endif
  28. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
  29. #ifdef DEBUG_DISPLAY
  30. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
  31. #endif
  32. #ifdef SCENESELECTIONPASS
  33. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/PickingSpaceTransforms.hlsl"
  34. #endif
  35. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
  36. #if SHADERPASS == SHADERPASS_FORWARD
  37. // The light loop (or lighting architecture) is in charge to:
  38. // - Define light list
  39. // - Define the light loop
  40. // - Setup the constant/data
  41. // - Do the reflection hierarchy
  42. // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong))
  43. #define HAS_LIGHTLOOP
  44. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl"
  45. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl"
  46. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
  47. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl"
  48. #else
  49. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
  50. #endif
  51. #if SHADERPASS != SHADERPASS_DEPTH_ONLY || defined(WRITE_NORMAL_BUFFER) || defined(TESSELLATION_ON)
  52. #define ATTRIBUTES_NEED_NORMAL
  53. #define ATTRIBUTES_NEED_TEXCOORD0
  54. #define ATTRIBUTES_NEED_TANGENT // will be filled by ApplyMeshModification()
  55. #if SHADERPASS == SHADERPASS_LIGHT_TRANSPORT
  56. #define ATTRIBUTES_NEED_TEXCOORD1
  57. #define ATTRIBUTES_NEED_TEXCOORD2
  58. #ifdef EDITOR_VISUALIZATION
  59. #define ATTRIBUTES_NEED_TEXCOORD3
  60. #define VARYINGS_NEED_TEXCOORD0
  61. #define VARYINGS_NEED_TEXCOORD1
  62. #define VARYINGS_NEED_TEXCOORD2
  63. #define VARYINGS_NEED_TEXCOORD3
  64. #endif
  65. #endif
  66. // Varying - Use for pixel shader
  67. // This second set of define allow to say which varyings will be output in the vertex (no more tesselation)
  68. #define VARYINGS_NEED_POSITION_WS
  69. #define VARYINGS_NEED_TANGENT_TO_WORLD
  70. #define VARYINGS_NEED_TEXCOORD0
  71. #endif
  72. #if defined(UNITY_INSTANCING_ENABLED) && defined(_TERRAIN_INSTANCED_PERPIXEL_NORMAL)
  73. #define ENABLE_TERRAIN_PERPIXEL_NORMAL
  74. #endif
  75. #ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
  76. // With per-pixel normal enabled, tangent space is created in the pixel shader.
  77. #undef ATTRIBUTES_NEED_NORMAL
  78. #undef ATTRIBUTES_NEED_TANGENT
  79. #undef VARYINGS_NEED_TANGENT_TO_WORLD
  80. #endif
  81. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VaryingMesh.hlsl"
  82. #include "InTerra_TerrainLitData.hlsl"
  83. #if SHADERPASS == SHADERPASS_GBUFFER
  84. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl"
  85. #elif SHADERPASS == SHADERPASS_LIGHT_TRANSPORT
  86. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl"
  87. #elif SHADERPASS == SHADERPASS_SHADOWS || SHADERPASS == SHADERPASS_DEPTH_ONLY
  88. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl"
  89. #elif SHADERPASS == SHADERPASS_FORWARD
  90. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl"
  91. #endif