123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- #ifndef UNIVERSAL_DEBUGGING2D_INCLUDED
- #define UNIVERSAL_DEBUGGING2D_INCLUDED
- #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/InputData2D.hlsl"
- #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/SurfaceData2D.hlsl"
- #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/DebuggingCommon.hlsl"
- #if defined(DEBUG_DISPLAY)
- #define SETUP_DEBUG_TEXTURE_DATA_2D(inputData, positionWS, texture) SetupDebugDataTexture(inputData, positionWS, texture##_TexelSize, texture##_MipInfo, GetMipCount(TEXTURE2D_ARGS(texture, sampler##texture)))
- #define SETUP_DEBUG_DATA_2D(inputData, positionWS) SetupDebugData(inputData, positionWS)
- void SetupDebugData(inout InputData2D inputData, float3 positionWS)
- {
- inputData.positionWS = positionWS;
- }
- void SetupDebugDataTexture(inout InputData2D inputData, float3 positionWS, float4 texelSize, float4 mipInfo, uint mipCount)
- {
- SetupDebugData(inputData, positionWS);
- inputData.texelSize = texelSize;
- inputData.mipInfo = mipInfo;
- inputData.mipCount = mipCount;
- }
- bool CalculateDebugColorMaterialSettings(in SurfaceData2D surfaceData, in InputData2D inputData, inout half4 debugColor)
- {
- switch(_DebugMaterialMode)
- {
- case DEBUGMATERIALMODE_NONE:
- {
- return false;
- }
- case DEBUGMATERIALMODE_ALBEDO:
- {
- debugColor = half4(surfaceData.albedo, 1);
- return true;
- }
- case DEBUGMATERIALMODE_ALPHA:
- {
- debugColor = half4(surfaceData.alpha.rrr, 1);
- return true;
- }
- case DEBUGMATERIALMODE_SPRITE_MASK:
- {
- debugColor = surfaceData.mask;
- return true;
- }
- case DEBUGMATERIALMODE_NORMAL_TANGENT_SPACE:
- case DEBUGMATERIALMODE_NORMAL_WORLD_SPACE:
- {
- debugColor = half4(surfaceData.normalTS, 1);
- return true;
- }
- default:
- {
- return TryGetDebugColorInvalidMode(debugColor);
- }
- }
- }
- bool CalculateDebugColorForRenderingSettings(in SurfaceData2D surfaceData, in InputData2D inputData, inout half4 debugColor)
- {
- if (CalculateColorForDebugSceneOverride(debugColor))
- {
- return true;
- }
- return TryGetDebugColorInvalidMode(debugColor);
- }
- bool CalculateDebugColorLightingSettings(inout SurfaceData2D surfaceData, inout InputData2D inputData, inout half4 debugColor)
- {
- switch(_DebugLightingMode)
- {
- case DEBUGLIGHTINGMODE_NONE:
- {
- return false;
- }
- case DEBUGLIGHTINGMODE_LIGHTING_WITHOUT_NORMAL_MAPS:
- case DEBUGLIGHTINGMODE_LIGHTING_WITH_NORMAL_MAPS:
- {
- surfaceData.albedo = 1;
- return false;
- }
- default:
- {
- return TryGetDebugColorInvalidMode(debugColor);
- }
- } // End of switch.
- }
- bool CalculateDebugColorValidationSettings(in SurfaceData2D surfaceData, in InputData2D inputData, inout half4 debugColor)
- {
- switch(_DebugMaterialValidationMode)
- {
- case DEBUGMATERIALVALIDATIONMODE_NONE:
- return false;
- case DEBUGMATERIALVALIDATIONMODE_ALBEDO:
- return CalculateValidationAlbedo(surfaceData.albedo, debugColor);
- default:
- return TryGetDebugColorInvalidMode(debugColor);
- }
- }
- bool CanDebugOverrideOutputColor(inout SurfaceData2D surfaceData, inout InputData2D inputData, inout half4 debugColor)
- {
- if (CalculateDebugColorMaterialSettings(surfaceData, inputData, debugColor))
- {
- return _DebugMaterialMode != DEBUGMATERIALMODE_SPRITE_MASK;
- }
- else if (CalculateDebugColorForRenderingSettings(surfaceData, inputData, debugColor))
- {
- return true;
- }
- else if (CalculateDebugColorLightingSettings(surfaceData, inputData, debugColor))
- {
- return true;
- }
- else if (CalculateDebugColorValidationSettings(surfaceData, inputData, debugColor))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- #else
- #define SETUP_DEBUG_TEXTURE_DATA_2D(inputData, positionWS, texture)
- #define SETUP_DEBUG_DATA_2D(inputData, positionWS)
- #endif
- #endif
|