Initial project commit

This commit is contained in:
2026-01-08 16:50:20 +00:00
commit f0c5a8b267
29596 changed files with 4861782 additions and 0 deletions

View File

@@ -0,0 +1,325 @@
using System;
namespace UnityEngine.Rendering.Universal
{
#region Material Settings
/// <summary>
/// Debug material modes.
/// </summary>
[GenerateHLSL]
public enum DebugMaterialMode
{
/// <summary>No material debug.</summary>
None,
/// <summary>Display material albedo.</summary>
Albedo,
/// <summary>Display material specular.</summary>
Specular,
/// <summary>Display material alpha.</summary>
Alpha,
/// <summary>Display material smoothness.</summary>
Smoothness,
/// <summary>Display material ambient occlusion.</summary>
AmbientOcclusion,
/// <summary>Display material emission.</summary>
Emission,
/// <summary>Display material normal (world space).</summary>
NormalWorldSpace,
/// <summary>Display material normal (tangent space).</summary>
NormalTangentSpace,
/// <summary>Display evaluated lighting complexity.</summary>
LightingComplexity,
/// <summary>Display material metallic.</summary>
Metallic,
/// <summary>Display material sprite mask.</summary>
SpriteMask,
/// <summary>Display rendering layer masks.</summary>
RenderingLayerMasks,
}
/// <summary>
/// Debug mode for displaying vertex attributes interpolated from vertex to pixel shader.
/// </summary>
[GenerateHLSL]
public enum DebugVertexAttributeMode
{
/// <summary>No vertex attribute debug.</summary>
None,
/// <summary>Display texture coordinate 0.</summary>
Texcoord0,
/// <summary>Display texture coordinate 1.</summary>
Texcoord1,
/// <summary>Display texture coordinate 2.</summary>
Texcoord2,
/// <summary>Display texture coordinate 3.</summary>
Texcoord3,
/// <summary>Display vertex color.</summary>
Color,
/// <summary>Display tangent.</summary>
Tangent,
/// <summary>Display normal.</summary>
Normal,
}
/// <summary>
/// Debug mode for validating out-of-range values of different material channels.
/// </summary>
[GenerateHLSL]
public enum DebugMaterialValidationMode
{
/// <summary>No material debug validation override.</summary>
None,
/// <summary>Validate albedo values according to validation settings.</summary>
Albedo,
/// <summary>Validate metallic values according to validation settings.</summary>
Metallic
}
#endregion
#region Rendering Settings
/// <summary>
/// Debug mode for displaying intermediate render targets.
/// </summary>
[GenerateHLSL]
public enum DebugFullScreenMode
{
/// <summary>No intermediate render target displayed.</summary>
None,
/// <summary>Display depth buffer contents.</summary>
Depth,
// NOTE: we could also add (dir, mag) format.
/// <summary>Display depth buffer contents.</summary>
[InspectorName("Motion Vector (100x, normalized)")]
MotionVector,
/// <summary>Display the shadow map from additional lights.</summary>
AdditionalLightsShadowMap,
/// <summary>Display the main shadow map.</summary>
MainLightShadowMap,
/// <summary> Display the light cookie atlas for additional lights.</summary>
AdditionalLightsCookieAtlas,
/// <summary>
/// Display the reflection probe atlas used for the Forward+ rendering path.
/// </summary>
ReflectionProbeAtlas,
/// <summary>
/// Displays the active STP debug view.
/// </summary>
STP,
}
/// <summary>
/// Debug mode that overrides how the renderer behaves.
/// </summary>
[GenerateHLSL]
public enum DebugSceneOverrideMode
{
/// <summary>No debug override.</summary>
None,
/// <summary>Visualize overdraw by drawing geometry using a semitransparent material. Areas that look opaque contain more overdraw.</summary>
Overdraw,
/// <summary>Render using wireframe only.</summary>
Wireframe,
/// <summary>Render using a constant fill color and wireframe.</summary>
SolidWireframe,
/// <summary>Render shaded geometry in addition to wireframe.</summary>
ShadedWireframe,
}
/// <summary>
/// Debug mode of the overdraw
/// </summary>
public enum DebugOverdrawMode
{
/// <summary>No overdraw debug mode.</summary>
None,
/// <summary>Debug overdraw of opaque only.</summary>
Opaque,
/// <summary>Debug overdraw of transparent only.</summary>
Transparent,
/// <summary>Debug overdraw of everything only.</summary>
All
}
/// <summary>
/// Debug mode for texture mipmap streaming.
/// </summary>
// Keep in sync with DebugMipMapMode in HDRP's Runtime/Debug/MipMapDebug.cs
[GenerateHLSL]
public enum DebugMipInfoMode
{
/// <summary>No mipmap debug.</summary>
None,
/// <summary>Display savings and shortage due to streaming.</summary>
MipStreamingPerformance,
/// <summary>Display the streaming status of materials and textures.</summary>
MipStreamingStatus,
/// <summary>Highlight recently streamed data.</summary>
MipStreamingActivity,
/// <summary>Display streaming priorities as set up when importing.</summary>
MipStreamingPriority,
/// <summary>Display the amount of uploaded mip levels.</summary>
MipCount,
/// <summary>Visualize the pixel density for the highest-resolution uploaded mip level from the camera's point-of-view.</summary>
MipRatio,
}
/// <summary>
/// Aggregation mode for texture mipmap streaming debugging information.
/// </summary>
// Keep in sync with DebugMipMapStatusMode in HDRP's Runtime/Debug/MipMapDebug.cs
[GenerateHLSL]
public enum DebugMipMapStatusMode
{
/// <summary>Show debug information aggregated per material.</summary>
Material,
/// <summary>Show debug information for the selected texture slot.</summary>
Texture,
}
/// <summary>
/// Terrain layer for texture mipmap streaming debugging.
/// </summary>
[GenerateHLSL]
public enum DebugMipMapModeTerrainTexture
{
/// <summary>Control texture debug.</summary>
Control,
/// <summary>Layer 0 diffuse texture debug.</summary>
[InspectorName("Layer 0 - Diffuse")] Layer0,
/// <summary>Layer 1 diffuse texture debug.</summary>
[InspectorName("Layer 1 - Diffuse")] Layer1,
/// <summary>Layer 2 diffuse texture debug.</summary>
[InspectorName("Layer 2 - Diffuse")] Layer2,
/// <summary>Layer 3 diffuse texture debug.</summary>
[InspectorName("Layer 3 - Diffuse")] Layer3,
}
/// <summary>
/// Mode that controls if post-processing is allowed.
/// </summary>
/// <remarks>
/// When "Auto" is used, post-processing can be either on or off, depending on other active debug modes.
/// </remarks>
[GenerateHLSL]
public enum DebugPostProcessingMode
{
/// <summary>Post-processing disabled.</summary>
Disabled,
/// <summary>Post-processing is either on or off, depending on other debug modes.</summary>
Auto,
/// <summary>Post-processing enabled.</summary>
Enabled
};
/// <summary>
/// Debug modes for validating illegal output values.
/// </summary>
[GenerateHLSL]
public enum DebugValidationMode
{
/// <summary>No validation.</summary>
None,
/// <summary>Highlight all pixels containing NaN (not a number), infinite or negative values.</summary>
[InspectorName("Highlight NaN, Inf and Negative Values")]
HighlightNanInfNegative,
/// <summary>Highlight all pixels with values outside the specified range.</summary>
[InspectorName("Highlight Values Outside Range")]
HighlightOutsideOfRange
}
/// <summary>
/// The channels used by DebugValidationMode.HighlightOutsideOfRange.
/// </summary>
/// <remarks>
/// When "RGB" is used, the pixel's RGB value is first converted to a luminance value.
/// Individual channels (R, G, B, and A) are tested individually against the range.
/// </remarks>
[GenerateHLSL]
public enum PixelValidationChannels
{
/// <summary>Use luminance calculated from RGB channels as the value to validate.</summary>
RGB,
/// <summary>Validate the red channel value.</summary>
R,
/// <summary>Validate the green channel value.</summary>
G,
/// <summary>Validate the blue channel value.</summary>
B,
/// <summary>Validate the alpha channel value.</summary>
A
}
#endregion
#region Lighting settings
/// <summary>
/// Debug modes for lighting.
/// </summary>
[GenerateHLSL]
public enum DebugLightingMode
{
/// <summary>No lighting debug mode.</summary>
None,
/// <summary>Display shadow cascades using different colors.</summary>
ShadowCascades,
/// <summary>Display lighting result without applying normal maps.</summary>
LightingWithoutNormalMaps,
/// <summary>Display lighting result (including normal maps).</summary>
LightingWithNormalMaps,
/// <summary>Display only reflections.</summary>
Reflections,
/// <summary>Display only reflections with smoothness.</summary>
ReflectionsWithSmoothness,
/// <summary>Display the indirect irradiance</summary>
GlobalIllumination,
}
/// <summary>
/// HDR debug mode.
/// </summary>
[GenerateHLSL]
public enum HDRDebugMode
{
/// <summary>No HDR debugging.</summary>
None,
/// <summary>Gamut view: show the gamuts and what part of the gamut the image shows.</summary>
GamutView,
/// <summary>Gamut clip: show what part of the Scene is covered by the Rec709 gamut and which parts are in the Rec2020 gamut.</summary>
GamutClip,
/// <summary>If the luminance value exceeds the paper white value, show the exceeding value in colors between yellow and red. Shows luminance values otherwise.</summary>
ValuesAbovePaperWhite
}
/// <summary>
/// Debug mode that allows selective disabling of individual lighting components.
/// </summary>
[GenerateHLSL, Flags]
public enum DebugLightingFeatureFlags
{
/// <summary>The debug mode is not active.</summary>
None,
/// <summary>Display contribution from global illumination.</summary>
GlobalIllumination = 0x1,
/// <summary>Display contribution from the main light.</summary>
MainLight = 0x2,
/// <summary>Display contribution from additional lights.</summary>
AdditionalLights = 0x4,
/// <summary>Display contribution from vertex lighting.</summary>
VertexLighting = 0x8,
/// <summary>Display contribution from emissive objects.</summary>
Emission = 0x10,
/// <summary>Display contribution from ambient occlusion.</summary>
AmbientOcclusion = 0x20,
}
#endregion
}

View File

@@ -0,0 +1,144 @@
//
// This file was automatically generated. Please don't edit by hand. Execute Editor command [ Edit > Rendering > Generate Shader Includes ] instead
//
#ifndef DEBUGVIEWENUMS_CS_HLSL
#define DEBUGVIEWENUMS_CS_HLSL
//
// UnityEngine.Rendering.Universal.DebugFullScreenMode: static fields
//
#define DEBUGFULLSCREENMODE_NONE (0)
#define DEBUGFULLSCREENMODE_DEPTH (1)
#define DEBUGFULLSCREENMODE_MOTION_VECTOR (2)
#define DEBUGFULLSCREENMODE_ADDITIONAL_LIGHTS_SHADOW_MAP (3)
#define DEBUGFULLSCREENMODE_MAIN_LIGHT_SHADOW_MAP (4)
#define DEBUGFULLSCREENMODE_ADDITIONAL_LIGHTS_COOKIE_ATLAS (5)
#define DEBUGFULLSCREENMODE_REFLECTION_PROBE_ATLAS (6)
#define DEBUGFULLSCREENMODE_STP (7)
//
// UnityEngine.Rendering.Universal.DebugLightingFeatureFlags: static fields
//
#define DEBUGLIGHTINGFEATUREFLAGS_NONE (0)
#define DEBUGLIGHTINGFEATUREFLAGS_GLOBAL_ILLUMINATION (1)
#define DEBUGLIGHTINGFEATUREFLAGS_MAIN_LIGHT (2)
#define DEBUGLIGHTINGFEATUREFLAGS_ADDITIONAL_LIGHTS (4)
#define DEBUGLIGHTINGFEATUREFLAGS_VERTEX_LIGHTING (8)
#define DEBUGLIGHTINGFEATUREFLAGS_EMISSION (16)
#define DEBUGLIGHTINGFEATUREFLAGS_AMBIENT_OCCLUSION (32)
//
// UnityEngine.Rendering.Universal.DebugLightingMode: static fields
//
#define DEBUGLIGHTINGMODE_NONE (0)
#define DEBUGLIGHTINGMODE_SHADOW_CASCADES (1)
#define DEBUGLIGHTINGMODE_LIGHTING_WITHOUT_NORMAL_MAPS (2)
#define DEBUGLIGHTINGMODE_LIGHTING_WITH_NORMAL_MAPS (3)
#define DEBUGLIGHTINGMODE_REFLECTIONS (4)
#define DEBUGLIGHTINGMODE_REFLECTIONS_WITH_SMOOTHNESS (5)
#define DEBUGLIGHTINGMODE_GLOBAL_ILLUMINATION (6)
//
// UnityEngine.Rendering.Universal.DebugMaterialMode: static fields
//
#define DEBUGMATERIALMODE_NONE (0)
#define DEBUGMATERIALMODE_ALBEDO (1)
#define DEBUGMATERIALMODE_SPECULAR (2)
#define DEBUGMATERIALMODE_ALPHA (3)
#define DEBUGMATERIALMODE_SMOOTHNESS (4)
#define DEBUGMATERIALMODE_AMBIENT_OCCLUSION (5)
#define DEBUGMATERIALMODE_EMISSION (6)
#define DEBUGMATERIALMODE_NORMAL_WORLD_SPACE (7)
#define DEBUGMATERIALMODE_NORMAL_TANGENT_SPACE (8)
#define DEBUGMATERIALMODE_LIGHTING_COMPLEXITY (9)
#define DEBUGMATERIALMODE_METALLIC (10)
#define DEBUGMATERIALMODE_SPRITE_MASK (11)
#define DEBUGMATERIALMODE_RENDERING_LAYER_MASKS (12)
//
// UnityEngine.Rendering.Universal.DebugMaterialValidationMode: static fields
//
#define DEBUGMATERIALVALIDATIONMODE_NONE (0)
#define DEBUGMATERIALVALIDATIONMODE_ALBEDO (1)
#define DEBUGMATERIALVALIDATIONMODE_METALLIC (2)
//
// UnityEngine.Rendering.Universal.DebugMipInfoMode: static fields
//
#define DEBUGMIPINFOMODE_NONE (0)
#define DEBUGMIPINFOMODE_MIP_STREAMING_PERFORMANCE (1)
#define DEBUGMIPINFOMODE_MIP_STREAMING_STATUS (2)
#define DEBUGMIPINFOMODE_MIP_STREAMING_ACTIVITY (3)
#define DEBUGMIPINFOMODE_MIP_STREAMING_PRIORITY (4)
#define DEBUGMIPINFOMODE_MIP_COUNT (5)
#define DEBUGMIPINFOMODE_MIP_RATIO (6)
//
// UnityEngine.Rendering.Universal.DebugMipMapModeTerrainTexture: static fields
//
#define DEBUGMIPMAPMODETERRAINTEXTURE_CONTROL (0)
#define DEBUGMIPMAPMODETERRAINTEXTURE_LAYER0 (1)
#define DEBUGMIPMAPMODETERRAINTEXTURE_LAYER1 (2)
#define DEBUGMIPMAPMODETERRAINTEXTURE_LAYER2 (3)
#define DEBUGMIPMAPMODETERRAINTEXTURE_LAYER3 (4)
//
// UnityEngine.Rendering.Universal.DebugMipMapStatusMode: static fields
//
#define DEBUGMIPMAPSTATUSMODE_MATERIAL (0)
#define DEBUGMIPMAPSTATUSMODE_TEXTURE (1)
//
// UnityEngine.Rendering.Universal.DebugPostProcessingMode: static fields
//
#define DEBUGPOSTPROCESSINGMODE_DISABLED (0)
#define DEBUGPOSTPROCESSINGMODE_AUTO (1)
#define DEBUGPOSTPROCESSINGMODE_ENABLED (2)
//
// UnityEngine.Rendering.Universal.DebugSceneOverrideMode: static fields
//
#define DEBUGSCENEOVERRIDEMODE_NONE (0)
#define DEBUGSCENEOVERRIDEMODE_OVERDRAW (1)
#define DEBUGSCENEOVERRIDEMODE_WIREFRAME (2)
#define DEBUGSCENEOVERRIDEMODE_SOLID_WIREFRAME (3)
#define DEBUGSCENEOVERRIDEMODE_SHADED_WIREFRAME (4)
//
// UnityEngine.Rendering.Universal.DebugValidationMode: static fields
//
#define DEBUGVALIDATIONMODE_NONE (0)
#define DEBUGVALIDATIONMODE_HIGHLIGHT_NAN_INF_NEGATIVE (1)
#define DEBUGVALIDATIONMODE_HIGHLIGHT_OUTSIDE_OF_RANGE (2)
//
// UnityEngine.Rendering.Universal.DebugVertexAttributeMode: static fields
//
#define DEBUGVERTEXATTRIBUTEMODE_NONE (0)
#define DEBUGVERTEXATTRIBUTEMODE_TEXCOORD0 (1)
#define DEBUGVERTEXATTRIBUTEMODE_TEXCOORD1 (2)
#define DEBUGVERTEXATTRIBUTEMODE_TEXCOORD2 (3)
#define DEBUGVERTEXATTRIBUTEMODE_TEXCOORD3 (4)
#define DEBUGVERTEXATTRIBUTEMODE_COLOR (5)
#define DEBUGVERTEXATTRIBUTEMODE_TANGENT (6)
#define DEBUGVERTEXATTRIBUTEMODE_NORMAL (7)
//
// UnityEngine.Rendering.Universal.HDRDebugMode: static fields
//
#define HDRDEBUGMODE_NONE (0)
#define HDRDEBUGMODE_GAMUT_VIEW (1)
#define HDRDEBUGMODE_GAMUT_CLIP (2)
#define HDRDEBUGMODE_VALUES_ABOVE_PAPER_WHITE (3)
//
// UnityEngine.Rendering.Universal.PixelValidationChannels: static fields
//
#define PIXELVALIDATIONCHANNELS_RGB (0)
#define PIXELVALIDATIONCHANNELS_R (1)
#define PIXELVALIDATIONCHANNELS_G (2)
#define PIXELVALIDATIONCHANNELS_B (3)
#define PIXELVALIDATIONCHANNELS_A (4)
#endif

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 448811f26ae38ae4cbb2edb0d2b9186c
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ef707b0a4fc04a4fb4501a4dec1c376d
timeCreated: 1608022896

View File

@@ -0,0 +1,164 @@
#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_NO_TS(inputData, positionWS, positionCS, texture) SetupDebugDataTexture(inputData, positionWS, positionCS, float4(0.1, 0.1, 1.0, 1.0), texture##_MipInfo, texture##_StreamInfo, GetMipCount(TEXTURE2D_ARGS(texture, sampler##texture)))
#define SETUP_DEBUG_DATA_2D(inputData, positionWS, positionCS) SetupDebugData(inputData, positionWS, positionCS)
void SetupDebugData(inout InputData2D inputData, float3 positionWS, float4 positionCS)
{
inputData.positionWS = positionWS;
inputData.positionCS = positionCS;
}
void SetupDebugDataTexture(inout InputData2D inputData, float3 positionWS, float4 positionCS, float4 texelSize, float4 mipInfo, float4 streamInfo, uint mipCount)
{
SetupDebugData(inputData, positionWS, positionCS);
inputData.texelSize = texelSize;
inputData.mipInfo = mipInfo;
inputData.streamInfo = streamInfo;
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, surfaceData.alpha);
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_WORLD_SPACE:
{
debugColor = half4(surfaceData.normalWS * 0.5 + 0.5, surfaceData.alpha);
return true;
}
case DEBUGMATERIALMODE_NORMAL_TANGENT_SPACE:
{
debugColor = half4(surfaceData.normalTS * 0.5 + 0.5, surfaceData.alpha);
return true;
}
default:
{
return TryGetDebugColorInvalidMode(debugColor);
}
}
}
bool CalculateColorForDebugMipmapStreaming(in SurfaceData2D surfaceData, in InputData2D inputData, inout half4 debugColor)
{
return CalculateColorForDebugMipmapStreaming(inputData.mipCount, uint2(inputData.positionCS.xy), inputData.texelSize, inputData.uv, inputData.mipInfo, inputData.streamInfo, surfaceData.albedo, debugColor);
}
bool CalculateDebugColorForRenderingSettings(in SurfaceData2D surfaceData, in InputData2D inputData, inout half4 debugColor)
{
if (CalculateColorForDebugSceneOverride(debugColor))
{
return true;
}
else if (CalculateColorForDebugMipmapStreaming(surfaceData, inputData, debugColor))
{
return true;
}
return false;
}
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_NO_TS(inputData, positionWS, positionCS, texture)
#define SETUP_DEBUG_TEXTURE_DATA_2D(inputData, positionWS, positionCS, texture)
#define SETUP_DEBUG_DATA_2D(inputData, positionWS, positionCS)
#endif
#endif

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4ee4501622ea4008903e313980a6b1b2
timeCreated: 1613562288

View File

@@ -0,0 +1,390 @@
#ifndef UNIVERSAL_DEBUGGING3D_INCLUDED
#define UNIVERSAL_DEBUGGING3D_INCLUDED
// Ensure that we always include "DebuggingCommon.hlsl" even if we don't use it - saves extraneous includes elsewhere...
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/DebuggingCommon.hlsl"
#if defined(DEBUG_DISPLAY)
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/BRDF.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GlobalIllumination.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RealtimeLights.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceData.hlsl"
#define TERRAIN_STREAM_INFO float4(0.0f, 0.0f, float(6 | (4 << 4)), 0.0f) // 0-15 are reserved for per-texture codes (use "6" to indicate terrain); per-material code "4" signifies "warnings/issues"
#define SETUP_DEBUG_TEXTURE_DATA(inputData, uv) SetupDebugDataTexture(inputData, TRANSFORM_TEX(uv.xy, unity_MipmapStreaming_DebugTex), unity_MipmapStreaming_DebugTex_TexelSize, unity_MipmapStreaming_DebugTex_MipInfo, unity_MipmapStreaming_DebugTex_StreamInfo, unity_MipmapStreaming_DebugTex)
#define SETUP_DEBUG_TEXTURE_DATA_NO_UV(inputData) SetupDebugDataTexture(inputData, float2(0.0f, 0.0f), unity_MipmapStreaming_DebugTex_TexelSize, unity_MipmapStreaming_DebugTex_MipInfo, unity_MipmapStreaming_DebugTex_StreamInfo, unity_MipmapStreaming_DebugTex)
#define SETUP_DEBUG_TEXTURE_DATA_FOR_TEX(inputData, uv, texture) SetupDebugDataTexture(inputData, uv, texture##_TexelSize, texture##_MipInfo, texture##_StreamInfo, texture)
#define SETUP_DEBUG_TEXTURE_DATA_FOR_TERRAIN(inputData) SetupDebugDataTerrain(inputData)
void SetupDebugDataTexture(inout InputData inputData, float2 uv, float4 texelSize, float4 mipInfo, float4 streamInfo, TEXTURE2D(tex))
{
inputData.uv = uv;
inputData.texelSize = texelSize;
inputData.mipInfo = mipInfo;
inputData.streamInfo = streamInfo;
inputData.mipCount = GetMipCount(TEXTURE2D_ARGS(tex, sampler_PointClamp));
inputData.originalColor = 0.0f;
if (_DebugMipInfoMode != DEBUGMIPINFOMODE_NONE)
{
inputData.originalColor = SAMPLE_TEXTURE2D(tex, sampler_LinearRepeat, uv).xyz;
}
}
void SetupDebugDataBrdf(inout InputData inputData, half3 brdfDiffuse, half3 brdfSpecular)
{
inputData.brdfDiffuse = brdfDiffuse;
inputData.brdfSpecular = brdfSpecular;
}
void SetupDebugDataTerrain(inout InputData inputData)
{
// TERRAIN_STREAM_INFO: no streamInfo will have been set (no MeshRenderer); set status to "6" to reflect in the debug status that this is a terrain
// also, set the per-material status to "4" to indicate warnings
inputData.streamInfo = TERRAIN_STREAM_INFO;
}
bool UpdateSurfaceAndInputDataForDebug(inout SurfaceData surfaceData, inout InputData inputData)
{
bool changed = false;
if (_DebugLightingMode == DEBUGLIGHTINGMODE_LIGHTING_WITHOUT_NORMAL_MAPS || _DebugLightingMode == DEBUGLIGHTINGMODE_LIGHTING_WITH_NORMAL_MAPS)
{
surfaceData.albedo = 1;
surfaceData.emission = 0;
surfaceData.specular = 0;
surfaceData.occlusion = 1;
surfaceData.clearCoatMask = 0;
surfaceData.clearCoatSmoothness = 1;
surfaceData.metallic = 0;
surfaceData.smoothness = 0;
changed = true;
}
else if (_DebugLightingMode == DEBUGLIGHTINGMODE_REFLECTIONS || _DebugLightingMode == DEBUGLIGHTINGMODE_REFLECTIONS_WITH_SMOOTHNESS)
{
surfaceData.albedo = 0;
surfaceData.emission = 0;
surfaceData.occlusion = 1;
surfaceData.clearCoatMask = 0;
surfaceData.clearCoatSmoothness = 1;
surfaceData.specular = 1;
surfaceData.metallic = 0;
if (_DebugLightingMode == DEBUGLIGHTINGMODE_REFLECTIONS)
{
surfaceData.smoothness = 1;
}
changed = true;
}
if (_DebugLightingMode == DEBUGLIGHTINGMODE_LIGHTING_WITHOUT_NORMAL_MAPS || _DebugLightingMode == DEBUGLIGHTINGMODE_REFLECTIONS)
{
const half3 normalTS = half3(0, 0, 1);
#if defined(_NORMALMAP)
inputData.normalWS = TransformTangentToWorld(normalTS, inputData.tangentToWorld);
#else
inputData.normalWS = inputData.normalWS;
#endif
surfaceData.normalTS = normalTS;
changed = true;
}
return changed;
}
bool CalculateValidationMetallic(half3 albedo, half metallic, inout half4 debugColor)
{
if (metallic < _DebugValidateMetallicMinValue)
{
debugColor = _DebugValidateBelowMinThresholdColor;
}
else if (metallic > _DebugValidateMetallicMaxValue)
{
debugColor = _DebugValidateAboveMaxThresholdColor;
}
else
{
half luminance = Luminance(albedo);
debugColor = half4(luminance, luminance, luminance, 1);
}
return true;
}
bool CalculateValidationColorForDebug(in InputData inputData, in SurfaceData surfaceData, inout half4 debugColor)
{
switch(_DebugMaterialValidationMode)
{
case DEBUGMATERIALVALIDATIONMODE_NONE:
return false;
case DEBUGMATERIALVALIDATIONMODE_ALBEDO:
return CalculateValidationAlbedo(surfaceData.albedo, debugColor);
case DEBUGMATERIALVALIDATIONMODE_METALLIC:
return CalculateValidationMetallic(surfaceData.albedo, surfaceData.metallic, debugColor);
default:
return TryGetDebugColorInvalidMode(debugColor);
}
}
float3 GetRenderingLayerMasksDebugColor(float4 positionCS, float3 normalWS)
{
uint stripeSize = 8;
int renderingLayers = GetMeshRenderingLayer() & _DebugRenderingLayerMask;
uint layerId = 0, layerCount = countbits(renderingLayers);
float4 debugColor = float4(1, 1, 1, 1);
for (uint i = 0; (i < 32) && (layerId < layerCount); i++)
{
if (renderingLayers & (1U << i))
{
uint t = (positionCS.y / stripeSize) % layerCount;
if (t == layerId)
debugColor.rgb = _DebugRenderingLayerMaskColors[i].rgb;
layerId++;
}
}
float shading = saturate(dot(normalWS, TransformViewToWorldDir(float3(0.0f, 0.0f, 1.0f), true)));
shading = Remap(0.0f, 1.0f, 0.6, 1.0f, shading);
return shading * debugColor.xyz;
}
bool CalculateColorForDebugMaterial(in InputData inputData, in SurfaceData surfaceData, inout half4 debugColor)
{
// Debug materials...
switch(_DebugMaterialMode)
{
case DEBUGMATERIALMODE_NONE:
return false;
case DEBUGMATERIALMODE_ALBEDO:
debugColor = half4(surfaceData.albedo, 1);
return true;
case DEBUGMATERIALMODE_SPECULAR:
debugColor = half4(surfaceData.specular, 1);
return true;
case DEBUGMATERIALMODE_ALPHA:
debugColor = half4(surfaceData.alpha.rrr, 1);
return true;
case DEBUGMATERIALMODE_SMOOTHNESS:
debugColor = half4(surfaceData.smoothness.rrr, 1);
return true;
case DEBUGMATERIALMODE_AMBIENT_OCCLUSION:
debugColor = half4(surfaceData.occlusion.rrr, 1);
return true;
case DEBUGMATERIALMODE_EMISSION:
debugColor = half4(surfaceData.emission, 1);
return true;
case DEBUGMATERIALMODE_NORMAL_WORLD_SPACE:
debugColor = half4(inputData.normalWS.xyz * 0.5 + 0.5, 1);
return true;
case DEBUGMATERIALMODE_NORMAL_TANGENT_SPACE:
debugColor = half4(surfaceData.normalTS.xyz * 0.5 + 0.5, 1);
return true;
case DEBUGMATERIALMODE_METALLIC:
debugColor = half4(surfaceData.metallic.rrr, 1);
return true;
case DEBUGMATERIALMODE_RENDERING_LAYER_MASKS:
debugColor.xyz = GetRenderingLayerMasksDebugColor(inputData.positionCS, inputData.normalWS).xyz;
return true;
default:
return TryGetDebugColorInvalidMode(debugColor);
}
}
bool CalculateColorForDebugMipmapStreaming(in InputData inputData, in SurfaceData surfaceData, inout half4 debugColor)
{
return CalculateColorForDebugMipmapStreaming(inputData.mipCount, inputData.positionCS.xy, inputData.texelSize, inputData.uv, inputData.mipInfo, inputData.streamInfo, inputData.originalColor, debugColor);
}
bool CalculateColorForDebug(in InputData inputData, in SurfaceData surfaceData, inout half4 debugColor)
{
if (CalculateColorForDebugSceneOverride(debugColor))
{
return true;
}
else if (CalculateColorForDebugMipmapStreaming(inputData, surfaceData, debugColor))
{
return true;
}
else if (CalculateColorForDebugMaterial(inputData, surfaceData, debugColor))
{
return true;
}
else if (CalculateValidationColorForDebug(inputData, surfaceData, debugColor))
{
return true;
}
else
{
return false;
}
}
half3 CalculateDebugShadowCascadeColor(in InputData inputData)
{
float3 positionWS = inputData.positionWS;
half cascadeIndex = ComputeCascadeIndex(positionWS);
switch (uint(cascadeIndex))
{
case 0: return kDebugColorShadowCascade0.rgb;
case 1: return kDebugColorShadowCascade1.rgb;
case 2: return kDebugColorShadowCascade2.rgb;
case 3: return kDebugColorShadowCascade3.rgb;
default: return kDebugColorBlack.rgb;
}
}
half4 CalculateDebugLightingComplexityColor(in InputData inputData, in SurfaceData surfaceData)
{
#if USE_CLUSTER_LIGHT_LOOP
int numLights = URP_FP_DIRECTIONAL_LIGHTS_COUNT;
uint entityIndex;
ClusterIterator it = ClusterInit(inputData.normalizedScreenSpaceUV, inputData.positionWS, 0);
[loop] while (ClusterNext(it, entityIndex))
{
numLights++;
}
it = ClusterInit(inputData.normalizedScreenSpaceUV, inputData.positionWS, 1);
[loop] while (ClusterNext(it, entityIndex))
{
numLights++;
}
#else
// Assume a main light and add 1 to the additional lights.
int numLights = GetAdditionalLightsCount() + 1;
#endif
const uint2 tileSize = uint2(32,32);
const uint maxLights = 9;
const float opacity = 0.8f;
uint2 pixelCoord = uint2(inputData.normalizedScreenSpaceUV * _ScreenParams.xy);
half3 base = surfaceData.albedo;
half4 overlay = half4(OverlayHeatMap(pixelCoord, tileSize, numLights, maxLights, opacity));
uint2 tileCoord = (float2)pixelCoord / tileSize;
uint2 offsetInTile = pixelCoord - tileCoord * tileSize;
bool border = any(offsetInTile == 0 || offsetInTile == tileSize.x - 1);
if (border)
overlay = half4(1, 1, 1, 0.4f);
return half4(lerp(base.rgb, overlay.rgb, overlay.a), 1);
}
bool CanDebugOverrideOutputColor(inout InputData inputData, inout SurfaceData surfaceData, inout BRDFData brdfData, inout half4 debugColor)
{
if (_DebugMaterialMode == DEBUGMATERIALMODE_LIGHTING_COMPLEXITY)
{
debugColor = CalculateDebugLightingComplexityColor(inputData, surfaceData);
return true;
}
else if (_DebugLightingMode == DEBUGLIGHTINGMODE_GLOBAL_ILLUMINATION)
{
debugColor = half4(inputData.bakedGI, surfaceData.alpha);
return true;
}
else
{
debugColor = half4(0, 0, 0, 1);
if (_DebugLightingMode == DEBUGLIGHTINGMODE_SHADOW_CASCADES)
{
surfaceData.albedo = CalculateDebugShadowCascadeColor(inputData);
}
else
{
if (UpdateSurfaceAndInputDataForDebug(surfaceData, inputData))
{
// If we've modified any data we'll need to re-sample the GI to ensure that everything works correctly...
#if defined(DYNAMICLIGHTMAP_ON)
inputData.bakedGI = SAMPLE_GI(inputData.staticLightmapUV, inputData.dynamicLightmapUV.xy, inputData.vertexSH, inputData.normalWS);
#elif !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
inputData.bakedGI = SAMPLE_GI(inputData.vertexSH,
GetAbsolutePositionWS(inputData.positionWS),
inputData.normalWS,
inputData.viewDirectionWS,
inputData.positionCS.xy,
inputData.probeOcclusion,
inputData.shadowMask);
#else
inputData.bakedGI = SAMPLE_GI(inputData.staticLightmapUV, inputData.vertexSH, inputData.normalWS);
#endif
}
}
// Update the BRDF data following any changes to the input/surface above...
InitializeBRDFData(surfaceData, brdfData);
return CalculateColorForDebug(inputData, surfaceData, debugColor);
}
}
bool CanDebugOverrideOutputColor(inout InputData inputData, inout SurfaceData surfaceData, inout half4 debugColor)
{
if (_DebugMaterialMode == DEBUGMATERIALMODE_LIGHTING_COMPLEXITY)
{
debugColor = CalculateDebugLightingComplexityColor(inputData, surfaceData);
return true;
}
else if (_DebugLightingMode == DEBUGLIGHTINGMODE_GLOBAL_ILLUMINATION)
{
debugColor = half4(inputData.bakedGI, surfaceData.alpha);
return true;
}
else
{
if (_DebugLightingMode == DEBUGLIGHTINGMODE_SHADOW_CASCADES)
{
surfaceData.albedo = CalculateDebugShadowCascadeColor(inputData);
}
else
{
if (UpdateSurfaceAndInputDataForDebug(surfaceData, inputData))
{
// If we've modified any data we'll need to re-sample the GI to ensure that everything works correctly...
#if defined(DYNAMICLIGHTMAP_ON)
inputData.bakedGI = SAMPLE_GI(inputData.staticLightmapUV, inputData.dynamicLightmapUV.xy, inputData.vertexSH, inputData.normalWS);
#elif !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
inputData.bakedGI = SAMPLE_GI(inputData.vertexSH,
GetAbsolutePositionWS(inputData.positionWS),
inputData.normalWS,
inputData.viewDirectionWS,
inputData.positionCS.xy,
inputData.probeOcclusion,
inputData.shadowMask);
#else
inputData.bakedGI = SAMPLE_GI(inputData.staticLightmapUV, inputData.vertexSH, inputData.normalWS);
#endif
}
}
return CalculateColorForDebug(inputData, surfaceData, debugColor);
}
}
#else
// When "DEBUG_DISPLAY" isn't defined this macro does nothing - there's no debug-data to set-up...
#define SETUP_DEBUG_TEXTURE_DATA(inputData, uv)
#define SETUP_DEBUG_TEXTURE_DATA_NO_UV(inputData)
#define SETUP_DEBUG_TEXTURE_DATA_FOR_TEX(inputData, uv, texture)
#define SETUP_DEBUG_TEXTURE_DATA_FOR_TERRAIN(inputData)
#endif
#endif

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d8ae717b647341719f2a89f20faaf51b
timeCreated: 1613560270

View File

@@ -0,0 +1,300 @@
#ifndef UNIVERSAL_DEBUGGING_COMMON_INCLUDED
#define UNIVERSAL_DEBUGGING_COMMON_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/DebugViewEnums.cs.hlsl"
#if defined(DEBUG_DISPLAY)
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreaming.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Debug.hlsl"
// Material settings...
int _DebugMaterialMode;
int _DebugVertexAttributeMode;
int _DebugMaterialValidationMode;
// Rendering settings...
int _DebugFullScreenMode;
int _DebugSceneOverrideMode;
int _DebugMipInfoMode;
int _DebugMipMapStatusMode;
int _DebugMipMapShowStatusCode;
half _DebugMipMapOpacity;
half _DebugMipMapRecentlyUpdatedCooldown;
int _DebugMipMapTerrainTextureMode;
int _DebugValidationMode;
// Lighting settings...
int _DebugLightingMode;
int _DebugLightingFeatureFlags;
half _DebugValidateAlbedoMinLuminance = 0.01;
half _DebugValidateAlbedoMaxLuminance = 0.90;
half _DebugValidateAlbedoSaturationTolerance = 0.214;
half _DebugValidateAlbedoHueTolerance = 0.104;
half3 _DebugValidateAlbedoCompareColor = half3(0.5, 0.5, 0.5);
uint _DebugRenderingLayerMask = 0;
CBUFFER_START(_DebugDisplayConstant)
float4 _DebugRenderingLayerMaskColors [32];
CBUFFER_END
half _DebugValidateMetallicMinValue = 0;
half _DebugValidateMetallicMaxValue = 0.9;
float4 _DebugColor;
float4 _DebugColorInvalidMode;
float4 _DebugValidateBelowMinThresholdColor;
float4 _DebugValidateAboveMaxThresholdColor;
// Not particular to any settings; used by MipMap debugging because we don't have reliable access to _Time.y
float _DebugCurrentRealTime;
// We commonly need to undo a previous TRANSFORM_TEX to get UV0s back, followed by a TRANSFORM_TEX with the UV0s / _ST of the StreamingDebugTex... hence, this macro.
#define UNDO_TRANSFORM_TEX(uv, undoTex) ((uv - undoTex##_ST.zw) / undoTex##_ST.xy)
half3 GetDebugColor(uint index)
{
uint clampedIndex = clamp(index, 0, DEBUG_COLORS_COUNT-1);
return kDebugColorGradient[clampedIndex].rgb;
}
bool TryGetDebugColorInvalidMode(out half4 debugColor)
{
// Depending upon how we want to deal with invalid modes, this code may need to change,
// for now we'll simply make each pixel use "_DebugColorInvalidMode"...
debugColor = _DebugColorInvalidMode;
return true;
}
uint GetMipMapLevel(float2 nonNormalizedUVCoordinate)
{
// The OpenGL Graphics System: A Specification 4.2
// - chapter 3.9.11, equation 3.21
float2 dx_vtc = ddx(nonNormalizedUVCoordinate);
float2 dy_vtc = ddy(nonNormalizedUVCoordinate);
float delta_max_sqr = max(dot(dx_vtc, dx_vtc), dot(dy_vtc, dy_vtc));
return (uint)(0.5 * log2(delta_max_sqr));
}
bool CalculateValidationAlbedo(half3 albedo, out half4 color)
{
half luminance = Luminance(albedo);
if (luminance < _DebugValidateAlbedoMinLuminance)
{
color = _DebugValidateBelowMinThresholdColor;
}
else if (luminance > _DebugValidateAlbedoMaxLuminance)
{
color = _DebugValidateAboveMaxThresholdColor;
}
else
{
half3 hsv = RgbToHsv(albedo);
half hue = hsv.r;
half sat = hsv.g;
half3 compHSV = RgbToHsv(_DebugValidateAlbedoCompareColor.rgb);
half compHue = compHSV.r;
half compSat = compHSV.g;
if ((compSat - _DebugValidateAlbedoSaturationTolerance > sat) || ((compHue - _DebugValidateAlbedoHueTolerance > hue) && (compHue - _DebugValidateAlbedoHueTolerance + 1.0 > hue)))
{
color = _DebugValidateBelowMinThresholdColor;
}
else if ((sat > compSat + _DebugValidateAlbedoSaturationTolerance) || ((hue > compHue + _DebugValidateAlbedoHueTolerance) && (hue > compHue + _DebugValidateAlbedoHueTolerance - 1.0)))
{
color = _DebugValidateAboveMaxThresholdColor;
}
else
{
color = half4(luminance, luminance, luminance, 1.0);
}
}
return true;
}
bool CalculateColorForDebugSceneOverride(out half4 color)
{
if (_DebugSceneOverrideMode == DEBUGSCENEOVERRIDEMODE_NONE)
{
color = 0;
return false;
}
else
{
color = _DebugColor;
return true;
}
}
half4 BlitScreenSpaceDigit(half4 originalColor, uint2 screenSpaceCoords, int digit, uint spacing, bool invertColors)
{
half4 outColor = originalColor;
const uint2 pixCoord = screenSpaceCoords / 2;
const uint2 tileSize = uint2(spacing, spacing);
const int2 coord = (pixCoord & (tileSize - 1)) - int2(tileSize.x/4+1, tileSize.y/3-3);
UNITY_LOOP for (int i = 0; i <= 1; ++i)
{
// 0 == shadow, 1 == text
if (SampleDebugFontNumber2Digits(coord + i, digit))
{
outColor = (i == 0)
? (invertColors ? half4(1, 1, 1, 1) : half4(0, 0, 0, 1))
: (invertColors ? half4(0, 0, 0, 1) : half4(1, 1, 1, 1));
}
}
return outColor;
}
void GetHatchedColor(uint2 screenSpaceCoords, half4 hatchingColor, inout half4 debugColor)
{
const uint spacing = 16; // increase spacing compared to the legend (easier on the eyes)
const uint thickness = 3;
if((screenSpaceCoords.x + screenSpaceCoords.y) % spacing < thickness)
debugColor = hatchingColor;
}
void GetHatchedColor(uint2 screenSpaceCoords, inout half4 debugColor)
{
GetHatchedColor(screenSpaceCoords, half4(0.1, 0.1, 0.1, 1), debugColor);
}
// Keep in sync with GetTextureDataDebug in HDRP's Runtime/Debug/DebugDisplay.hlsl
bool CalculateColorForDebugMipmapStreaming(in uint mipCount, uint2 screenSpaceCoords, in float4 texelSize, in float2 uv, in float4 mipInfo, in float4 streamInfo, in half3 originalColor, inout half4 debugColor)
{
bool hasDebugColor = false;
bool needsHatching;
switch (_DebugMipInfoMode)
{
case DEBUGMIPINFOMODE_NONE:
hasDebugColor = false;
break;
case DEBUGMIPINFOMODE_MIP_COUNT:
debugColor = half4(GetDebugMipCountColor(mipCount, needsHatching), 1);
if (needsHatching)
{
half4 hatchingColor = half4(GetDebugMipCountHatchingColor(mipCount), 1);
GetHatchedColor(screenSpaceCoords, hatchingColor, debugColor);
}
if (mipCount > 0 && mipCount <= 14)
debugColor = BlitScreenSpaceDigit(debugColor, screenSpaceCoords, mipCount, 32, true);
hasDebugColor = true;
break;
case DEBUGMIPINFOMODE_MIP_RATIO:
debugColor = half4(GetDebugMipColorIncludingMipReduction(originalColor, mipCount, texelSize, uv, mipInfo), 1);
hasDebugColor = true;
break;
case DEBUGMIPINFOMODE_MIP_STREAMING_PERFORMANCE:
debugColor = half4(GetDebugStreamingMipColor(mipCount, mipInfo, streamInfo, needsHatching), 1);
if (needsHatching)
GetHatchedColor(screenSpaceCoords, debugColor);
hasDebugColor = true;
break;
case DEBUGMIPINFOMODE_MIP_STREAMING_STATUS:
if(_DebugMipMapStatusMode == DEBUGMIPMAPSTATUSMODE_TEXTURE)
debugColor = half4(GetDebugStreamingStatusColor(streamInfo, needsHatching), 1);
else
debugColor = half4(GetDebugPerMaterialStreamingStatusColor(streamInfo, needsHatching), 1);
if (needsHatching)
GetHatchedColor(screenSpaceCoords, debugColor);
if (_DebugMipMapShowStatusCode && _DebugMipMapStatusMode == DEBUGMIPMAPSTATUSMODE_TEXTURE && !IsStreaming(streamInfo))
{
if (GetStatusCode(streamInfo, false) != kMipmapDebugStatusCodeNotSet && GetStatusCode(streamInfo, false) != kMipmapDebugStatusCodeNoTexture) // we're ignoring these because there's just one status anyway (so the color itself is enough)
debugColor = BlitScreenSpaceDigit(debugColor, screenSpaceCoords, GetStatusCode(streamInfo, false), 16, false);
}
hasDebugColor = true;
break;
case DEBUGMIPINFOMODE_MIP_STREAMING_PRIORITY:
debugColor = half4(GetDebugStreamingPriorityColor(streamInfo), 1);
hasDebugColor = true;
break;
case DEBUGMIPINFOMODE_MIP_STREAMING_ACTIVITY:
debugColor = half4(GetDebugStreamingRecentlyUpdatedColor(_DebugCurrentRealTime, _DebugMipMapRecentlyUpdatedCooldown, _DebugMipMapStatusMode == DEBUGMIPMAPSTATUSMODE_MATERIAL, streamInfo), 1);
hasDebugColor = true;
break;
default:
hasDebugColor = TryGetDebugColorInvalidMode(debugColor);
break;
}
// Blend the original color with the debug color
if(hasDebugColor)
debugColor = lerp(half4(originalColor, 1), debugColor, _DebugMipMapOpacity);
return hasDebugColor;
}
#else
// When "DEBUG_DISPLAY" isn't defined this macro just returns the original UVs.
#define UNDO_TRANSFORM_TEX(uv, undoTex) uv
#endif
bool IsAlphaDiscardEnabled()
{
#if defined(DEBUG_DISPLAY)
return (_DebugSceneOverrideMode == DEBUGSCENEOVERRIDEMODE_NONE);
#else
return true;
#endif
}
bool IsFogEnabled()
{
#if defined(DEBUG_DISPLAY)
return (_DebugMaterialMode == DEBUGMATERIALMODE_NONE) &&
(_DebugVertexAttributeMode == DEBUGVERTEXATTRIBUTEMODE_NONE) &&
(_DebugMaterialValidationMode == DEBUGMATERIALVALIDATIONMODE_NONE) &&
(_DebugSceneOverrideMode == DEBUGSCENEOVERRIDEMODE_NONE) &&
(_DebugMipInfoMode == DEBUGMIPINFOMODE_NONE) &&
(_DebugLightingMode == DEBUGLIGHTINGMODE_NONE) &&
(_DebugLightingFeatureFlags == 0) &&
(_DebugValidationMode == DEBUGVALIDATIONMODE_NONE);
#else
return true;
#endif
}
bool IsLightingFeatureEnabled(uint bitMask)
{
#if defined(DEBUG_DISPLAY)
return (_DebugLightingFeatureFlags == 0) || ((_DebugLightingFeatureFlags & bitMask) != 0);
#else
return true;
#endif
}
bool IsOnlyAOLightingFeatureEnabled()
{
#if defined(DEBUG_DISPLAY)
return _DebugLightingFeatureFlags == DEBUGLIGHTINGFEATUREFLAGS_AMBIENT_OCCLUSION;
#else
return false;
#endif
}
#endif

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a419d344c87843af8e1ce2e8c571fcb6
timeCreated: 1613560313

View File

@@ -0,0 +1,214 @@
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/DebuggingCommon.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Debug.hlsl"
#if defined(DEBUG_DISPLAY)
int _DebugMaxPixelCost;
int _ValidationChannels;
float _RangeMinimum;
float _RangeMaximum;
TEXTURE2D_X(_DebugTexture);
TEXTURE2D(_DebugTextureNoStereo);
// 2023.3 Deprecated. This is for backwards compatibility. Remove in the future.
#define sampler_DebugTexture sampler_PointClamp
half4 _DebugTextureDisplayRect;
int _DebugRenderTargetSupportsStereo;
float4 _DebugRenderTargetRangeRemap;
// CPU parametrized, non-clamping, range remap. (RangeRemap in common.hlsl saturates!)
half4 RemapSourceRange(half4 source)
{
float4 r = _DebugRenderTargetRangeRemap;
float4 s = source;
// Remap(float origFrom, float origTo, float targetFrom, float targetTo, float value)
s.r = Remap(r.x, r.y, r.z, r.w, s.r);
s.g = Remap(r.x, r.y, r.z, r.w, s.g);
s.b = Remap(r.x, r.y, r.z, r.w, s.b);
s.a = Remap(r.x, r.y, r.z, r.w, s.a);
return half4(s);
}
bool CalculateDebugColorRenderingSettings(half4 color, float2 uv, inout half4 debugColor)
{
if (_DebugSceneOverrideMode == DEBUGSCENEOVERRIDEMODE_OVERDRAW)
{
// color.r is (Number of overdraw / Max displayed overdraw count)
debugColor.rgb = GetOverdrawColor(color.r * _DebugMaxPixelCost, _DebugMaxPixelCost).rgb;
DrawOverdrawLegend(uv, _DebugMaxPixelCost, _ScreenSize, debugColor.rgb);
return true;
}
if (_DebugMipInfoMode != DEBUGMIPINFOMODE_NONE)
{
debugColor = color; // just passing through
// draw legend
switch(_DebugMipInfoMode)
{
case DEBUGMIPINFOMODE_MIP_COUNT:
DrawMipCountLegend(uv, _ScreenSize, debugColor.rgb);
break;
case DEBUGMIPINFOMODE_MIP_RATIO:
DrawMipRatioLegend(uv, _ScreenSize, debugColor.rgb);
break;
case DEBUGMIPINFOMODE_MIP_STREAMING_STATUS:
if (_DebugMipMapStatusMode == DEBUGMIPMAPSTATUSMODE_TEXTURE)
DrawMipStreamingStatusLegend(uv, _ScreenSize, _DebugMipMapShowStatusCode, debugColor.rgb);
else
DrawMipStreamingStatusPerMaterialLegend(uv, _ScreenSize, debugColor.rgb);
break;
case DEBUGMIPINFOMODE_MIP_STREAMING_PERFORMANCE:
DrawTextureStreamingPerformanceLegend(uv, _ScreenSize, debugColor.rgb);
break;
case DEBUGMIPINFOMODE_MIP_STREAMING_PRIORITY:
DrawMipPriorityLegend(uv, _ScreenSize, debugColor.rgb);
break;
case DEBUGMIPINFOMODE_MIP_STREAMING_ACTIVITY:
DrawMipRecentlyUpdatedLegend(uv, _ScreenSize, _DebugMipMapStatusMode == DEBUGMIPMAPSTATUSMODE_MATERIAL, debugColor.rgb);
break;
}
return true;
}
switch(_DebugFullScreenMode)
{
case DEBUGFULLSCREENMODE_DEPTH:
case DEBUGFULLSCREENMODE_MOTION_VECTOR:
case DEBUGFULLSCREENMODE_MAIN_LIGHT_SHADOW_MAP:
case DEBUGFULLSCREENMODE_ADDITIONAL_LIGHTS_SHADOW_MAP:
case DEBUGFULLSCREENMODE_ADDITIONAL_LIGHTS_COOKIE_ATLAS:
case DEBUGFULLSCREENMODE_REFLECTION_PROBE_ATLAS:
case DEBUGFULLSCREENMODE_STP:
{
float2 uvOffset = half2(uv.x - _DebugTextureDisplayRect.x, uv.y - _DebugTextureDisplayRect.y);
if ((uvOffset.x >= 0) && (uvOffset.x < _DebugTextureDisplayRect.z) &&
(uvOffset.y >= 0) && (uvOffset.y < _DebugTextureDisplayRect.w))
{
float2 debugTextureUv = float2(uvOffset.x / _DebugTextureDisplayRect.z, uvOffset.y / _DebugTextureDisplayRect.w);
half4 sampleColor = (half4)0;
if (_DebugRenderTargetSupportsStereo == 1)
sampleColor = SAMPLE_TEXTURE2D_X(_DebugTexture, sampler_DebugTexture, debugTextureUv);
else
sampleColor = SAMPLE_TEXTURE2D(_DebugTextureNoStereo, sampler_DebugTexture, debugTextureUv);
// Optionally remap source to valid visualization range.
if(any(_DebugRenderTargetRangeRemap != 0))
{
sampleColor.rgb = RemapSourceRange(sampleColor).rgb;
}
if (_DebugFullScreenMode == DEBUGFULLSCREENMODE_DEPTH)
{
debugColor = half4(sampleColor.rrr, 1);
}
else if (_DebugFullScreenMode == DEBUGFULLSCREENMODE_MOTION_VECTOR)
{
// Motion vector is RG only.
debugColor = half4(sampleColor.rg, 0, 1);
}
else if (_DebugFullScreenMode == DEBUGFULLSCREENMODE_STP)
{
// This is encoded in gamma 2.0 (so the square is needed to get it back to linear).
debugColor = sampleColor * sampleColor;
}
else
{
debugColor = sampleColor;
}
return true;
}
else
{
return false;
}
}
default:
{
return false;
}
} // End of switch.
}
bool CalculateDebugColorValidationSettings(half4 color, float2 uv, inout half4 debugColor)
{
switch(_DebugValidationMode)
{
case DEBUGVALIDATIONMODE_HIGHLIGHT_NAN_INF_NEGATIVE:
{
if (AnyIsNaN(color))
{
debugColor = half4(1, 0, 0, 1);
}
else if (AnyIsInf(color))
{
debugColor = half4(0, 1, 0, 1);
}
else if (color.r < 0 || color.g < 0 || color.b < 0 || color.a < 0)
{
debugColor = half4(0, 0, 1, 1);
}
else
{
debugColor = half4(Luminance(color).rrr, 1);
}
return true;
}
case DEBUGVALIDATIONMODE_HIGHLIGHT_OUTSIDE_OF_RANGE:
{
float val;
if (_ValidationChannels == PIXELVALIDATIONCHANNELS_RGB)
{
val = Luminance(color.rgb);
}
else if (_ValidationChannels == PIXELVALIDATIONCHANNELS_R)
{
val = color.r;
}
else if (_ValidationChannels == PIXELVALIDATIONCHANNELS_G)
{
val = color.g;
}
else if (_ValidationChannels == PIXELVALIDATIONCHANNELS_B)
{
val = color.b;
}
else if (_ValidationChannels == PIXELVALIDATIONCHANNELS_A)
{
val = color.a;
}
if (val < _RangeMinimum)
debugColor = _DebugValidateBelowMinThresholdColor;
else if (val > _RangeMaximum)
debugColor = _DebugValidateAboveMaxThresholdColor;
else
debugColor = half4(Luminance(color.rgb).rrr, 1);
return true;
}
default:
{
return false;
}
} // End of switch.
}
bool CanDebugOverrideOutputColor(half4 color, float2 uv, inout half4 debugColor)
{
return CalculateDebugColorRenderingSettings(color, uv, debugColor) ||
CalculateDebugColorValidationSettings(color, uv, debugColor);
}
#endif

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4203f0a40f114a18a614d8fa38c29be9
timeCreated: 1614358421