This commit is contained in:
2026-11-24 15:51:02 +01:00
parent cca4d73e41
commit f4aa17114a
22092 changed files with 5042406 additions and 0 deletions
@@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
namespace UnityEngine.Rendering.Universal
{
[Serializable]
class DebugDisplaySettingsCommon : IDebugDisplaySettingsData, ISerializedDebugDisplaySettings
{
[DisplayInfo(name = "Frequently Used", order = -1)]
private class SettingsPanel : DebugDisplaySettingsPanel
{
DebugUI.Foldout.ContextMenuItem AddGoToSectionContextMenuItem(string panelName)
{
return new DebugUI.Foldout.ContextMenuItem
{
displayName = $"Open {panelName} Tab...",
action = () =>
{
DebugManager.instance.RequestPanelSelection(panelName);
}
};
}
public SettingsPanel()
{
AddWidget(new DebugUI.RuntimeDebugShadersMessageBox());
var debugDisplaySettings = UniversalRenderPipelineDebugDisplaySettings.Instance;
var renderingSettingsData = debugDisplaySettings.renderingSettings;
AddWidget(new DebugUI.Foldout
{
displayName = "Rendering Debug",
isHeader = true,
opened = true,
children =
{
DebugDisplaySettingsRendering.WidgetFactory.CreateMapOverlays(renderingSettingsData),
DebugDisplaySettingsRendering.WidgetFactory.CreateStpDebugViews(renderingSettingsData),
DebugDisplaySettingsRendering.WidgetFactory.CreateMapOverlaySize(renderingSettingsData),
DebugDisplaySettingsRendering.WidgetFactory.CreateHDR(renderingSettingsData),
DebugDisplaySettingsRendering.WidgetFactory.CreateMSAA(renderingSettingsData),
DebugDisplaySettingsRendering.WidgetFactory.CreatePostProcessing(renderingSettingsData),
DebugDisplaySettingsRendering.WidgetFactory.CreateAdditionalWireframeShaderViews(renderingSettingsData),
DebugDisplaySettingsRendering.WidgetFactory.CreateWireframeNotSupportedWarning(renderingSettingsData),
DebugDisplaySettingsRendering.WidgetFactory.CreateOverdrawMode(renderingSettingsData),
DebugDisplaySettingsRendering.WidgetFactory.CreateMaxOverdrawCount(renderingSettingsData),
},
contextMenuItems = new List<DebugUI.Foldout.ContextMenuItem> { AddGoToSectionContextMenuItem("Rendering") }
});
var materialSettingsData = debugDisplaySettings.materialSettings;
AddWidget(new DebugUI.Foldout
{
displayName = "Material Filters",
isHeader = true,
opened = true,
children =
{
DebugDisplaySettingsMaterial.WidgetFactory.CreateMaterialOverride(materialSettingsData)
},
contextMenuItems = new List<DebugUI.Foldout.ContextMenuItem> { AddGoToSectionContextMenuItem("Material") }
});
var lightingSettingsData = debugDisplaySettings.lightingSettings;
AddWidget(new DebugUI.Foldout
{
displayName = "Lighting Debug Modes",
isHeader = true,
opened = true,
children =
{
DebugDisplaySettingsLighting.WidgetFactory.CreateLightingDebugMode(lightingSettingsData),
DebugDisplaySettingsLighting.WidgetFactory.CreateLightingFeatures(lightingSettingsData)
},
contextMenuItems = new List<DebugUI.Foldout.ContextMenuItem> { AddGoToSectionContextMenuItem("Lighting") }
});
}
}
#region IDebugDisplaySettingsData
// All common settings are owned by another panel, so they are treated as inactive here.
/// <inheritdoc/>
public bool AreAnySettingsActive => false;
/// <inheritdoc/>
public IDebugDisplaySettingsPanelDisposable CreatePanel()
{
return new SettingsPanel();
}
#endregion
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 89bc0329853842ae999d6f86829fc126
timeCreated: 1615364496
@@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
using NameAndTooltip = UnityEngine.Rendering.DebugUI.Widget.NameAndTooltip;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Lighting-related Rendering Debugger settings.
/// </summary>
[Serializable]
public class DebugDisplaySettingsLighting : IDebugDisplaySettingsData, ISerializedDebugDisplaySettings
{
/// <summary>
/// Current debug lighting mode.
/// </summary>
public DebugLightingMode lightingDebugMode { get; set; }
/// <summary>
/// Current debug lighting feature flags mask that allows selective disabling individual lighting components.
/// </summary>
public DebugLightingFeatureFlags lightingFeatureFlags { get; set; }
/// <summary>
/// Current HDR debug mode.
/// </summary>
public HDRDebugMode hdrDebugMode { get; set; }
static internal class Strings
{
public static readonly NameAndTooltip LightingDebugMode = new() { name = "Lighting Debug Mode", tooltip = "Use the drop-down to select which lighting and shadow debug information to overlay on the screen." };
public static readonly NameAndTooltip LightingFeatures = new() { name = "Lighting Features", tooltip = "Filter and debug selected lighting features in the system." };
public static readonly NameAndTooltip HDRDebugMode = new() { name = "HDR Debug Mode", tooltip = "Select which HDR brightness debug information to overlay on the screen." };
}
internal static class WidgetFactory
{
internal static DebugUI.Widget CreateLightingDebugMode(DebugDisplaySettingsLighting data) => new DebugUI.EnumField
{
nameAndTooltip = Strings.LightingDebugMode,
autoEnum = typeof(DebugLightingMode),
getter = () => (int)data.lightingDebugMode,
setter = (value) => data.lightingDebugMode = (DebugLightingMode)value,
getIndex = () => (int)data.lightingDebugMode,
setIndex = (value) => data.lightingDebugMode = (DebugLightingMode)value
};
internal static DebugUI.Widget CreateLightingFeatures(DebugDisplaySettingsLighting data) => new DebugUI.BitField
{
nameAndTooltip = Strings.LightingFeatures,
getter = () => data.lightingFeatureFlags,
setter = (value) => data.lightingFeatureFlags = (DebugLightingFeatureFlags)value,
enumType = typeof(DebugLightingFeatureFlags),
};
internal static DebugUI.Widget CreateHDRDebugMode(DebugDisplaySettingsLighting data) => new DebugUI.EnumField
{
nameAndTooltip = Strings.HDRDebugMode,
autoEnum = typeof(HDRDebugMode),
getter = () => (int)data.hdrDebugMode,
setter = (value) => data.hdrDebugMode = (HDRDebugMode)value,
getIndex = () => (int)data.hdrDebugMode,
setIndex = (value) => data.hdrDebugMode = (HDRDebugMode)value
};
}
[DisplayInfo(name = "Lighting", order = 3)]
[URPHelpURL("urp/features/rendering-debugger-reference", "lighting")]
internal class SettingsPanel : DebugDisplaySettingsPanel<DebugDisplaySettingsLighting>
{
public SettingsPanel(DebugDisplaySettingsLighting data)
: base(data)
{
AddWidget(new DebugUI.RuntimeDebugShadersMessageBox());
AddWidget(new DebugUI.Foldout
{
displayName = "Lighting Debug Modes",
opened = true,
children =
{
WidgetFactory.CreateLightingDebugMode(data),
WidgetFactory.CreateHDRDebugMode(data),
WidgetFactory.CreateLightingFeatures(data)
},
documentationUrl = typeof(DebugDisplaySettingsLighting).GetCustomAttribute<HelpURLAttribute>()?.URL
});
}
}
#region IDebugDisplaySettingsData
/// <inheritdoc/>
public bool AreAnySettingsActive => (lightingDebugMode != DebugLightingMode.None) || (lightingFeatureFlags != DebugLightingFeatureFlags.None) || (hdrDebugMode != HDRDebugMode.None);
/// <inheritdoc/>
public bool IsPostProcessingAllowed => (lightingDebugMode != DebugLightingMode.Reflections && lightingDebugMode != DebugLightingMode.ReflectionsWithSmoothness);
/// <inheritdoc/>
public bool IsLightingActive => true;
/// <inheritdoc/>
IDebugDisplaySettingsPanelDisposable IDebugDisplaySettingsData.CreatePanel()
{
return new SettingsPanel(this);
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e3df3f6511ee9d84fb93259d602ff2e5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,589 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using NameAndTooltip = UnityEngine.Rendering.DebugUI.Widget.NameAndTooltip;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Material-related Rendering Debugger settings.
/// </summary>
[Serializable]
public class DebugDisplaySettingsMaterial : IDebugDisplaySettingsData, ISerializedDebugDisplaySettings
{
#region Material validation
/// <summary>
/// Builtin presets for debug albedo validation.
/// </summary>
public enum AlbedoDebugValidationPreset
{
/// <summary> Use this for default luminance. </summary>
DefaultLuminance,
/// <summary> Use this for black acrylic paint. </summary>
BlackAcrylicPaint,
/// <summary> Use this for dark soil. </summary>
DarkSoil,
/// <summary> Use this for worn asphalt. </summary>
WornAsphalt,
/// <summary> Use this for dry clay soil. </summary>
DryClaySoil,
/// <summary> Use this for green grass. </summary>
GreenGrass,
/// <summary> Use this for old concrete. </summary>
OldConcrete,
/// <summary> Use this for red clay tile. </summary>
RedClayTile,
/// <summary> Use this for dry sand. </summary>
DrySand,
/// <summary> Use this for new concrete. </summary>
NewConcrete,
/// <summary> Use this for white acrylic paint. </summary>
WhiteAcrylicPaint,
/// <summary> Use this for fresh snow. </summary>
FreshSnow,
/// <summary> Use this for blue sky. </summary>
BlueSky,
/// <summary> Use this for foliage. </summary>
Foliage,
/// <summary> Use this for custom. </summary>
Custom
}
struct AlbedoDebugValidationPresetData
{
public string name;
public Color color;
public float minLuminance;
public float maxLuminance;
}
AlbedoDebugValidationPresetData[] m_AlbedoDebugValidationPresetData =
{
new AlbedoDebugValidationPresetData()
{
name = "Default Luminance",
color = new Color(127f / 255f, 127f / 255f, 127f / 255f),
minLuminance = 0.01f,
maxLuminance = 0.90f
},
// colors taken from http://www.babelcolor.com/index_htm_files/ColorChecker_RGB_and_spectra.xls
new AlbedoDebugValidationPresetData()
{
name = "Black Acrylic Paint",
color = new Color(56f / 255f, 56f / 255f, 56f / 255f),
minLuminance = 0.03f,
maxLuminance = 0.07f
},
new AlbedoDebugValidationPresetData()
{
name = "Dark Soil",
color = new Color(85f / 255f, 61f / 255f, 49f / 255f),
minLuminance = 0.05f,
maxLuminance = 0.14f
},
new AlbedoDebugValidationPresetData()
{
name = "Worn Asphalt",
color = new Color(91f / 255f, 91f / 255f, 91f / 255f),
minLuminance = 0.10f,
maxLuminance = 0.15f
},
new AlbedoDebugValidationPresetData()
{
name = "Dry Clay Soil",
color = new Color(137f / 255f, 120f / 255f, 102f / 255f),
minLuminance = 0.15f,
maxLuminance = 0.35f
},
new AlbedoDebugValidationPresetData()
{
name = "Green Grass",
color = new Color(123f / 255f, 131f / 255f, 74f / 255f),
minLuminance = 0.16f,
maxLuminance = 0.26f
},
new AlbedoDebugValidationPresetData()
{
name = "Old Concrete",
color = new Color(135f / 255f, 136f / 255f, 131f / 255f),
minLuminance = 0.17f,
maxLuminance = 0.30f
},
new AlbedoDebugValidationPresetData()
{
name = "Red Clay Tile",
color = new Color(197f / 255f, 125f / 255f, 100f / 255f),
minLuminance = 0.23f,
maxLuminance = 0.33f
},
new AlbedoDebugValidationPresetData()
{
name = "Dry Sand",
color = new Color(177f / 255f, 167f / 255f, 132f / 255f),
minLuminance = 0.20f,
maxLuminance = 0.45f
},
new AlbedoDebugValidationPresetData()
{
name = "New Concrete",
color = new Color(185f / 255f, 182f / 255f, 175f / 255f),
minLuminance = 0.32f,
maxLuminance = 0.55f
},
new AlbedoDebugValidationPresetData()
{
name = "White Acrylic Paint",
color = new Color(227f / 255f, 227f / 255f, 227f / 255f),
minLuminance = 0.75f,
maxLuminance = 0.85f
},
new AlbedoDebugValidationPresetData()
{
name = "Fresh Snow",
color = new Color(243f / 255f, 243f / 255f, 243f / 255f),
minLuminance = 0.85f,
maxLuminance = 0.95f
},
new AlbedoDebugValidationPresetData()
{
name = "Blue Sky",
color = new Color(93f / 255f, 123f / 255f, 157f / 255f),
minLuminance = new Color(93f / 255f, 123f / 255f, 157f / 255f).linear.maxColorComponent - 0.05f,
maxLuminance = new Color(93f / 255f, 123f / 255f, 157f / 255f).linear.maxColorComponent + 0.05f
},
new AlbedoDebugValidationPresetData()
{
name = "Foliage",
color = new Color(91f / 255f, 108f / 255f, 65f / 255f),
minLuminance = new Color(91f / 255f, 108f / 255f, 65f / 255f).linear.maxColorComponent - 0.05f,
maxLuminance = new Color(91f / 255f, 108f / 255f, 65f / 255f).linear.maxColorComponent + 0.05f
},
new AlbedoDebugValidationPresetData()
{
name = "Custom",
color = new Color(127f / 255f, 127f / 255f, 127f / 255f),
minLuminance = 0.01f,
maxLuminance = 0.90f
},
};
AlbedoDebugValidationPreset m_AlbedoValidationPreset;
/// <summary>
/// Current albedo debug validation preset.
/// </summary>
public AlbedoDebugValidationPreset albedoValidationPreset
{
get => m_AlbedoValidationPreset;
set
{
m_AlbedoValidationPreset = value;
AlbedoDebugValidationPresetData presetData = m_AlbedoDebugValidationPresetData[(int)value];
albedoMinLuminance = presetData.minLuminance;
albedoMaxLuminance = presetData.maxLuminance;
albedoCompareColor = presetData.color;
}
}
/// <summary>
/// Current minimum luminance threshold value for albedo validation.
/// Any albedo luminance values below this value will be considered invalid and will appear red on screen.
/// </summary>
public float albedoMinLuminance { get; set; } = 0.01f;
/// <summary>
/// Current maximum luminance threshold value for albedo validation.
/// Any albedo luminance values above this value will be considered invalid and will appear blue on screen.
/// </summary>
public float albedoMaxLuminance { get; set; } = 0.90f;
float m_AlbedoHueTolerance = 0.104f;
/// <summary>
/// Current hue tolerance value for albedo validation.
/// </summary>
public float albedoHueTolerance
{
get => m_AlbedoValidationPreset == AlbedoDebugValidationPreset.DefaultLuminance ? 1.0f : m_AlbedoHueTolerance;
set => m_AlbedoHueTolerance = value;
}
float m_AlbedoSaturationTolerance = 0.214f;
/// <summary>
/// Current saturation tolerance value for albedo validation.
/// </summary>
public float albedoSaturationTolerance
{
get => m_AlbedoValidationPreset == AlbedoDebugValidationPreset.DefaultLuminance ? 1.0f : m_AlbedoSaturationTolerance;
set => m_AlbedoSaturationTolerance = value;
}
/// <summary>
/// Current target color value for albedo validation.
/// </summary>
public Color albedoCompareColor { get; set; } = new Color(127f / 255f, 127f / 255f, 127f / 255f, 255f / 255f);
/// <summary>
/// Current minimum threshold value for metallic validation.
/// Any metallic values below this value will be considered invalid and will appear red on screen.
/// </summary>
public float metallicMinValue { get; set; } = 0.0f;
/// <summary>
/// Current maximum threshold value for metallic validation.
/// Any metallic values above this value will be considered invalid and will appear blue on screen.
/// </summary>
public float metallicMaxValue { get; set; } = 0.9f;
/// <summary>
/// Current value for filtering layers based on the selected light's rendering layers.
/// </summary>
public bool renderingLayersSelectedLight { get; set; } = false;
/// <summary>
/// Current value for filtering layers based on the selected light's shadow layers.
/// </summary>
public bool selectedLightShadowLayerMask { get; set; } = false;
/// <summary>
/// Current value for filtering layers.
/// </summary>
public uint renderingLayerMask { get; set; } = 0;
/// <summary>Rendering Layers Debug Colors.</summary>
public Vector4[] debugRenderingLayersColors = new Vector4[]
{
new Vector4(230, 159, 0) / 255,
new Vector4(86, 180, 233) / 255,
new Vector4(255, 182, 291) / 255,
new Vector4(0, 158, 115) / 255,
new Vector4(240, 228, 66) / 255,
new Vector4(0, 114, 178) / 255,
new Vector4(213, 94, 0) / 255,
new Vector4(170, 68, 170) / 255,
new Vector4(1.0f, 0.5f, 0.5f),
new Vector4(0.5f, 1.0f, 0.5f),
new Vector4(0.5f, 0.5f, 1.0f),
new Vector4(0.5f, 1.0f, 1.0f),
new Vector4(0.75f, 0.25f, 1.0f),
new Vector4(0.25f, 1.0f, 0.75f),
new Vector4(0.25f, 0.25f, 0.75f),
new Vector4(0.75f, 0.25f, 0.25f),
new Vector4(0.0f, 0.0f, 0.0f),
new Vector4(0.0f, 0.0f, 0.0f),
new Vector4(0.0f, 0.0f, 0.0f),
new Vector4(0.0f, 0.0f, 0.0f),
new Vector4(0.0f, 0.0f, 0.0f),
new Vector4(0.0f, 0.0f, 0.0f),
new Vector4(0.0f, 0.0f, 0.0f),
new Vector4(0.0f, 0.0f, 0.0f),
new Vector4(0.0f, 0.0f, 0.0f),
new Vector4(0.0f, 0.0f, 0.0f),
new Vector4(0.0f, 0.0f, 0.0f),
new Vector4(0.0f, 0.0f, 0.0f),
new Vector4(0.0f, 0.0f, 0.0f),
new Vector4(0.0f, 0.0f, 0.0f),
new Vector4(0.0f, 0.0f, 0.0f),
new Vector4(0.0f, 0.0f, 0.0f),
};
/// <summary>
/// Get the RenderingLayerMask used by the selected light
/// </summary>
/// <returns>Bitmask representing the RenderingLayerMask for the selected light.</returns>
public uint GetDebugLightLayersMask()
{
#if UNITY_EDITOR
if (renderingLayersSelectedLight)
{
if (UnityEditor.Selection.activeGameObject == null)
return 0;
var light = UnityEditor.Selection.activeGameObject.GetComponent<UniversalAdditionalLightData>();
if (light == null)
return 0;
if (selectedLightShadowLayerMask)
return light.shadowRenderingLayers;
return light.renderingLayers;
}
#endif
return 0xFFFF;
}
/// <summary>
/// Current material validation mode.
/// </summary>
public DebugMaterialValidationMode materialValidationMode { get; set; }
#endregion
/// <summary>
/// Current debug material mode.
/// </summary>
public DebugMaterialMode materialDebugMode { get; set; }
/// <summary>
/// Current debug vertex attribute mode.
/// </summary>
public DebugVertexAttributeMode vertexAttributeDebugMode { get; set; }
static class Strings
{
public const string AlbedoSettingsContainerName = "Albedo Settings";
public const string MetallicSettingsContainerName = "Metallic Settings";
public const string RenderingLayerMasksSettingsContainerName = "Rendering Layer Masks Settings";
public static readonly NameAndTooltip MaterialOverride = new() { name = "Material Override", tooltip = "Use the drop-down to select a Material property to visualize on every GameObject on screen." };
public static readonly NameAndTooltip VertexAttribute = new() { name = "Vertex Attribute", tooltip = "Use the drop-down to select a 3D GameObject attribute, like Texture Coordinates or Vertex Color, to visualize on screen." };
public static readonly NameAndTooltip MaterialValidationMode = new() { name = "Material Validation Mode", tooltip = "Debug and validate material properties." };
public static readonly NameAndTooltip RenderingLayersSelectedLight = new() { name = "Filter Rendering Layers by Light", tooltip = "Highlight Renderers affected by Selected Light" };
public static readonly NameAndTooltip SelectedLightShadowLayerMask = new() { name = "Use Light's Shadow Layer Mask", tooltip = "Highlight Renderers that cast shadows for the Selected Light" };
public static readonly NameAndTooltip FilterRenderingLayerMask = new() { name = "Filter Layers", tooltip = "Use the dropdown to filter Rendering Layers that you want to visualize" };
public static readonly NameAndTooltip ValidationPreset = new() { name = "Validation Preset", tooltip = "Validate using a list of preset surfaces and inputs based on real-world surfaces." };
public static readonly NameAndTooltip AlbedoCustomColor = new() { name = "Target Color", tooltip = "Custom target color for albedo validation." };
public static readonly NameAndTooltip AlbedoMinLuminance = new() { name = "Min Luminance", tooltip = "Any values set below this field are invalid and appear red on screen." };
public static readonly NameAndTooltip AlbedoMaxLuminance = new() { name = "Max Luminance", tooltip = "Any values set above this field are invalid and appear blue on screen." };
public static readonly NameAndTooltip AlbedoHueTolerance = new() { name = "Hue Tolerance", tooltip = "Validate a material based on a specific hue." };
public static readonly NameAndTooltip AlbedoSaturationTolerance = new() { name = "Saturation Tolerance", tooltip = "Validate a material based on a specific Saturation." };
public static readonly NameAndTooltip MetallicMinValue = new() { name = "Min Value", tooltip = "Any values set below this field are invalid and appear red on screen." };
public static readonly NameAndTooltip MetallicMaxValue = new() { name = "Max Value", tooltip = "Any values set above this field are invalid and appear blue on screen." };
}
internal static class WidgetFactory
{
internal static DebugUI.Widget CreateMaterialOverride(DebugDisplaySettingsMaterial data) => new DebugUI.EnumField
{
nameAndTooltip = Strings.MaterialOverride,
autoEnum = typeof(DebugMaterialMode),
getter = () => (int)data.materialDebugMode,
setter = (value) => data.materialDebugMode = (DebugMaterialMode)value,
getIndex = () => (int)data.materialDebugMode,
setIndex = (value) => data.materialDebugMode = (DebugMaterialMode)value
};
internal static DebugUI.Widget CreateVertexAttribute(DebugDisplaySettingsMaterial data) => new DebugUI.EnumField
{
nameAndTooltip = Strings.VertexAttribute,
autoEnum = typeof(DebugVertexAttributeMode),
getter = () => (int)data.vertexAttributeDebugMode,
setter = (value) => data.vertexAttributeDebugMode = (DebugVertexAttributeMode)value,
getIndex = () => (int)data.vertexAttributeDebugMode,
setIndex = (value) => data.vertexAttributeDebugMode = (DebugVertexAttributeMode)value
};
internal static DebugUI.Widget CreateMaterialValidationMode(DebugDisplaySettingsMaterial data) => new DebugUI.EnumField
{
nameAndTooltip = Strings.MaterialValidationMode,
autoEnum = typeof(DebugMaterialValidationMode),
getter = () => (int)data.materialValidationMode,
setter = (value) => data.materialValidationMode = (DebugMaterialValidationMode)value,
getIndex = () => (int)data.materialValidationMode,
setIndex = (value) => data.materialValidationMode = (DebugMaterialValidationMode)value
};
internal static DebugUI.Widget CreateRenderingLayersSelectedLight (DebugDisplaySettingsMaterial data) => new DebugUI.BoolField
{
nameAndTooltip = Strings.RenderingLayersSelectedLight,
getter = () => (bool)data.renderingLayersSelectedLight,
setter = (value) => data.renderingLayersSelectedLight = value,
flags = DebugUI.Flags.EditorOnly,
};
internal static DebugUI.Widget CreateSelectedLightShadowLayerMask(DebugDisplaySettingsMaterial data) => new DebugUI.BoolField
{
nameAndTooltip = Strings.SelectedLightShadowLayerMask,
getter = () => (bool)data.selectedLightShadowLayerMask,
setter = value => data.selectedLightShadowLayerMask = value,
flags = DebugUI.Flags.EditorOnly,
isHiddenCallback = () => !data.renderingLayersSelectedLight
};
internal static DebugUI.RenderingLayerField CreateFilterRenderingLayerMasks(DebugDisplaySettingsMaterial data)
{
var renderingLayersField = new DebugUI.RenderingLayerField()
{
nameAndTooltip = Strings.FilterRenderingLayerMask,
getter = () => data.renderingLayerMask,
setter = value => data.renderingLayerMask = value,
getRenderingLayerColor = index => data.debugRenderingLayersColors[index],
setRenderingLayerColor = (value, index) => data.debugRenderingLayersColors[index] = value,
isHiddenCallback = () => data.renderingLayersSelectedLight
};
return renderingLayersField;
}
internal static DebugUI.Widget CreateAlbedoPreset(DebugDisplaySettingsMaterial data) => new DebugUI.EnumField
{
nameAndTooltip = Strings.ValidationPreset,
autoEnum = typeof(AlbedoDebugValidationPreset),
getter = () => (int)data.albedoValidationPreset,
setter = (value) => data.albedoValidationPreset = (AlbedoDebugValidationPreset)value,
getIndex = () => (int)data.albedoValidationPreset,
setIndex = (value) => data.albedoValidationPreset = (AlbedoDebugValidationPreset)value
};
internal static DebugUI.Widget CreateAlbedoCustomColor(DebugDisplaySettingsMaterial data) => new DebugUI.ColorField()
{
nameAndTooltip = Strings.AlbedoCustomColor,
getter = () => data.albedoCompareColor,
setter = (value) => data.albedoCompareColor = value,
isHiddenCallback = () => data.albedoValidationPreset != AlbedoDebugValidationPreset.Custom
};
internal static DebugUI.Widget CreateAlbedoMinLuminance(DebugDisplaySettingsMaterial data) => new DebugUI.FloatField
{
nameAndTooltip = Strings.AlbedoMinLuminance,
getter = () => data.albedoMinLuminance,
setter = (value) => data.albedoMinLuminance = value,
incStep = 0.01f
};
internal static DebugUI.Widget CreateAlbedoMaxLuminance(DebugDisplaySettingsMaterial data) => new DebugUI.FloatField
{
nameAndTooltip = Strings.AlbedoMaxLuminance,
getter = () => data.albedoMaxLuminance,
setter = (value) => data.albedoMaxLuminance = value,
incStep = 0.01f
};
internal static DebugUI.Widget CreateAlbedoHueTolerance(DebugDisplaySettingsMaterial data) => new DebugUI.FloatField
{
nameAndTooltip = Strings.AlbedoHueTolerance,
getter = () => data.albedoHueTolerance,
setter = (value) => data.albedoHueTolerance = value,
incStep = 0.01f,
isHiddenCallback = () => data.albedoValidationPreset == AlbedoDebugValidationPreset.DefaultLuminance
};
internal static DebugUI.Widget CreateAlbedoSaturationTolerance(DebugDisplaySettingsMaterial data) => new DebugUI.FloatField
{
nameAndTooltip = Strings.AlbedoSaturationTolerance,
getter = () => data.albedoSaturationTolerance,
setter = (value) => data.albedoSaturationTolerance = value,
incStep = 0.01f,
isHiddenCallback = () => data.albedoValidationPreset == AlbedoDebugValidationPreset.DefaultLuminance
};
internal static DebugUI.Widget CreateMetallicMinValue(DebugDisplaySettingsMaterial data) => new DebugUI.FloatField
{
nameAndTooltip = Strings.MetallicMinValue,
getter = () => data.metallicMinValue,
setter = (value) => data.metallicMinValue = value,
incStep = 0.01f
};
internal static DebugUI.Widget CreateMetallicMaxValue(DebugDisplaySettingsMaterial data) => new DebugUI.FloatField
{
nameAndTooltip = Strings.MetallicMaxValue,
getter = () => data.metallicMaxValue,
setter = (value) => data.metallicMaxValue = value,
incStep = 0.01f
};
}
[DisplayInfo(name = "Material", order = 2)]
[URPHelpURL("urp/features/rendering-debugger-reference", "material")]
internal class SettingsPanel : DebugDisplaySettingsPanel<DebugDisplaySettingsMaterial>
{
public SettingsPanel(DebugDisplaySettingsMaterial data)
: base(data)
{
AddWidget(new DebugUI.RuntimeDebugShadersMessageBox());
AddWidget(new DebugUI.Foldout
{
displayName = "Material Filters",
opened = true,
children =
{
WidgetFactory.CreateMaterialOverride(data),
new DebugUI.Container()
{
displayName = Strings.RenderingLayerMasksSettingsContainerName,
isHiddenCallback = () => data.materialDebugMode != DebugMaterialMode.RenderingLayerMasks,
children =
{
WidgetFactory.CreateRenderingLayersSelectedLight(data),
WidgetFactory.CreateSelectedLightShadowLayerMask(data),
WidgetFactory.CreateFilterRenderingLayerMasks(data),
}
},
WidgetFactory.CreateVertexAttribute(data)
}
});
AddWidget(new DebugUI.Foldout
{
displayName = "Material Validation",
opened = true,
children =
{
WidgetFactory.CreateMaterialValidationMode(data),
new DebugUI.Container()
{
displayName = Strings.AlbedoSettingsContainerName,
isHiddenCallback = () => data.materialValidationMode != DebugMaterialValidationMode.Albedo,
children =
{
WidgetFactory.CreateAlbedoPreset(data),
WidgetFactory.CreateAlbedoCustomColor(data),
WidgetFactory.CreateAlbedoMinLuminance(data),
WidgetFactory.CreateAlbedoMaxLuminance(data),
WidgetFactory.CreateAlbedoHueTolerance(data),
WidgetFactory.CreateAlbedoSaturationTolerance(data)
}
},
new DebugUI.Container()
{
displayName = Strings.MetallicSettingsContainerName,
isHiddenCallback = () => data.materialValidationMode != DebugMaterialValidationMode.Metallic,
children =
{
WidgetFactory.CreateMetallicMinValue(data),
WidgetFactory.CreateMetallicMaxValue(data)
}
}
}
});
}
}
#region IDebugDisplaySettingsQuery
/// <inheritdoc/>
public bool AreAnySettingsActive =>
(materialDebugMode != DebugMaterialMode.None) ||
(vertexAttributeDebugMode != DebugVertexAttributeMode.None) ||
(materialValidationMode != DebugMaterialValidationMode.None);
/// <inheritdoc/>
public bool IsPostProcessingAllowed => !AreAnySettingsActive;
/// <inheritdoc/>
public bool IsLightingActive => !AreAnySettingsActive;
/// <inheritdoc/>
IDebugDisplaySettingsPanelDisposable IDebugDisplaySettingsData.CreatePanel()
{
return new SettingsPanel(this);
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b64304a6322ab44a3acc9758c949e286
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,721 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using NameAndTooltip = UnityEngine.Rendering.DebugUI.Widget.NameAndTooltip;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Debug wireframe modes.
/// </summary>
public enum DebugWireframeMode
{
/// <summary>No wireframe.</summary>
None,
/// <summary>Unfilled wireframe.</summary>
Wireframe,
/// <summary>Solid, filled wireframe.</summary>
SolidWireframe,
/// <summary>Solid, shaded wireframe.</summary>
ShadedWireframe,
}
/// <summary>
/// Rendering-related Rendering Debugger settings.
/// </summary>
[Serializable]
public class DebugDisplaySettingsRendering : IDebugDisplaySettingsData, ISerializedDebugDisplaySettings
{
// Under the hood, the implementation uses a single enum (DebugSceneOverrideMode). For UI & public API,
// we have split this enum into WireframeMode and a separate Overdraw boolean.
DebugWireframeMode m_WireframeMode = DebugWireframeMode.None;
/// <summary>
/// Current debug wireframe mode.
/// </summary>
public DebugWireframeMode wireframeMode
{
get => m_WireframeMode;
set
{
m_WireframeMode = value;
UpdateDebugSceneOverrideMode();
}
}
bool m_Overdraw = false;
/// <summary>
/// Whether debug overdraw mode is active.
/// </summary>
[Obsolete("overdraw has been deprecated. Use overdrawMode instead. #from(2022.2) #breakingFrom(2023.1)", true)]
public bool overdraw
{
get => m_Overdraw;
set
{
m_Overdraw = value;
UpdateDebugSceneOverrideMode();
}
}
DebugOverdrawMode m_OverdrawMode = DebugOverdrawMode.None;
/// <summary>
/// Which overdraw debug mode is active.
/// </summary>
public DebugOverdrawMode overdrawMode
{
get => m_OverdrawMode;
set
{
m_OverdrawMode = value;
UpdateDebugSceneOverrideMode();
}
}
/// <summary>
/// Maximum overdraw count for a single pixel.
///
/// This is used to setup the feedback range in when <see cref="overdrawMode"/> is active.
/// </summary>
public int maxOverdrawCount { get; set; } = 10;
void UpdateDebugSceneOverrideMode()
{
switch (wireframeMode)
{
case DebugWireframeMode.Wireframe:
sceneOverrideMode = DebugSceneOverrideMode.Wireframe;
break;
case DebugWireframeMode.SolidWireframe:
sceneOverrideMode = DebugSceneOverrideMode.SolidWireframe;
break;
case DebugWireframeMode.ShadedWireframe:
sceneOverrideMode = DebugSceneOverrideMode.ShadedWireframe;
break;
default:
sceneOverrideMode = overdrawMode != DebugOverdrawMode.None ? DebugSceneOverrideMode.Overdraw : DebugSceneOverrideMode.None;
break;
}
}
/// <summary>
/// Current debug fullscreen overlay mode.
/// </summary>
public DebugFullScreenMode fullScreenDebugMode { get; set; } = DebugFullScreenMode.None;
internal int stpDebugViewIndex { get; set; } = 0;
/// <summary>
/// Size of the debug fullscreen overlay, as percentage of the screen size.
/// </summary>
public int fullScreenDebugModeOutputSizeScreenPercent { get; set; } = 50;
internal DebugSceneOverrideMode sceneOverrideMode { get; set; } = DebugSceneOverrideMode.None;
/// <summary>
/// Texture mipmap streaming debug mode.
/// </summary>
public DebugMipInfoMode mipInfoMode { get; set; } = DebugMipInfoMode.None;
/// <summary>
/// Show detailed status codes for the Mipmap Streaming Status debug view.
/// </summary>
public bool mipDebugStatusShowCode { get; set; } = false;
/// <summary>
/// Aggregation mode for showing debug information per texture or aggregated for each material.
/// </summary>
public DebugMipMapStatusMode mipDebugStatusMode { get; set; } = DebugMipMapStatusMode.Material;
/// <summary>
/// Opacity of texture mipmap streaming debug colors.
/// </summary>
public float mipDebugOpacity { get; set; } = 1.0f;
/// <summary>
/// Timespan during which a texture upload should be visualized as recently updated.
/// </summary>
public float mipDebugRecentUpdateCooldown { get; set; } = 3.0f;
/// <summary>
/// The material texture slot for which texture mipmap streaming debug information is shown.
/// </summary>
public int mipDebugMaterialTextureSlot { get; set; } = 0;
/// <summary>
/// Whether to debug a specific texture slot in the material, or to show the debug data for the entire material.
///
/// By default we will show information for the entire material (and not a specific texture slot) where it makes sense.
/// </summary>
public bool showInfoForAllSlots { get; set; } = true;
internal bool canAggregateData {
get { return mipInfoMode == DebugMipInfoMode.MipStreamingStatus || mipInfoMode == DebugMipInfoMode.MipStreamingActivity; }
}
/// <summary>
/// The terrain layer for which texture mipmap streaming debug information is shown.
/// </summary>
public DebugMipMapModeTerrainTexture mipDebugTerrainTexture { get; set; } = DebugMipMapModeTerrainTexture.Control;
/// <summary>
/// Current debug post processing mode.
/// </summary>
public DebugPostProcessingMode postProcessingDebugMode { get; set; } = DebugPostProcessingMode.Auto;
/// <summary>
/// Whether MSAA is enabled.
/// </summary>
public bool enableMsaa { get; set; } = true;
/// <summary>
/// Whether HDR is enabled.
/// </summary>
public bool enableHDR { get; set; } = true;
/// <summary>
/// Current Temporal Anti-aliasing debug mode.
/// </summary>
public enum TaaDebugMode
{
/// <summary>The default non-debug TAA rendering.</summary>
None = 0,
/// <summary>Output the jittered raw frame render. TAA current frame influence 100%.</summary>
ShowRawFrame,
/// <summary>Output the raw frame render, but with jitter disabled. TAA current frame influence 100%.</summary>
ShowRawFrameNoJitter,
/// <summary>Output the clamped (rectified), reprojected TAA history. Current frame influence 0%.</summary>
ShowClampedHistory,
}
/// <summary>
/// Current TAA debug mode.
/// </summary>
public TaaDebugMode taaDebugMode { get; set; } = TaaDebugMode.None;
/// <summary>
/// Whether to block the Reflection Probe Atlas overlay display. Returns true when the relevant overlay is selected
/// but the main camera's rendering mode doesn't support displaying the Reflection Probe Atlas.
/// </summary>
internal bool blockReflectionProbeAtlasOverlay
{
get
{
var camera = Camera.main;
return camera == null ? false :
(fullScreenDebugMode == DebugFullScreenMode.ReflectionProbeAtlas && !(camera.GetUniversalAdditionalCameraData().scriptableRenderer as UniversalRenderer).usesClusterLightLoop);
}
}
/// <summary>
/// Whether to block the STP overlay display. Returns true when STP debug mode is selected
/// but the Universal Render Pipeline's upscaling filter is not set to STP.
/// </summary>
internal bool blockSTPOverlay {
get {
var asset = UniversalRenderPipeline.asset;
return asset != null && fullScreenDebugMode == DebugFullScreenMode.STP &&
#if ENABLE_UPSCALER_FRAMEWORK
asset.upscalerName != STPIUpscaler.upscalerName;
#else
asset.upscalingFilter != UpscalingFilterSelection.STP;
#endif
}
}
#region Pixel validation
/// <summary>
/// Current debug pixel validation mode.
/// </summary>
public DebugValidationMode validationMode { get; set; }
/// <summary>
/// Current validation channels for DebugValidationMode.HighlightOutsideOfRange.
/// </summary>
public PixelValidationChannels validationChannels { get; set; } = PixelValidationChannels.RGB;
/// <summary>
/// Current minimum threshold value for pixel validation.
/// Any values below this value will be considered invalid and will appear red on screen.
/// </summary>
public float validationRangeMin { get; set; } = 0.0f;
/// <summary>
/// Current maximum threshold value for pixel validation.
/// Any values above this value will be considered invalid and will appear blue on screen.
/// </summary>
public float validationRangeMax { get; set; } = 1.0f;
static class Strings
{
public const string RangeValidationSettingsContainerName = "Pixel Range Settings";
public static readonly NameAndTooltip MapOverlays = new() { name = "Map Overlays", tooltip = "Overlays render pipeline textures to validate the scene." };
public static readonly NameAndTooltip ReflectionProbeAtlasDebugWarning = new() { name = "Warning: Reflection Probe Atlas visualization not supported for the current rendering path. Switch to Forward+ or Deferred+ to use this debug view.", tooltip = "Switch to Forward+ or Deferred+ in the main camera's Universal Renderer Data asset to use this debug overlay." };
public static readonly NameAndTooltip StpDebugWarning = new() { name = "Warning: STP Overlay Not Active. Enable STP upscaling filter in the render pipeline asset to use these debug view.", tooltip = "Enable STP upscaling filter in the render pipeline asset to use these debug views." };
public static readonly NameAndTooltip StpDebugViews = new() { name = "STP Debug Views", tooltip = "Debug visualizations provided by STP." };
public static readonly NameAndTooltip MapSize = new() { name = "Map Size", tooltip = "Set the size of the render pipeline texture in the scene." };
public static readonly NameAndTooltip AdditionalWireframeModes = new() { name = "Additional Wireframe Modes", tooltip = "Debug the scene with additional wireframe shader views that are different from those in the scene view." };
public static readonly NameAndTooltip WireframeNotSupportedWarning = new() { name = "Warning: This platform might not support wireframe rendering.", tooltip = "Some platforms, for example, mobile platforms using OpenGL ES and Vulkan, might not support wireframe rendering." };
public static readonly NameAndTooltip OverdrawMode = new() { name = "Overdraw Mode", tooltip = "Debug anywhere materials that overdrawn pixels top of each other." };
public static readonly NameAndTooltip MaxOverdrawCount = new() { name = "Max Overdraw Count", tooltip = "Maximum overdraw count allowed for a single pixel." };
public static readonly NameAndTooltip MipMapDisableMipCaching = new() {name = "Disable Mip Caching", tooltip = "By disabling mip caching, the data on GPU accurately reflects what the TextureStreamer calculates. While this can significantly increase CPU-to-GPU traffic, it can be an invaluable tool to validate that the Streamer behaves as expected."};
public static readonly NameAndTooltip MipMapDebugView = new() { name = "Debug View", tooltip = "Use the drop-down to select a mipmap property to debug." };
public static readonly NameAndTooltip MipMapDebugOpacity = new() { name = "Debug Opacity", tooltip = "Opacity of texture mipmap streaming debug colors." };
public static readonly NameAndTooltip MipMapMaterialTextureSlot = new() { name = "Material Texture Slot", tooltip = "Use the drop-down to select the material texture slot to debug (does not affect terrain).\n\nThe slot indices follow the default order by which texture properties appear in the Material Inspector.\nThe default order is itself defined by the order in which (non-hidden) texture properties appear in the shader's \"Properties\" block." };
public static readonly NameAndTooltip MipMapTerrainTexture = new() { name = "Terrain Texture", tooltip = "Use the drop-down to select the terrain Texture to debug the mipmap for." };
public static readonly NameAndTooltip MipMapDisplayStatusCodes = new() { name = "Display Status Codes", tooltip = "Show detailed status codes indicating why textures are not streaming or highlighting points of attention." };
public static readonly NameAndTooltip MipMapActivityTimespan = new() { name = "Activity Timespan", tooltip = "How long a texture should be shown as \"recently updated\"." };
public static readonly NameAndTooltip MipMapCombinePerMaterial = new() { name = "Combined per Material", tooltip = "Combine the information over all slots per material." };
public static readonly NameAndTooltip PostProcessing = new() { name = "Post-processing", tooltip = "Override the controls for Post Processing in the scene." };
public static readonly NameAndTooltip MSAA = new() { name = "MSAA", tooltip = "Use the checkbox to disable MSAA in the scene." };
public static readonly NameAndTooltip HDR = new() { name = "HDR", tooltip = "Use the checkbox to disable High Dynamic Range in the scene." };
public static readonly NameAndTooltip TaaDebugMode = new() { name = "TAA Debug Mode", tooltip = "Choose whether to force TAA to output the raw jittered frame or clamped reprojected history." };
public static readonly NameAndTooltip PixelValidationMode = new() { name = "Pixel Validation Mode", tooltip = "Choose between modes that validate pixel on screen." };
public static readonly NameAndTooltip Channels = new() { name = "Channels", tooltip = "Choose the texture channel used to validate the scene." };
public static readonly NameAndTooltip ValueRangeMin = new() { name = "Value Range Min", tooltip = "Any values set below this field will be considered invalid and will appear red on screen." };
public static readonly NameAndTooltip ValueRangeMax = new() { name = "Value Range Max", tooltip = "Any values set above this field will be considered invalid and will appear blue on screen." };
}
#endregion
internal static class WidgetFactory
{
internal static DebugUI.Widget CreateMapOverlays(DebugDisplaySettingsRendering data) => new DebugUI.EnumField
{
nameAndTooltip = Strings.MapOverlays,
autoEnum = typeof(DebugFullScreenMode),
getter = () => (int)data.fullScreenDebugMode,
setter = (value) => data.fullScreenDebugMode = (DebugFullScreenMode)value,
getIndex = () => (int)data.fullScreenDebugMode,
setIndex = (value) => data.fullScreenDebugMode = (DebugFullScreenMode)value
};
internal static DebugUI.Widget CreateStpDebugViews(DebugDisplaySettingsRendering data) => new DebugUI.Container()
{
children =
{
new DebugUI.MessageBox
{
nameAndTooltip = Strings.StpDebugWarning,
style = DebugUI.MessageBox.Style.Warning,
isHiddenCallback = () => !data.blockSTPOverlay,
},
new DebugUI.EnumField
{
nameAndTooltip = Strings.StpDebugViews,
isHiddenCallback = () => data.fullScreenDebugMode != DebugFullScreenMode.STP,
enumNames = STP.debugViewDescriptions,
enumValues = STP.debugViewIndices,
getter = () => (int)data.stpDebugViewIndex,
setter = (value) => data.stpDebugViewIndex = value,
getIndex = () => (int)data.stpDebugViewIndex,
setIndex = (value) => data.stpDebugViewIndex = value
}
}
};
internal static DebugUI.Widget CreateMapOverlaySize(DebugDisplaySettingsRendering data) => new DebugUI.Container()
{
children =
{
new DebugUI.MessageBox
{
nameAndTooltip = Strings.ReflectionProbeAtlasDebugWarning,
style = DebugUI.MessageBox.Style.Warning,
isHiddenCallback = () => !data.blockReflectionProbeAtlasOverlay,
},
new DebugUI.IntField
{
nameAndTooltip = Strings.MapSize,
isHiddenCallback = () => data.blockReflectionProbeAtlasOverlay,
getter = () => data.fullScreenDebugModeOutputSizeScreenPercent,
setter = value => data.fullScreenDebugModeOutputSizeScreenPercent = value,
incStep = 10,
incStepMult = 50,
min = () => 0,
max = () => 100
}
}
};
internal static DebugUI.Widget CreateAdditionalWireframeShaderViews(DebugDisplaySettingsRendering data) => new DebugUI.EnumField
{
nameAndTooltip = Strings.AdditionalWireframeModes,
autoEnum = typeof(DebugWireframeMode),
getter = () => (int)data.wireframeMode,
setter = (value) => data.wireframeMode = (DebugWireframeMode)value,
getIndex = () => (int)data.wireframeMode,
setIndex = (value) => data.wireframeMode = (DebugWireframeMode)value
};
internal static DebugUI.Widget CreateWireframeNotSupportedWarning(DebugDisplaySettingsRendering data) => new DebugUI.MessageBox
{
nameAndTooltip = Strings.WireframeNotSupportedWarning,
style = DebugUI.MessageBox.Style.Warning,
isHiddenCallback = () =>
{
#if UNITY_EDITOR
return true;
#else
switch (SystemInfo.graphicsDeviceType)
{
case GraphicsDeviceType.OpenGLES3:
case GraphicsDeviceType.Vulkan:
return data.wireframeMode == DebugWireframeMode.None;
default:
return true;
}
#endif
}
};
internal static DebugUI.Widget CreateOverdrawMode(DebugDisplaySettingsRendering data) => new DebugUI.EnumField()
{
nameAndTooltip = Strings.OverdrawMode,
autoEnum = typeof(DebugOverdrawMode),
getter = () => (int)data.overdrawMode,
setter = (value) => data.overdrawMode = (DebugOverdrawMode)value,
getIndex = () => (int)data.overdrawMode,
setIndex = (value) => data.overdrawMode = (DebugOverdrawMode)value
};
internal static DebugUI.Widget CreateMaxOverdrawCount(DebugDisplaySettingsRendering data) => new DebugUI.Container()
{
isHiddenCallback = () => data.overdrawMode == DebugOverdrawMode.None,
children =
{
new DebugUI.IntField
{
nameAndTooltip = Strings.MaxOverdrawCount,
getter = () => data.maxOverdrawCount,
setter = value => data.maxOverdrawCount = value,
incStep = 10,
min = () => 1,
max = () => 500
}
}
};
internal static DebugUI.Widget CreateMipMapDebugWidget(DebugDisplaySettingsRendering data) => new DebugUI.Container()
{
displayName = "Mipmap Streaming",
children =
{
new DebugUI.BoolField()
{
nameAndTooltip = Strings.MipMapDisableMipCaching,
getter = () => Texture.streamingTextureDiscardUnusedMips,
setter = (value) => Texture.streamingTextureDiscardUnusedMips = value,
},
CreateMipMapMode(data),
CreateMipMapDebugSettings(data)
}
};
internal static DebugUI.Widget CreateMipMapMode(DebugDisplaySettingsRendering data) => new DebugUI.EnumField()
{
nameAndTooltip = Strings.MipMapDebugView,
autoEnum = typeof(DebugMipInfoMode),
getter = () => (int)data.mipInfoMode,
setter = (value) => data.mipInfoMode = (DebugMipInfoMode)value,
getIndex = () => (int)data.mipInfoMode,
setIndex = (value) => data.mipInfoMode = (DebugMipInfoMode)value
};
internal static DebugUI.Widget CreateMipMapDebugSettings(DebugDisplaySettingsRendering data)
{
const int maxMaterialTextureSlotCount = 64;
GUIContent[] texSlotStrings = new GUIContent[maxMaterialTextureSlotCount];
int[] texSlotValues = new int[maxMaterialTextureSlotCount];
for (int i = 0; i < maxMaterialTextureSlotCount; ++i)
{
texSlotStrings[i] = new GUIContent(string.Format("Slot {0}", i));
texSlotValues[i] = i;
}
return new DebugUI.Container()
{
isHiddenCallback = () => data.mipInfoMode == DebugMipInfoMode.None,
children =
{
new DebugUI.FloatField
{
nameAndTooltip = Strings.MipMapDebugOpacity,
getter = () => data.mipDebugOpacity,
setter = value => { data.mipDebugOpacity = value; },
min = () => 0.0f,
max = () => 1.0f
},
CreateMipMapDebugSlotSelector(data, () => data.canAggregateData, texSlotStrings, texSlotValues), // if we can aggregate, we want to show this under a checkbox instead (see next)
new DebugUI.BoolField()
{
isHiddenCallback = () => !data.canAggregateData,
nameAndTooltip = Strings.MipMapCombinePerMaterial,
getter = () => data.showInfoForAllSlots,
setter = value =>
{
data.showInfoForAllSlots = value;
data.mipDebugStatusMode = value ? DebugMipMapStatusMode.Material : DebugMipMapStatusMode.Texture;
},
},
new DebugUI.Container()
{
isHiddenCallback = () => !data.canAggregateData || data.showInfoForAllSlots,
children =
{
CreateMipMapDebugSlotSelector(data, () => false, texSlotStrings, texSlotValues),
CreateMipMapShowStatusCodeToggle(data)
}
},
new DebugUI.EnumField
{
nameAndTooltip = Strings.MipMapTerrainTexture,
getter = () => (int)data.mipDebugTerrainTexture,
setter = value => data.mipDebugTerrainTexture = (DebugMipMapModeTerrainTexture)value,
autoEnum = typeof(DebugMipMapModeTerrainTexture),
getIndex = () => (int)data.mipDebugTerrainTexture,
setIndex = value => data.mipDebugTerrainTexture = (DebugMipMapModeTerrainTexture)value
},
CreateMipMapDebugCooldownSlider(data)
}
};
}
internal static DebugUI.Widget CreateMipMapDebugSlotSelector(DebugDisplaySettingsRendering data, Func<bool> hiddenCB, GUIContent[] texSlotStrings, int[] texSlotValues) => new DebugUI.EnumField()
{
isHiddenCallback = hiddenCB,
nameAndTooltip = Strings.MipMapMaterialTextureSlot,
getter = () => data.mipDebugMaterialTextureSlot,
setter = value => data.mipDebugMaterialTextureSlot = value,
getIndex = () => data.mipDebugMaterialTextureSlot,
setIndex = value => data.mipDebugMaterialTextureSlot = value,
enumNames = texSlotStrings,
enumValues = texSlotValues,
};
internal static DebugUI.Widget CreateMipMapDebugCooldownSlider(DebugDisplaySettingsRendering data) => new DebugUI.FloatField()
{
isHiddenCallback = () => data.mipInfoMode != DebugMipInfoMode.MipStreamingActivity,
nameAndTooltip = Strings.MipMapActivityTimespan,
getter = () => data.mipDebugRecentUpdateCooldown,
setter = value => data.mipDebugRecentUpdateCooldown = value,
min = () => 0.0f,
max = () => 60.0f
};
internal static DebugUI.Widget CreateMipMapShowStatusCodeToggle(DebugDisplaySettingsRendering data) => new DebugUI.BoolField()
{
isHiddenCallback = () => data.mipInfoMode != DebugMipInfoMode.MipStreamingStatus,
nameAndTooltip = Strings.MipMapDisplayStatusCodes,
getter = () => data.mipDebugStatusShowCode,
setter = (value) => data.mipDebugStatusShowCode = value,
};
internal static DebugUI.Widget CreatePostProcessing(DebugDisplaySettingsRendering data) => new DebugUI.EnumField
{
nameAndTooltip = Strings.PostProcessing,
autoEnum = typeof(DebugPostProcessingMode),
getter = () => (int)data.postProcessingDebugMode,
setter = (value) => data.postProcessingDebugMode = (DebugPostProcessingMode)value,
getIndex = () => (int)data.postProcessingDebugMode,
setIndex = (value) => data.postProcessingDebugMode = (DebugPostProcessingMode)value
};
internal static DebugUI.Widget CreateMSAA(DebugDisplaySettingsRendering data) => new DebugUI.BoolField
{
nameAndTooltip = Strings.MSAA,
getter = () => data.enableMsaa,
setter = (value) => data.enableMsaa = value
};
internal static DebugUI.Widget CreateHDR(DebugDisplaySettingsRendering data) => new DebugUI.BoolField
{
nameAndTooltip = Strings.HDR,
getter = () => data.enableHDR,
setter = (value) => data.enableHDR = value
};
internal static DebugUI.Widget CreateTaaDebugMode(DebugDisplaySettingsRendering data) => new DebugUI.EnumField
{
nameAndTooltip = Strings.TaaDebugMode,
autoEnum = typeof(TaaDebugMode),
getter = () => (int)data.taaDebugMode,
setter = (value) => data.taaDebugMode = (TaaDebugMode)value,
getIndex = () => (int)data.taaDebugMode,
setIndex = (value) => data.taaDebugMode = (TaaDebugMode)value
};
internal static DebugUI.Widget CreatePixelValidationMode(DebugDisplaySettingsRendering data) => new DebugUI.EnumField
{
nameAndTooltip = Strings.PixelValidationMode,
autoEnum = typeof(DebugValidationMode),
getter = () => (int)data.validationMode,
setter = (value) => data.validationMode = (DebugValidationMode)value,
getIndex = () => (int)data.validationMode,
setIndex = (value) => data.validationMode = (DebugValidationMode)value
};
internal static DebugUI.Widget CreatePixelValidationChannels(DebugDisplaySettingsRendering data) => new DebugUI.EnumField
{
nameAndTooltip = Strings.Channels,
autoEnum = typeof(PixelValidationChannels),
getter = () => (int)data.validationChannels,
setter = (value) => data.validationChannels = (PixelValidationChannels)value,
getIndex = () => (int)data.validationChannels,
setIndex = (value) => data.validationChannels = (PixelValidationChannels)value
};
internal static DebugUI.Widget CreatePixelValueRangeMin(DebugDisplaySettingsRendering data) => new DebugUI.FloatField
{
nameAndTooltip = Strings.ValueRangeMin,
getter = () => data.validationRangeMin,
setter = (value) => data.validationRangeMin = value,
incStep = 0.01f
};
internal static DebugUI.Widget CreatePixelValueRangeMax(DebugDisplaySettingsRendering data) => new DebugUI.FloatField
{
nameAndTooltip = Strings.ValueRangeMax,
getter = () => data.validationRangeMax,
setter = (value) => data.validationRangeMax = value,
incStep = 0.01f
};
}
[DisplayInfo(name = "Rendering", order = 1)]
[URPHelpURL("urp/features/rendering-debugger-reference", "rendering")]
internal class SettingsPanel : DebugDisplaySettingsPanel<DebugDisplaySettingsRendering>
{
public SettingsPanel(DebugDisplaySettingsRendering data)
: base(data)
{
AddWidget(new DebugUI.RuntimeDebugShadersMessageBox());
AddWidget(new DebugUI.Foldout
{
displayName = "Rendering Debug",
opened = true,
children =
{
WidgetFactory.CreateMapOverlays(data),
WidgetFactory.CreateStpDebugViews(data),
WidgetFactory.CreateMapOverlaySize(data),
WidgetFactory.CreateHDR(data),
WidgetFactory.CreateMSAA(data),
WidgetFactory.CreateTaaDebugMode(data),
WidgetFactory.CreatePostProcessing(data),
WidgetFactory.CreateAdditionalWireframeShaderViews(data),
WidgetFactory.CreateWireframeNotSupportedWarning(data),
WidgetFactory.CreateOverdrawMode(data),
WidgetFactory.CreateMaxOverdrawCount(data),
WidgetFactory.CreateMipMapDebugWidget(data)
}
});
AddWidget(new DebugUI.Foldout
{
displayName = "Pixel Validation",
opened = true,
children =
{
WidgetFactory.CreatePixelValidationMode(data),
new DebugUI.Container()
{
displayName = Strings.RangeValidationSettingsContainerName,
isHiddenCallback = () => data.validationMode != DebugValidationMode.HighlightOutsideOfRange,
children =
{
WidgetFactory.CreatePixelValidationChannels(data),
WidgetFactory.CreatePixelValueRangeMin(data),
WidgetFactory.CreatePixelValueRangeMax(data)
}
}
}
});
AddWidget(new DebugUI.Foldout
{
displayName = "HDR Output",
opened = true,
children =
{
new DebugUI.MessageBox
{
displayName = "The values in the Rendering Debugger editor window might not be accurate. Please use the Rendering Debugger Overlay instead (Ctrl+Backspace in Play mode).",
style = DebugUI.MessageBox.Style.Warning,
flags = DebugUI.Flags.EditorOnly
},
DebugDisplaySettingsHDROutput.CreateHDROuputDisplayTable()
}
});
}
}
#region IDebugDisplaySettingsData
/// <inheritdoc/>
public bool AreAnySettingsActive => (postProcessingDebugMode != DebugPostProcessingMode.Auto) ||
(fullScreenDebugMode != DebugFullScreenMode.None) ||
(sceneOverrideMode != DebugSceneOverrideMode.None) ||
(mipInfoMode != DebugMipInfoMode.None) ||
(validationMode != DebugValidationMode.None) ||
!enableMsaa ||
!enableHDR ||
(taaDebugMode != TaaDebugMode.None);
/// <inheritdoc/>
public bool IsPostProcessingAllowed => (postProcessingDebugMode != DebugPostProcessingMode.Disabled) &&
(sceneOverrideMode == DebugSceneOverrideMode.None) &&
(mipInfoMode == DebugMipInfoMode.None);
/// <inheritdoc/>
public bool IsLightingActive => (sceneOverrideMode == DebugSceneOverrideMode.None) &&
(mipInfoMode == DebugMipInfoMode.None);
/// <inheritdoc/>
public bool TryGetScreenClearColor(ref Color color)
{
if (mipInfoMode != DebugMipInfoMode.None)
{
color = Color.black;
return true;
}
switch (sceneOverrideMode)
{
case DebugSceneOverrideMode.None:
case DebugSceneOverrideMode.ShadedWireframe:
return false;
case DebugSceneOverrideMode.Overdraw:
color = Color.black;
return true;
case DebugSceneOverrideMode.Wireframe:
case DebugSceneOverrideMode.SolidWireframe:
color = new Color(0.1f, 0.1f, 0.1f, 1.0f);
return true;
default:
throw new ArgumentOutOfRangeException(nameof(color));
}
}
/// <inheritdoc/>
IDebugDisplaySettingsPanelDisposable IDebugDisplaySettingsData.CreatePanel()
{
return new SettingsPanel(this);
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6f1482d9a0a18492f96f7cae7df31add
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,661 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using UnityEditor;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering.RenderGraphModule;
namespace UnityEngine.Rendering.Universal
{
class DebugHandler : IDebugDisplaySettingsQuery
{
#region Property Id Constants
static readonly int k_DebugColorInvalidModePropertyId = Shader.PropertyToID("_DebugColorInvalidMode");
static readonly int k_DebugCurrentRealTimeId = Shader.PropertyToID("_DebugCurrentRealTime");
static readonly int k_DebugColorPropertyId = Shader.PropertyToID("_DebugColor");
static readonly int k_DebugTexturePropertyId = Shader.PropertyToID("_DebugTexture");
static readonly int k_DebugFontId = Shader.PropertyToID("_DebugFont");
static readonly int k_DebugTextureNoStereoPropertyId = Shader.PropertyToID("_DebugTextureNoStereo");
static readonly int k_DebugTextureDisplayRect = Shader.PropertyToID("_DebugTextureDisplayRect");
static readonly int k_DebugRenderTargetSupportsStereo = Shader.PropertyToID("_DebugRenderTargetSupportsStereo");
static readonly int k_DebugRenderTargetRangeRemap = Shader.PropertyToID("_DebugRenderTargetRangeRemap");
// Material settings...
static readonly int k_DebugMaterialModeId = Shader.PropertyToID("_DebugMaterialMode");
static readonly int k_DebugVertexAttributeModeId = Shader.PropertyToID("_DebugVertexAttributeMode");
static readonly int k_DebugMaterialValidationModeId = Shader.PropertyToID("_DebugMaterialValidationMode");
// Rendering settings...
static readonly int k_DebugMipInfoModeId = Shader.PropertyToID("_DebugMipInfoMode");
static readonly int k_DebugMipMapStatusModeId = Shader.PropertyToID("_DebugMipMapStatusMode");
static readonly int k_DebugMipMapShowStatusCodeId = Shader.PropertyToID("_DebugMipMapShowStatusCode");
static readonly int k_DebugMipMapOpacityId = Shader.PropertyToID("_DebugMipMapOpacity");
static readonly int k_DebugMipMapRecentlyUpdatedCooldownId = Shader.PropertyToID("_DebugMipMapRecentlyUpdatedCooldown");
static readonly int k_DebugMipMapTerrainTextureModeId = Shader.PropertyToID("_DebugMipMapTerrainTextureMode");
static readonly int k_DebugSceneOverrideModeId = Shader.PropertyToID("_DebugSceneOverrideMode");
static readonly int k_DebugFullScreenModeId = Shader.PropertyToID("_DebugFullScreenMode");
static readonly int k_DebugValidationModeId = Shader.PropertyToID("_DebugValidationMode");
static readonly int k_DebugValidateBelowMinThresholdColorPropertyId = Shader.PropertyToID("_DebugValidateBelowMinThresholdColor");
static readonly int k_DebugValidateAboveMaxThresholdColorPropertyId = Shader.PropertyToID("_DebugValidateAboveMaxThresholdColor");
static readonly int k_DebugMaxPixelCost = Shader.PropertyToID("_DebugMaxPixelCost");
// Lighting settings...
static readonly int k_DebugLightingModeId = Shader.PropertyToID("_DebugLightingMode");
static readonly int k_DebugLightingFeatureFlagsId = Shader.PropertyToID("_DebugLightingFeatureFlags");
static readonly int k_DebugValidateAlbedoMinLuminanceId = Shader.PropertyToID("_DebugValidateAlbedoMinLuminance");
static readonly int k_DebugValidateAlbedoMaxLuminanceId = Shader.PropertyToID("_DebugValidateAlbedoMaxLuminance");
static readonly int k_DebugValidateAlbedoSaturationToleranceId = Shader.PropertyToID("_DebugValidateAlbedoSaturationTolerance");
static readonly int k_DebugValidateAlbedoHueToleranceId = Shader.PropertyToID("_DebugValidateAlbedoHueTolerance");
static readonly int k_DebugValidateAlbedoCompareColorId = Shader.PropertyToID("_DebugValidateAlbedoCompareColor");
static readonly int k_DebugValidateMetallicMinValueId = Shader.PropertyToID("_DebugValidateMetallicMinValue");
static readonly int k_DebugValidateMetallicMaxValueId = Shader.PropertyToID("_DebugValidateMetallicMaxValue");
static readonly int k_ValidationChannelsId = Shader.PropertyToID("_ValidationChannels");
static readonly int k_RangeMinimumId = Shader.PropertyToID("_RangeMinimum");
static readonly int k_RangeMaximumId = Shader.PropertyToID("_RangeMaximum");
#endregion
#region Pass Data
private static readonly ProfilingSampler s_DebugSetupSampler = new ProfilingSampler("Setup Debug Properties");
private static readonly ProfilingSampler s_DebugFinalValidationSampler = new ProfilingSampler(nameof(UpdateShaderGlobalPropertiesForFinalValidationPass));
DebugSetupPassData s_DebugSetupPassData = new DebugSetupPassData();
DebugFinalValidationPassData s_DebugFinalValidationPassData = new DebugFinalValidationPassData();
#endregion
readonly Material m_ReplacementMaterial;
readonly Material m_HDRDebugViewMaterial;
HDRDebugViewPass m_HDRDebugViewPass;
RTHandle m_DebugScreenColorHandle;
RTHandle m_DebugScreenDepthHandle;
readonly UniversalRenderPipelineRuntimeTextures m_RuntimeTextures;
bool m_HasDebugRenderTarget;
bool m_DebugRenderTargetSupportsStereo;
Vector4 m_DebugRenderTargetPixelRect;
Vector4 m_DebugRenderTargetRangeRemap;
RTHandle m_DebugRenderTarget;
RTHandle m_DebugFontTexture;
private GraphicsBuffer m_debugDisplayConstant;
readonly UniversalRenderPipelineDebugDisplaySettings m_DebugDisplaySettings;
DebugDisplaySettingsLighting LightingSettings => m_DebugDisplaySettings.lightingSettings;
DebugDisplaySettingsMaterial MaterialSettings => m_DebugDisplaySettings.materialSettings;
DebugDisplaySettingsRendering RenderingSettings => m_DebugDisplaySettings.renderingSettings;
#region IDebugDisplaySettingsQuery
/// <inheritdoc/>
public bool AreAnySettingsActive => m_DebugDisplaySettings.AreAnySettingsActive;
/// <inheritdoc/>
public bool IsPostProcessingAllowed => m_DebugDisplaySettings.IsPostProcessingAllowed;
/// <inheritdoc/>
public bool IsLightingActive => m_DebugDisplaySettings.IsLightingActive;
// These modes would require putting custom data into gbuffer, so instead we just disable deferred mode.
internal bool IsActiveModeUnsupportedForDeferred =>
m_DebugDisplaySettings.lightingSettings.lightingDebugMode != DebugLightingMode.None ||
m_DebugDisplaySettings.lightingSettings.lightingFeatureFlags != DebugLightingFeatureFlags.None ||
m_DebugDisplaySettings.renderingSettings.sceneOverrideMode != DebugSceneOverrideMode.None ||
m_DebugDisplaySettings.materialSettings.materialDebugMode != DebugMaterialMode.None ||
m_DebugDisplaySettings.materialSettings.vertexAttributeDebugMode != DebugVertexAttributeMode.None ||
m_DebugDisplaySettings.materialSettings.materialValidationMode != DebugMaterialValidationMode.None ||
m_DebugDisplaySettings.renderingSettings.mipInfoMode != DebugMipInfoMode.None;
/// <inheritdoc/>
public bool TryGetScreenClearColor(ref Color color)
{
return m_DebugDisplaySettings.TryGetScreenClearColor(ref color);
}
#endregion
internal Material ReplacementMaterial => m_ReplacementMaterial;
internal UniversalRenderPipelineDebugDisplaySettings DebugDisplaySettings => m_DebugDisplaySettings;
internal ref RTHandle DebugScreenColorHandle => ref m_DebugScreenColorHandle;
internal ref RTHandle DebugScreenDepthHandle => ref m_DebugScreenDepthHandle;
internal HDRDebugViewPass hdrDebugViewPass => m_HDRDebugViewPass;
internal bool HDRDebugViewIsActive(bool resolveFinalTarget)
{
// HDR debug views should only apply to the last camera in the stack
return m_HDRDebugViewMaterial != null && DebugDisplaySettings.lightingSettings.hdrDebugMode != HDRDebugMode.None && resolveFinalTarget;
}
internal bool WriteToDebugScreenTexture(bool resolveFinalTarget)
{
return HDRDebugViewIsActive(resolveFinalTarget);
}
internal bool IsScreenClearNeeded
{
get
{
Color color = Color.black;
return TryGetScreenClearColor(ref color);
}
}
internal bool IsRenderPassSupported
{
get
{
return RenderingSettings.sceneOverrideMode == DebugSceneOverrideMode.None || RenderingSettings.sceneOverrideMode == DebugSceneOverrideMode.Overdraw;
}
}
internal bool IsDepthPrimingCompatible => RenderingSettings.sceneOverrideMode != DebugSceneOverrideMode.Wireframe;
internal int stpDebugViewIndex { get { return RenderingSettings.stpDebugViewIndex; } }
internal DebugHandler()
{
m_DebugDisplaySettings = UniversalRenderPipelineDebugDisplaySettings.Instance;
if (GraphicsSettings.TryGetRenderPipelineSettings<UniversalRenderPipelineDebugShaders>(out var shaders))
{
m_ReplacementMaterial = (shaders.debugReplacementPS != null) ? CoreUtils.CreateEngineMaterial(shaders.debugReplacementPS) : null;
m_HDRDebugViewMaterial = (shaders.hdrDebugViewPS != null) ? CoreUtils.CreateEngineMaterial(shaders.hdrDebugViewPS) : null;
}
m_HDRDebugViewPass = new HDRDebugViewPass(m_HDRDebugViewMaterial);
m_RuntimeTextures = GraphicsSettings.GetRenderPipelineSettings<UniversalRenderPipelineRuntimeTextures>();
if (m_RuntimeTextures != null)
{
m_DebugFontTexture = RTHandles.Alloc(m_RuntimeTextures.debugFontTexture);
}
m_debugDisplayConstant = new GraphicsBuffer(GraphicsBuffer.Target.Constant, 32, Marshal.SizeOf(typeof(Vector4)));
}
public void Dispose()
{
m_HDRDebugViewPass.Dispose();
m_DebugScreenColorHandle?.Release();
m_DebugScreenDepthHandle?.Release();
m_DebugFontTexture?.Release();
m_debugDisplayConstant.Dispose();
CoreUtils.Destroy(m_HDRDebugViewMaterial);
CoreUtils.Destroy(m_ReplacementMaterial);
}
internal bool IsActiveForCamera(bool isPreviewCamera)
{
return !isPreviewCamera && AreAnySettingsActive;
}
internal bool TryGetFullscreenDebugMode(out DebugFullScreenMode debugFullScreenMode)
{
return TryGetFullscreenDebugMode(out debugFullScreenMode, out _);
}
internal bool TryGetFullscreenDebugMode(out DebugFullScreenMode debugFullScreenMode, out int textureHeightPercent)
{
debugFullScreenMode = RenderingSettings.fullScreenDebugMode;
textureHeightPercent = RenderingSettings.fullScreenDebugModeOutputSizeScreenPercent;
if (RenderingSettings.blockSTPOverlay)
return false;
return debugFullScreenMode != DebugFullScreenMode.None;
}
internal static void ConfigureColorDescriptorForDebugScreen(ref RenderTextureDescriptor descriptor, int cameraWidth, int cameraHeight)
{
descriptor.width = cameraWidth;
descriptor.height = cameraHeight;
descriptor.useMipMap = false;
descriptor.autoGenerateMips = false;
descriptor.useDynamicScale = true;
descriptor.depthStencilFormat = GraphicsFormat.None;
}
internal static void ConfigureDepthDescriptorForDebugScreen(ref RenderTextureDescriptor descriptor, GraphicsFormat depthStencilFormat, int cameraWidth, int cameraHeight)
{
descriptor.width = cameraWidth;
descriptor.height = cameraHeight;
descriptor.useMipMap = false;
descriptor.autoGenerateMips = false;
descriptor.useDynamicScale = true;
descriptor.depthStencilFormat = depthStencilFormat;
descriptor.graphicsFormat = GraphicsFormat.None;
}
[Conditional("UNITY_ENABLE_CHECKS")]
internal void SetupShaderProperties(RasterCommandBuffer cmd, int passIndex = 0)
{
if (LightingSettings.lightingDebugMode == DebugLightingMode.ShadowCascades)
{
// we disable cubemap reflections, too distracting (in TemplateLWRP for ex.)
cmd.EnableShaderKeyword("_DEBUG_ENVIRONMENTREFLECTIONS_OFF");
}
else
{
cmd.DisableShaderKeyword("_DEBUG_ENVIRONMENTREFLECTIONS_OFF");
}
m_debugDisplayConstant.SetData(MaterialSettings.debugRenderingLayersColors, 0, 0, 32);
cmd.SetGlobalConstantBuffer(m_debugDisplayConstant, "_DebugDisplayConstant", 0, m_debugDisplayConstant.count * m_debugDisplayConstant.stride);
if (MaterialSettings.renderingLayersSelectedLight)
cmd.SetGlobalInt("_DebugRenderingLayerMask", (int)MaterialSettings.GetDebugLightLayersMask());
else
cmd.SetGlobalInt("_DebugRenderingLayerMask", (int)MaterialSettings.renderingLayerMask);
switch (RenderingSettings.sceneOverrideMode)
{
case DebugSceneOverrideMode.Overdraw:
{
// Target texture can contains only a value between 0 and 1
// So we encode the number of overdraw in the range (0, max displayed overdaw count)
// The value will be clamped by the GPU driver
var value = 1 / (float)RenderingSettings.maxOverdrawCount;
cmd.SetGlobalColor(k_DebugColorPropertyId, new Color(value, value, value, 1));
break;
}
case DebugSceneOverrideMode.Wireframe:
{
cmd.SetGlobalColor(k_DebugColorPropertyId, Color.black);
break;
}
case DebugSceneOverrideMode.SolidWireframe:
{
cmd.SetGlobalColor(k_DebugColorPropertyId, (passIndex == 0) ? Color.white : Color.black);
break;
}
case DebugSceneOverrideMode.ShadedWireframe:
{
if (passIndex == 0)
{
cmd.SetKeyword(ShaderGlobalKeywords.DEBUG_DISPLAY, false);
}
else if (passIndex == 1)
{
cmd.SetGlobalColor(k_DebugColorPropertyId, Color.black);
cmd.SetKeyword(ShaderGlobalKeywords.DEBUG_DISPLAY, true);
}
break;
}
}
switch (MaterialSettings.materialValidationMode)
{
case DebugMaterialValidationMode.Albedo:
cmd.SetGlobalFloat(k_DebugValidateAlbedoMinLuminanceId, MaterialSettings.albedoMinLuminance);
cmd.SetGlobalFloat(k_DebugValidateAlbedoMaxLuminanceId, MaterialSettings.albedoMaxLuminance);
cmd.SetGlobalFloat(k_DebugValidateAlbedoSaturationToleranceId, MaterialSettings.albedoSaturationTolerance);
cmd.SetGlobalFloat(k_DebugValidateAlbedoHueToleranceId, MaterialSettings.albedoHueTolerance);
cmd.SetGlobalColor(k_DebugValidateAlbedoCompareColorId, MaterialSettings.albedoCompareColor.linear);
break;
case DebugMaterialValidationMode.Metallic:
cmd.SetGlobalFloat(k_DebugValidateMetallicMinValueId, MaterialSettings.metallicMinValue);
cmd.SetGlobalFloat(k_DebugValidateMetallicMaxValueId, MaterialSettings.metallicMaxValue);
break;
}
}
internal void SetDebugRenderTarget(RTHandle renderTarget, Rect displayRect, bool supportsStereo, Vector4 dataRangeRemap)
{
m_HasDebugRenderTarget = true;
m_DebugRenderTargetSupportsStereo = supportsStereo;
m_DebugRenderTarget = renderTarget;
m_DebugRenderTargetPixelRect = new Vector4(displayRect.x, displayRect.y, displayRect.width, displayRect.height);
m_DebugRenderTargetRangeRemap = dataRangeRemap;
}
internal void ResetDebugRenderTarget()
{
m_HasDebugRenderTarget = false;
}
class DebugFinalValidationPassData
{
public bool isFinalPass;
public bool resolveFinalTarget;
public bool isActiveForCamera;
public bool hasDebugRenderTarget;
public TextureHandle debugRenderTargetHandle;
public int debugTexturePropertyId;
public Vector4 debugRenderTargetPixelRect;
public int debugRenderTargetSupportsStereo;
public Vector4 debugRenderTargetRangeRemap;
public TextureHandle debugFontTextureHandle;
// NOTE: The settings are references.
// It's assumed they're the same for the whole frame. Build timeline != execution timeline!
// Ideally these would be copied without any allocs.
public DebugDisplaySettingsRendering renderingSettings;
}
DebugFinalValidationPassData InitDebugFinalValidationPassData(DebugFinalValidationPassData passData, UniversalCameraData cameraData, bool isFinalPass)
{
passData.isFinalPass = isFinalPass;
passData.resolveFinalTarget = cameraData.resolveFinalTarget;
passData.isActiveForCamera = IsActiveForCamera(cameraData.isPreviewCamera);
passData.hasDebugRenderTarget = m_HasDebugRenderTarget;
passData.debugRenderTargetHandle = TextureHandle.nullHandle;
passData.debugTexturePropertyId = m_DebugRenderTargetSupportsStereo ? k_DebugTexturePropertyId : k_DebugTextureNoStereoPropertyId;
passData.debugRenderTargetPixelRect = m_DebugRenderTargetPixelRect;
passData.debugRenderTargetSupportsStereo = m_DebugRenderTargetSupportsStereo ? 1 : 0;
passData.debugRenderTargetRangeRemap = m_DebugRenderTargetRangeRemap;
passData.debugFontTextureHandle = TextureHandle.nullHandle;
passData.renderingSettings = RenderingSettings;
return passData;
}
static void UpdateShaderGlobalPropertiesForFinalValidationPass(RasterCommandBuffer cmd, DebugFinalValidationPassData data)
{
// Ensure final validation & fullscreen debug modes are only done once in the very final pass, for the last camera on the stack.
bool isFinal = data.isFinalPass && data.resolveFinalTarget;
if (!isFinal)
{
cmd.SetKeyword(ShaderGlobalKeywords.DEBUG_DISPLAY, false);
return;
}
if (data.isActiveForCamera)
{
cmd.SetKeyword(ShaderGlobalKeywords.DEBUG_DISPLAY, true);
}
else
{
cmd.SetKeyword(ShaderGlobalKeywords.DEBUG_DISPLAY, false);
}
if (data.hasDebugRenderTarget)
{
if(data.debugRenderTargetHandle.IsValid())
cmd.SetGlobalTexture(data.debugTexturePropertyId, data.debugRenderTargetHandle);
cmd.SetGlobalVector(k_DebugTextureDisplayRect, data.debugRenderTargetPixelRect);
cmd.SetGlobalInteger(k_DebugRenderTargetSupportsStereo, data.debugRenderTargetSupportsStereo);
cmd.SetGlobalVector(k_DebugRenderTargetRangeRemap, data.debugRenderTargetRangeRemap);
}
var renderingSettings = data.renderingSettings;
if (renderingSettings.validationMode == DebugValidationMode.HighlightOutsideOfRange)
{
cmd.SetGlobalInteger(k_ValidationChannelsId, (int)renderingSettings.validationChannels);
cmd.SetGlobalFloat(k_RangeMinimumId, renderingSettings.validationRangeMin);
cmd.SetGlobalFloat(k_RangeMaximumId, renderingSettings.validationRangeMax);
}
if (renderingSettings.mipInfoMode != DebugMipInfoMode.None)
{
// some (not all) of these need text rendering
cmd.SetGlobalTexture(k_DebugFontId, data.debugFontTextureHandle);
}
}
[Conditional("UNITY_ENABLE_CHECKS")]
internal void UpdateShaderGlobalPropertiesForFinalValidationPass(CommandBuffer cmd, UniversalCameraData cameraData, bool isFinalPass)
{
UpdateShaderGlobalPropertiesForFinalValidationPass(CommandBufferHelpers.GetRasterCommandBuffer(cmd), InitDebugFinalValidationPassData(s_DebugFinalValidationPassData, cameraData, isFinalPass));
cmd.SetGlobalTexture(s_DebugFinalValidationPassData.debugTexturePropertyId, m_DebugRenderTarget);
if (RenderingSettings.mipInfoMode != DebugMipInfoMode.None)
{
// some (not all) of these need text rendering
cmd.SetGlobalTexture(k_DebugFontId, m_RuntimeTextures.debugFontTexture);
}
}
[Conditional("UNITY_ENABLE_CHECKS")]
internal void UpdateShaderGlobalPropertiesForFinalValidationPass(RenderGraph renderGraph, UniversalCameraData cameraData, bool isFinalPass)
{
using (var builder = renderGraph.AddRasterRenderPass<DebugFinalValidationPassData>(nameof(UpdateShaderGlobalPropertiesForFinalValidationPass), out var passData, s_DebugFinalValidationSampler))
{
InitDebugFinalValidationPassData(passData, cameraData, isFinalPass);
if (m_DebugRenderTarget != null)
passData.debugRenderTargetHandle = renderGraph.ImportTexture(m_DebugRenderTarget);
if (m_DebugFontTexture != null)
passData.debugFontTextureHandle = renderGraph.ImportTexture(m_DebugFontTexture);
builder.AllowGlobalStateModification(true);
if (passData.debugRenderTargetHandle.IsValid())
{
builder.UseTexture(passData.debugRenderTargetHandle);
builder.SetGlobalTextureAfterPass(passData.debugRenderTargetHandle, passData.debugTexturePropertyId);
}
if (passData.debugFontTextureHandle.IsValid())
{
builder.UseTexture(passData.debugFontTextureHandle);
builder.SetGlobalTextureAfterPass(passData.debugFontTextureHandle, k_DebugFontId);
}
builder.SetRenderFunc(static (DebugFinalValidationPassData data, RasterGraphContext context) =>
{
UpdateShaderGlobalPropertiesForFinalValidationPass(context.cmd, data);
});
}
}
class DebugSetupPassData
{
public bool isActiveForCamera;
// NOTE: The settings are references.
// It's assumed they're the same for the whole frame. Build timeline != execution timeline!
// Ideally these would be copied without any allocs.
public DebugDisplaySettingsMaterial materialSettings;
public DebugDisplaySettingsRendering renderingSettings;
public DebugDisplaySettingsLighting lightingSettings;
}
DebugSetupPassData InitDebugSetupPassData(DebugSetupPassData passData, bool isPreviewCamera)
{
passData.isActiveForCamera = IsActiveForCamera(isPreviewCamera);
passData.materialSettings = MaterialSettings;
passData.renderingSettings = RenderingSettings;
passData.lightingSettings = LightingSettings;
return passData;
}
[Conditional("UNITY_ENABLE_CHECKS")]
static void Setup(RasterCommandBuffer cmd, DebugSetupPassData passData)
{
if (passData.isActiveForCamera)
{
cmd.SetKeyword(ShaderGlobalKeywords.DEBUG_DISPLAY, true);
// Material settings...
cmd.SetGlobalFloat(k_DebugMaterialModeId, (int)passData.materialSettings.materialDebugMode);
cmd.SetGlobalFloat(k_DebugVertexAttributeModeId, (int)passData.materialSettings.vertexAttributeDebugMode);
cmd.SetGlobalInteger(k_DebugMaterialValidationModeId, (int)passData.materialSettings.materialValidationMode);
// Rendering settings...
cmd.SetGlobalInteger(k_DebugMipInfoModeId, (int)passData.renderingSettings.mipInfoMode);
cmd.SetGlobalInteger(k_DebugMipMapStatusModeId, (int)passData.renderingSettings.mipDebugStatusMode);
cmd.SetGlobalInteger(k_DebugMipMapShowStatusCodeId, passData.renderingSettings.mipDebugStatusShowCode ? 1 : 0);
cmd.SetGlobalFloat(k_DebugMipMapOpacityId, passData.renderingSettings.mipDebugOpacity);
cmd.SetGlobalFloat(k_DebugMipMapRecentlyUpdatedCooldownId, passData.renderingSettings.mipDebugRecentUpdateCooldown);
cmd.SetGlobalFloat(k_DebugMipMapTerrainTextureModeId, (int)passData.renderingSettings.mipDebugTerrainTexture);
cmd.SetGlobalInteger(k_DebugSceneOverrideModeId, (int)passData.renderingSettings.sceneOverrideMode);
cmd.SetGlobalInteger(k_DebugFullScreenModeId, (int)passData.renderingSettings.fullScreenDebugMode);
cmd.SetGlobalInteger(k_DebugMaxPixelCost, (int)passData.renderingSettings.maxOverdrawCount);
cmd.SetGlobalInteger(k_DebugValidationModeId, (int)passData.renderingSettings.validationMode);
cmd.SetGlobalColor(k_DebugValidateBelowMinThresholdColorPropertyId, Color.red);
cmd.SetGlobalColor(k_DebugValidateAboveMaxThresholdColorPropertyId, Color.blue);
// Lighting settings...
cmd.SetGlobalFloat(k_DebugLightingModeId, (int)passData.lightingSettings.lightingDebugMode);
cmd.SetGlobalInteger(k_DebugLightingFeatureFlagsId, (int)passData.lightingSettings.lightingFeatureFlags);
// Set-up any other persistent properties...
cmd.SetGlobalColor(k_DebugColorInvalidModePropertyId, Color.red);
#if UNITY_EDITOR
cmd.SetGlobalFloat(k_DebugCurrentRealTimeId, (float)EditorApplication.timeSinceStartup);
#else
cmd.SetGlobalFloat(k_DebugCurrentRealTimeId, Time.realtimeSinceStartup);
#endif
}
else
{
cmd.SetKeyword(ShaderGlobalKeywords.DEBUG_DISPLAY, false);
}
}
[Conditional("UNITY_ENABLE_CHECKS")]
internal void Setup(CommandBuffer cmd, bool isPreviewCamera)
{
Setup(CommandBufferHelpers.GetRasterCommandBuffer(cmd), InitDebugSetupPassData(s_DebugSetupPassData, isPreviewCamera));
}
[Conditional("UNITY_ENABLE_CHECKS")]
internal void Setup(RenderGraph renderGraph, bool isPreviewCamera)
{
using (var builder = renderGraph.AddRasterRenderPass<DebugSetupPassData>(s_DebugSetupSampler.name, out var passData, s_DebugSetupSampler))
{
InitDebugSetupPassData(passData, isPreviewCamera);
builder.AllowGlobalStateModification(true);
builder.SetRenderFunc(static (DebugSetupPassData data, RasterGraphContext context) =>
{
Setup(context.cmd, data);
});
}
}
[Conditional("UNITY_ENABLE_CHECKS")]
internal void Render(RenderGraph renderGraph, UniversalCameraData cameraData, in TextureHandle srcColor, in TextureHandle overlayTexture, in TextureHandle dstColor)
{
if (IsActiveForCamera(cameraData.isPreviewCamera) && HDRDebugViewIsActive(cameraData.resolveFinalTarget))
{
m_HDRDebugViewPass.RenderHDRDebug(renderGraph, cameraData, srcColor, overlayTexture, dstColor, LightingSettings.hdrDebugMode);
}
}
#region DebugRendererLists
internal DebugRendererLists CreateRendererListsWithDebugRenderState(
RenderGraph renderGraph,
ref CullingResults cullResults,
ref DrawingSettings drawingSettings,
ref FilteringSettings filteringSettings,
ref RenderStateBlock renderStateBlock)
{
DebugRendererLists debug = new DebugRendererLists(this, filteringSettings);
debug.CreateRendererListsWithDebugRenderState(renderGraph, ref cullResults, ref drawingSettings, ref filteringSettings, ref renderStateBlock);
return debug;
}
#endregion
}
internal class DebugRendererLists
{
private readonly DebugHandler m_DebugHandler;
readonly FilteringSettings m_FilteringSettings;
List<DebugRenderSetup> m_DebugRenderSetups = new List<DebugRenderSetup>(2);
List<RendererList> m_ActiveDebugRendererList = new List<RendererList>(2);
List<RendererListHandle> m_ActiveDebugRendererListHdl = new List<RendererListHandle>(2);
public DebugRendererLists(DebugHandler debugHandler,
FilteringSettings filteringSettings)
{
m_DebugHandler = debugHandler;
m_FilteringSettings = filteringSettings;
}
private void CreateDebugRenderSetups(FilteringSettings filteringSettings)
{
var sceneOverrideMode = m_DebugHandler.DebugDisplaySettings.renderingSettings.sceneOverrideMode;
var numIterations = ((sceneOverrideMode == DebugSceneOverrideMode.SolidWireframe) || (sceneOverrideMode == DebugSceneOverrideMode.ShadedWireframe)) ? 2 : 1;
for (var i = 0; i < numIterations; i++)
m_DebugRenderSetups.Add(new DebugRenderSetup(m_DebugHandler, i, filteringSettings));
}
void DisposeDebugRenderLists()
{
foreach (var debugRenderSetup in m_DebugRenderSetups)
{
debugRenderSetup.Dispose();
}
m_DebugRenderSetups.Clear();
m_ActiveDebugRendererList.Clear();
m_ActiveDebugRendererListHdl.Clear();
}
internal void CreateRendererListsWithDebugRenderState(
RenderGraph renderGraph,
ref CullingResults cullResults,
ref DrawingSettings drawingSettings,
ref FilteringSettings filteringSettings,
ref RenderStateBlock renderStateBlock)
{
CreateDebugRenderSetups(filteringSettings);
foreach (DebugRenderSetup debugRenderSetup in m_DebugRenderSetups)
{
DrawingSettings debugDrawingSettings = debugRenderSetup.CreateDrawingSettings(drawingSettings);
RenderStateBlock debugRenderStateBlock = debugRenderSetup.GetRenderStateBlock(renderStateBlock);
RendererListHandle rendererListHdl = new RendererListHandle();
RenderingUtils.CreateRendererListWithRenderStateBlock(renderGraph, ref cullResults, debugDrawingSettings, filteringSettings, debugRenderStateBlock, ref rendererListHdl);
m_ActiveDebugRendererListHdl.Add((rendererListHdl));
}
}
internal void PrepareRendererListForRasterPass(IRasterRenderGraphBuilder builder)
{
foreach (RendererListHandle rendererListHdl in m_ActiveDebugRendererListHdl)
{
builder.UseRendererList(rendererListHdl);
}
}
internal void DrawWithRendererList(RasterCommandBuffer cmd)
{
foreach (DebugRenderSetup debugRenderSetup in m_DebugRenderSetups)
{
debugRenderSetup.Begin(cmd);
RendererList rendererList = new RendererList();
if (m_ActiveDebugRendererList.Count > 0)
{
rendererList = m_ActiveDebugRendererList[debugRenderSetup.GetIndex()];
}
else if(m_ActiveDebugRendererListHdl.Count > 0)
{
rendererList = m_ActiveDebugRendererListHdl[debugRenderSetup.GetIndex()];
}
debugRenderSetup.DrawWithRendererList(cmd, ref rendererList);
debugRenderSetup.End(cmd);
}
DisposeDebugRenderLists();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a684da720c3a43aaa94d1c3e9de4321f
timeCreated: 1601652776
@@ -0,0 +1,171 @@
using System;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering.RenderGraphModule;
namespace UnityEngine.Rendering.Universal
{
class DebugRenderSetup : IDisposable
{
private readonly DebugHandler m_DebugHandler;
private readonly FilteringSettings m_FilteringSettings;
private readonly int m_Index;
private DebugDisplaySettingsMaterial MaterialSettings => m_DebugHandler.DebugDisplaySettings.materialSettings;
private DebugDisplaySettingsRendering RenderingSettings => m_DebugHandler.DebugDisplaySettings.renderingSettings;
private DebugDisplaySettingsLighting LightingSettings => m_DebugHandler.DebugDisplaySettings.lightingSettings;
internal void Begin(RasterCommandBuffer cmd)
{
DebugSceneOverrideMode sceneOverrideMode = RenderingSettings.sceneOverrideMode;
switch (sceneOverrideMode)
{
case DebugSceneOverrideMode.Wireframe:
{
cmd.SetWireframe(true);
break;
}
case DebugSceneOverrideMode.SolidWireframe:
case DebugSceneOverrideMode.ShadedWireframe:
{
if (m_Index == 1)
{
cmd.SetWireframe(true);
}
break;
}
}
m_DebugHandler.SetupShaderProperties(cmd, m_Index);
}
internal void End(RasterCommandBuffer cmd)
{
DebugSceneOverrideMode sceneOverrideMode = RenderingSettings.sceneOverrideMode;
switch (sceneOverrideMode)
{
case DebugSceneOverrideMode.Wireframe:
{
cmd.SetWireframe(false);
break;
}
case DebugSceneOverrideMode.SolidWireframe:
case DebugSceneOverrideMode.ShadedWireframe:
{
if (m_Index == 1)
{
cmd.SetWireframe(false);
}
break;
}
}
}
internal DebugRenderSetup(DebugHandler debugHandler,
int index,
FilteringSettings filteringSettings)
{
m_DebugHandler = debugHandler;
m_FilteringSettings = filteringSettings;
m_Index = index;
}
internal void CreateRendererList(
RenderGraph renderGraph,
ref CullingResults cullResults,
ref DrawingSettings drawingSettings,
ref FilteringSettings filteringSettings,
ref RenderStateBlock renderStateBlock,
ref RendererListHandle rendererListHdl)
{
RenderingUtils.CreateRendererListWithRenderStateBlock(renderGraph, ref cullResults, drawingSettings, filteringSettings, renderStateBlock, ref rendererListHdl);
}
internal void DrawWithRendererList(RasterCommandBuffer cmd, ref RendererList rendererList)
{
if(rendererList.isValid)
cmd.DrawRendererList(rendererList);
}
internal DrawingSettings CreateDrawingSettings(DrawingSettings drawingSettings)
{
bool usesReplacementMaterial = (MaterialSettings.vertexAttributeDebugMode != DebugVertexAttributeMode.None);
if (usesReplacementMaterial)
{
Material replacementMaterial = m_DebugHandler.ReplacementMaterial;
DrawingSettings modifiedDrawingSettings = drawingSettings;
modifiedDrawingSettings.overrideMaterial = replacementMaterial;
modifiedDrawingSettings.overrideMaterialPassIndex = 0;
return modifiedDrawingSettings;
}
// No overrides, return original
return drawingSettings;
}
internal RenderStateBlock GetRenderStateBlock(RenderStateBlock renderStateBlock)
{
DebugSceneOverrideMode sceneOverrideMode = RenderingSettings.sceneOverrideMode;
// Potentially override parts of the RenderStateBlock
switch (sceneOverrideMode)
{
case DebugSceneOverrideMode.Overdraw:
{
var isOpaque = m_FilteringSettings.renderQueueRange == RenderQueueRange.opaque || m_FilteringSettings.renderQueueRange == RenderQueueRange.all;
var isTransparent = m_FilteringSettings.renderQueueRange == RenderQueueRange.transparent || m_FilteringSettings.renderQueueRange == RenderQueueRange.all;
var overdrawOpaque =
m_DebugHandler.DebugDisplaySettings.renderingSettings.overdrawMode == DebugOverdrawMode.Opaque
|| m_DebugHandler.DebugDisplaySettings.renderingSettings.overdrawMode == DebugOverdrawMode.All;
var overdrawTransparent =
m_DebugHandler.DebugDisplaySettings.renderingSettings.overdrawMode == DebugOverdrawMode.Transparent
|| m_DebugHandler.DebugDisplaySettings.renderingSettings.overdrawMode == DebugOverdrawMode.All;
var blendOverdraw = isOpaque && overdrawOpaque || isTransparent && overdrawTransparent;
var destination = blendOverdraw ? BlendMode.One : BlendMode.Zero;
RenderTargetBlendState additiveBlend = new RenderTargetBlendState(sourceColorBlendMode: BlendMode.One, destinationColorBlendMode: destination);
// Additive-blend but leave z-write and culling as they are when we draw normally
renderStateBlock.blendState = new BlendState { blendState0 = additiveBlend };
renderStateBlock.mask = RenderStateMask.Blend;
break;
}
case DebugSceneOverrideMode.Wireframe:
{
// Disable culling to see all lines
renderStateBlock.rasterState = new RasterState(
cullingMode: CullMode.Off
);
renderStateBlock.mask = RenderStateMask.Raster;
break;
}
case DebugSceneOverrideMode.SolidWireframe:
case DebugSceneOverrideMode.ShadedWireframe:
{
if (m_Index == 1)
{
// Ensure we render the wireframe in front of the solid triangles of the previous pass...
renderStateBlock.rasterState = new RasterState(offsetUnits: -1, offsetFactor: -1);
renderStateBlock.mask = RenderStateMask.Raster;
}
break;
}
}
return renderStateBlock;
}
internal int GetIndex() { return m_Index; }
public void Dispose()
{
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a7745542269049e0a733b635ef8e4df8
timeCreated: 1613120217
@@ -0,0 +1,126 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Class for the rendering debugger settings.
/// </summary>
public class UniversalRenderPipelineDebugDisplaySettings : DebugDisplaySettings<UniversalRenderPipelineDebugDisplaySettings>
{
DebugDisplaySettingsCommon commonSettings { get; set; }
/// <summary>
/// Material-related rendering debugger settings.
/// </summary>
public DebugDisplaySettingsMaterial materialSettings { get; private set; }
/// <summary>
/// Rendering-related rendering debugger settings.
/// </summary>
public DebugDisplaySettingsRendering renderingSettings { get; private set; }
/// <summary>
/// Lighting-related rendering debugger settings.
/// </summary>
public DebugDisplaySettingsLighting lightingSettings { get; private set; }
/// <summary>
/// Volume-related rendering debugger settings.
/// </summary>
public DebugDisplaySettingsVolume volumeSettings { get; private set; }
/// <summary>
/// Display stats.
/// </summary>
internal DebugDisplaySettingsStats displayStats { get; private set; }
/// <summary>
/// GPU Resident Drawer Rendering Debugger settings and statistics.
/// </summary>
internal DebugDisplayGPUResidentDrawer gpuResidentDrawerSettings { get; private set; }
#region IDebugDisplaySettingsQuery
/// <summary>
/// Returns true if the current state of debug settings allows post-processing.
/// </summary>
public override bool IsPostProcessingAllowed
{
get
{
DebugPostProcessingMode debugPostProcessingMode = renderingSettings.postProcessingDebugMode;
switch (debugPostProcessingMode)
{
case DebugPostProcessingMode.Disabled:
{
return false;
}
case DebugPostProcessingMode.Auto:
{
// Only enable post-processing if we aren't using certain debug-views.
bool postProcessingAllowed = true;
foreach (IDebugDisplaySettingsData setting in m_Settings)
postProcessingAllowed &= setting.IsPostProcessingAllowed;
return postProcessingAllowed;
}
case DebugPostProcessingMode.Enabled:
{
return true;
}
default:
{
throw new ArgumentOutOfRangeException(nameof(debugPostProcessingMode), $"Invalid post-processing state {debugPostProcessingMode}");
}
}
}
}
#endregion
/// <summary>
/// Creates a new <c>UniversalRenderPipelineDebugDisplaySettings</c> instance.
/// </summary>
public UniversalRenderPipelineDebugDisplaySettings()
{
}
/// <inheritdoc/>
public override void Reset()
{
base.Reset();
displayStats = Add(new DebugDisplaySettingsStats(new UniversalRenderPipelineDebugDisplayStats()));
materialSettings = Add(DebugDisplaySerializer.GetOrCreate<DebugDisplaySettingsMaterial>());
lightingSettings = Add(DebugDisplaySerializer.GetOrCreate<DebugDisplaySettingsLighting>());
renderingSettings = Add(DebugDisplaySerializer.GetOrCreate<DebugDisplaySettingsRendering>());
volumeSettings = Add(DebugDisplaySerializer.GetOrCreate<DebugDisplaySettingsVolume>());
commonSettings = Add(DebugDisplaySerializer.GetOrCreate<DebugDisplaySettingsCommon>());
gpuResidentDrawerSettings = Add(DebugDisplaySerializer.GetOrCreate<DebugDisplayGPUResidentDrawer>());
// This is not a debug property owned by any `IDebugDisplaySettingsData`, it is a static property on `Texture`.
// When the user hits reset, we want to make sure texture mip caching is enabled again (regardless of whether the
// user toggled this in the Rendering Debugger UI or changed it using the scripting API).
Texture.streamingTextureDiscardUnusedMips = false;
}
internal void UpdateDisplayStats()
{
if (displayStats != null)
displayStats.debugDisplayStats.Update();
}
internal void UpdateMaterials()
{
if (renderingSettings.mipInfoMode != DebugMipInfoMode.None)
{
int textureSlotImpl = (renderingSettings.canAggregateData && renderingSettings.showInfoForAllSlots)
? -1
: renderingSettings.mipDebugMaterialTextureSlot;
Texture.SetStreamingTextureMaterialDebugProperties(textureSlotImpl);
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2792d18b8e6d4d141af28c77268cced7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using Unity.RenderPipelines.Core.Runtime.Shared;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// URP Rendering Debugger Display Stats.
/// </summary>
class UniversalRenderPipelineDebugDisplayStats : DebugDisplayStats
{
readonly List<ProfilingSampler> m_URPSamplers = GetProfilingSamplersToDisplay(typeof(URPProfilingSamplers));
/// <inheritdoc/>
public override void EnableProfilingRecorders()
{
AddAndEnableProfilingSamplers(m_URPSamplers);
base.EnableProfilingRecorders();
}
/// <inheritdoc/>
public override void RegisterDebugUI(List<DebugUI.Widget> list)
{
#if UNITY_ANDROID || UNITY_IPHONE || UNITY_TVOS
list.Add(new DebugUI.MessageBox
{
displayName = "Warning: GPU timings may not be accurate on mobile devices that have tile-based architectures.",
style = DebugUI.MessageBox.Style.Warning,
flags = DebugUI.Flags.RuntimeOnly
});
#endif
base.RegisterDebugUI(list);
var detailedStats = DebugUIUtilities.GetFoldoutByName("Detailed Stats", list);
var detailedFoldout = detailedStats != null ? DebugUIUtilities.GetFoldoutByName("Profiling Scopes", detailedStats.children) : null;
detailedFoldout?.children.InsertRange(0, BuildProfilingSamplerWidgetList(m_URPSamplers));
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cd017e26c44959440b65ae797d9d4d90
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,47 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Volume debug settings.
/// </summary>
[Obsolete("This is not longer supported Please use DebugDisplaySettingsVolume. #from(6000.2)")]
public partial class UniversalRenderPipelineVolumeDebugSettings : VolumeDebugSettings<UniversalAdditionalCameraData>
{
/// <summary>Selected camera volume stack.</summary>
public override VolumeStack selectedCameraVolumeStack
{
get
{
Camera cam = selectedCamera;
if (cam == null)
return null;
var additionalCameraData = selectedCamera.GetComponent<UniversalAdditionalCameraData>();
if (additionalCameraData == null)
return null;
var stack = additionalCameraData.volumeStack;
if (stack != null)
return stack;
return VolumeManager.instance.stack;
}
}
/// <summary>Selected camera volume layer mask.</summary>
public override LayerMask selectedCameraLayerMask
{
get
{
if (selectedCamera != null && selectedCamera.TryGetComponent<UniversalAdditionalCameraData>(out var selectedAdditionalCameraData))
return selectedAdditionalCameraData.volumeLayerMask;
return 1; // "Default"
}
}
/// <summary>Selected camera volume position.</summary>
public override Vector3 selectedCameraPosition => selectedCamera != null ? selectedCamera.transform.position : Vector3.zero;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 18f50ab9cd0aa054b99d7d539cd829b5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,13 @@
using System;
namespace UnityEngine.Rendering.Universal
{
public partial class UniversalRenderPipelineVolumeDebugSettings
{
/// <summary>
/// Specifies the render pipeline for this volume settings
/// </summary>
[Obsolete("This property is obsolete and kept only for not breaking user code. VolumeDebugSettings will use current pipeline when it needs to gather volume component types and paths. #from(2023.2)")]
public override Type targetRenderPipeline => typeof(UniversalRenderPipeline);
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 03143e7f435146a583815fb58bdbd8a2
timeCreated: 1681826159