Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #ifndef UNIVERSAL_DEBUGGING2D_INCLUDED
  2. #define UNIVERSAL_DEBUGGING2D_INCLUDED
  3. #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/InputData2D.hlsl"
  4. #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/SurfaceData2D.hlsl"
  5. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/DebuggingCommon.hlsl"
  6. #if defined(DEBUG_DISPLAY)
  7. #define SETUP_DEBUG_TEXTURE_DATA_2D(inputData, positionWS, positionCS, texture) SetupDebugDataTexture(inputData, positionWS, positionCS, texture##_TexelSize, texture##_MipInfo, texture##_StreamInfo, GetMipCount(TEXTURE2D_ARGS(texture, sampler##texture)))
  8. #define SETUP_DEBUG_DATA_2D(inputData, positionWS, positionCS) SetupDebugData(inputData, positionWS, positionCS)
  9. void SetupDebugData(inout InputData2D inputData, float3 positionWS, float4 positionCS)
  10. {
  11. inputData.positionWS = positionWS;
  12. inputData.positionCS = positionCS;
  13. }
  14. void SetupDebugDataTexture(inout InputData2D inputData, float3 positionWS, float4 positionCS, float4 texelSize, float4 mipInfo, float4 streamInfo, uint mipCount)
  15. {
  16. SetupDebugData(inputData, positionWS, positionCS);
  17. inputData.texelSize = texelSize;
  18. inputData.mipInfo = mipInfo;
  19. inputData.streamInfo = streamInfo;
  20. inputData.mipCount = mipCount;
  21. }
  22. bool CalculateDebugColorMaterialSettings(in SurfaceData2D surfaceData, in InputData2D inputData, inout half4 debugColor)
  23. {
  24. switch(_DebugMaterialMode)
  25. {
  26. case DEBUGMATERIALMODE_NONE:
  27. {
  28. return false;
  29. }
  30. case DEBUGMATERIALMODE_ALBEDO:
  31. {
  32. debugColor = half4(surfaceData.albedo, 1);
  33. return true;
  34. }
  35. case DEBUGMATERIALMODE_ALPHA:
  36. {
  37. debugColor = half4(surfaceData.alpha.rrr, 1);
  38. return true;
  39. }
  40. case DEBUGMATERIALMODE_SPRITE_MASK:
  41. {
  42. debugColor = surfaceData.mask;
  43. return true;
  44. }
  45. case DEBUGMATERIALMODE_NORMAL_TANGENT_SPACE:
  46. case DEBUGMATERIALMODE_NORMAL_WORLD_SPACE:
  47. {
  48. debugColor = half4(surfaceData.normalTS, 1);
  49. return true;
  50. }
  51. default:
  52. {
  53. return TryGetDebugColorInvalidMode(debugColor);
  54. }
  55. }
  56. }
  57. bool CalculateColorForDebugMipmapStreaming(in SurfaceData2D surfaceData, in InputData2D inputData, inout half4 debugColor)
  58. {
  59. return CalculateColorForDebugMipmapStreaming(inputData.mipCount, uint2(inputData.positionCS.xy), inputData.texelSize, inputData.uv, inputData.mipInfo, inputData.streamInfo, surfaceData.albedo, debugColor);
  60. }
  61. bool CalculateDebugColorForRenderingSettings(in SurfaceData2D surfaceData, in InputData2D inputData, inout half4 debugColor)
  62. {
  63. if (CalculateColorForDebugSceneOverride(debugColor))
  64. {
  65. return true;
  66. }
  67. else if (CalculateColorForDebugMipmapStreaming(surfaceData, inputData, debugColor))
  68. {
  69. return true;
  70. }
  71. return false;
  72. }
  73. bool CalculateDebugColorLightingSettings(inout SurfaceData2D surfaceData, inout InputData2D inputData, inout half4 debugColor)
  74. {
  75. switch(_DebugLightingMode)
  76. {
  77. case DEBUGLIGHTINGMODE_NONE:
  78. {
  79. return false;
  80. }
  81. case DEBUGLIGHTINGMODE_LIGHTING_WITHOUT_NORMAL_MAPS:
  82. case DEBUGLIGHTINGMODE_LIGHTING_WITH_NORMAL_MAPS:
  83. {
  84. surfaceData.albedo = 1;
  85. return false;
  86. }
  87. default:
  88. {
  89. return TryGetDebugColorInvalidMode(debugColor);
  90. }
  91. } // End of switch.
  92. }
  93. bool CalculateDebugColorValidationSettings(in SurfaceData2D surfaceData, in InputData2D inputData, inout half4 debugColor)
  94. {
  95. switch(_DebugMaterialValidationMode)
  96. {
  97. case DEBUGMATERIALVALIDATIONMODE_NONE:
  98. return false;
  99. case DEBUGMATERIALVALIDATIONMODE_ALBEDO:
  100. return CalculateValidationAlbedo(surfaceData.albedo, debugColor);
  101. default:
  102. return TryGetDebugColorInvalidMode(debugColor);
  103. }
  104. }
  105. bool CanDebugOverrideOutputColor(inout SurfaceData2D surfaceData, inout InputData2D inputData, inout half4 debugColor)
  106. {
  107. if (CalculateDebugColorMaterialSettings(surfaceData, inputData, debugColor))
  108. {
  109. return _DebugMaterialMode != DEBUGMATERIALMODE_SPRITE_MASK;
  110. }
  111. else if (CalculateDebugColorForRenderingSettings(surfaceData, inputData, debugColor))
  112. {
  113. return true;
  114. }
  115. else if (CalculateDebugColorLightingSettings(surfaceData, inputData, debugColor))
  116. {
  117. return true;
  118. }
  119. else if (CalculateDebugColorValidationSettings(surfaceData, inputData, debugColor))
  120. {
  121. return true;
  122. }
  123. else
  124. {
  125. return false;
  126. }
  127. }
  128. #else
  129. #define SETUP_DEBUG_TEXTURE_DATA_2D(inputData, positionWS, positionCS, texture)
  130. #define SETUP_DEBUG_DATA_2D(inputData, positionWS, positionCS)
  131. #endif
  132. #endif