Spine-Common-URP.hlsl 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef SPINE_COMMON_URP_INCLUDED
  2. #define SPINE_COMMON_URP_INCLUDED
  3. #if defined(USE_FORWARD_PLUS) || defined(USE_CLUSTER_LIGHT_LOOP)
  4. #define IS_URP_14_OR_NEWER 1
  5. #define IS_URP_12_OR_NEWER 1
  6. #else
  7. #define IS_URP_14_OR_NEWER 0
  8. #ifdef UNIVERSAL_REALTIME_LIGHTS_INCLUDED
  9. #define IS_URP_12_OR_NEWER 1
  10. #else
  11. #define IS_URP_12_OR_NEWER 0
  12. #endif
  13. #endif
  14. #if IS_URP_14_OR_NEWER && !defined(_USE_WEBGL1_LIGHTS)
  15. #define IS_URP_15_OR_NEWER 1
  16. #include "Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolume.hlsl"
  17. #if defined(_APVWorldOffset)
  18. #define IS_URP_17_OR_NEWER 1
  19. #else
  20. #define IS_URP_17_OR_NEWER 0
  21. #endif
  22. #else
  23. #define IS_URP_15_OR_NEWER 0
  24. #endif
  25. #if defined(_WRITE_RENDERING_LAYERS) && IS_URP_14_OR_NEWER
  26. #define USE_WRITE_RENDERING_LAYERS
  27. #endif
  28. #if defined(_LIGHT_LAYERS) && IS_URP_12_OR_NEWER
  29. #define USE_LIGHT_LAYERS
  30. #endif
  31. #if defined(_LIGHT_COOKIES) && IS_URP_12_OR_NEWER
  32. #define USE_LIGHT_COOKIES
  33. #endif
  34. #ifdef USE_LIGHT_LAYERS
  35. uint GetMeshRenderingLayerBackwardsCompatible()
  36. {
  37. #if IS_URP_14_OR_NEWER
  38. return GetMeshRenderingLayer();
  39. #elif IS_URP_12_OR_NEWER
  40. return GetMeshRenderingLightLayer();
  41. #else
  42. return 0;
  43. #endif
  44. }
  45. #else
  46. uint GetMeshRenderingLayerBackwardsCompatible()
  47. {
  48. return 0;
  49. }
  50. #endif
  51. #if USE_FORWARD_PLUS
  52. // note: LIGHT_LOOP_BEGIN accesses inputData.normalizedScreenSpaceUV and inputData.positionWS.
  53. #define LIGHT_LOOP_BEGIN_SPINE LIGHT_LOOP_BEGIN
  54. #define LIGHT_LOOP_END_SPINE LIGHT_LOOP_END
  55. #elif !_USE_WEBGL1_LIGHTS
  56. #define LIGHT_LOOP_BEGIN_SPINE(lightCount) \
  57. for (uint lightIndex = 0u; lightIndex < lightCount; ++lightIndex) {
  58. #define LIGHT_LOOP_END_SPINE }
  59. #else
  60. // WebGL 1 doesn't support variable for loop conditions
  61. #define LIGHT_LOOP_BEGIN_SPINE(lightCount) \
  62. for (int lightIndex = 0; lightIndex < _WEBGL1_MAX_LIGHTS; ++lightIndex) { \
  63. if (lightIndex >= (int)lightCount) break;
  64. #define LIGHT_LOOP_END_SPINE }
  65. #endif
  66. #endif