using System; namespace UnityEngine.Rendering.HighDefinition { /// /// Full Screen Lighting Debug Mode. /// [GenerateHLSL] public enum DebugLightingMode { /// No lighting debug mode. None, // Caution: Shader code assume that all lighting decomposition mode are contiguous // i.e start with DiffuseLighting and end with EmissiveLighting. Keep those boundary. /// Display only diffuse lighting. DiffuseLighting, /// Display only specular lighting. SpecularLighting, /// Display only direct diffuse lighting. DirectDiffuseLighting, /// Display only direct specular lighting. DirectSpecularLighting, /// Display only indirect diffuse lighting. IndirectDiffuseLighting, /// Display only reflection. ReflectionLighting, /// Display only refraction. RefractionLighting, /// Display only Emissive lighting. EmissiveLighting, /// Display lux values. LuxMeter, /// Display luminance values. LuminanceMeter, /// Disable scene lightings and replaces it with a pre-computed lighting environment. MatcapView, /// Display Directional Shadow Cascades splits. VisualizeCascade, /// Display Shadow Masks. VisualizeShadowMasks, /// Display indirect diffuse occlusion. IndirectDiffuseOcclusion, /// Display indirect specular occlusion. IndirectSpecularOcclusion, /// Display Probe Volumes. ProbeVolume } /// /// Debug Light Filtering. /// [GenerateHLSL] [Flags] public enum DebugLightFilterMode { /// No light filtering. None = 0, /// Display directional lights. DirectDirectional = 1 << 0, /// Display punctual lights. DirectPunctual = 1 << 1, /// Display rectangle lights. DirectRectangle = 1 << 2, /// Display tube lights. DirectTube = 1 << 3, /// Display Spot lights. DirectSpotCone = 1 << 4, /// Display Pyramid lights. DirectSpotPyramid = 1 << 5, /// Display Box lights. DirectSpotBox = 1 << 6, /// Display Reflection Probes. IndirectReflectionProbe = 1 << 7, /// Display Planar Probes. IndirectPlanarProbe = 1 << 8, } /// /// Debug Light Layers Filtering. /// [GenerateHLSL] [Flags] public enum DebugLightLayersMask { /// No light layer debug. None = 0, /// Debug light layer 1. LightLayer1 = 1 << 0, /// Debug light layer 2. LightLayer2 = 1 << 1, /// Debug light layer 3. LightLayer3 = 1 << 2, /// Debug light layer 4. LightLayer4 = 1 << 3, /// Debug light layer 5. LightLayer5 = 1 << 4, /// Debug light layer 6. LightLayer6 = 1 << 5, /// Debug light layer 7. LightLayer7 = 1 << 6, /// Debug light layer 8. LightLayer8 = 1 << 7, } static class DebugLightHierarchyExtensions { public static bool IsEnabledFor( this DebugLightFilterMode mode, GPULightType gpuLightType, SpotLightShape spotLightShape ) { switch (gpuLightType) { case GPULightType.ProjectorBox: case GPULightType.ProjectorPyramid: case GPULightType.Spot: { switch (spotLightShape) { case SpotLightShape.Box: return (mode & DebugLightFilterMode.DirectSpotBox) != 0; case SpotLightShape.Cone: return (mode & DebugLightFilterMode.DirectSpotCone) != 0; case SpotLightShape.Pyramid: return (mode & DebugLightFilterMode.DirectSpotPyramid) != 0; default: throw new ArgumentOutOfRangeException(nameof(spotLightShape)); } } case GPULightType.Tube: return (mode & DebugLightFilterMode.DirectTube) != 0; case GPULightType.Point: return (mode & DebugLightFilterMode.DirectPunctual) != 0; case GPULightType.Rectangle: return (mode & DebugLightFilterMode.DirectRectangle) != 0; case GPULightType.Directional: return (mode & DebugLightFilterMode.DirectDirectional) != 0; default: throw new ArgumentOutOfRangeException(nameof(gpuLightType)); } } public static bool IsEnabledFor( this DebugLightFilterMode mode, ProbeSettings.ProbeType probeType ) { switch (probeType) { case ProbeSettings.ProbeType.PlanarProbe: return (mode & DebugLightFilterMode.IndirectPlanarProbe) != 0; case ProbeSettings.ProbeType.ReflectionProbe: return (mode & DebugLightFilterMode.IndirectReflectionProbe) != 0; default: throw new ArgumentOutOfRangeException(nameof(probeType)); } } } /// /// Shadow Maps Debug Mode. /// [GenerateHLSL] public enum ShadowMapDebugMode { /// No Shadow Maps debug. None, /// Display punctual lights shadow atlas as an overlay. VisualizePunctualLightAtlas, /// Display directional light shadow atlas as an overlay. VisualizeDirectionalLightAtlas, /// Display area lights shadow atlas as an overlay. VisualizeAreaLightAtlas, /// Display punctual lights cached shadow atlas as an overlay. VisualizeCachedPunctualLightAtlas, /// Display area lights cached shadow atlas as an overlay. VisualizeCachedAreaLightAtlas, /// Display a single light shadow map as an overlay. VisualizeShadowMap, /// Replace rendering with a black and white view of the shadow of a single light in the scene. SingleShadow, } /// /// Exposure debug mode. /// [GenerateHLSL] public enum ExposureDebugMode { /// No exposure debug. None, /// Display the EV100 values of the scene, color-coded. SceneEV100Values, /// Display the Histogram used for exposure. HistogramView, /// Display an RGB histogram of the final image (after post-processing). FinalImageHistogramView, /// Visualize the scene color weighted as the metering mode selected. MeteringWeighted, } /// /// Probe Volume Debug Modes. /// [GenerateHLSL] internal enum ProbeVolumeDebugMode { None, VisualizeAtlas, VisualizeDebugColors, VisualizeValidity } /// /// Probe Volume Atlas Slicing Modes. /// [GenerateHLSL] internal enum ProbeVolumeAtlasSliceMode { IrradianceSH00, IrradianceSH1_1, IrradianceSH10, IrradianceSH11, IrradianceSH2_2, IrradianceSH2_1, IrradianceSH20, IrradianceSH21, IrradianceSH22, Validity, OctahedralDepth } /// /// Lighting Debug Settings. /// [Serializable] public class LightingDebugSettings { /// /// Returns true if any lighting debug mode is enabled. /// /// True if any lighting debug mode is enabled public bool IsDebugDisplayEnabled() { return debugLightingMode != DebugLightingMode.None || debugLightFilterMode != DebugLightFilterMode.None || debugLightLayers || overrideSmoothness || overrideAlbedo || overrideNormal || overrideAmbientOcclusion || overrideSpecularColor || overrideEmissiveColor || shadowDebugMode == ShadowMapDebugMode.SingleShadow || probeVolumeDebugMode != ProbeVolumeDebugMode.None; } /// Current Light Filtering. public DebugLightFilterMode debugLightFilterMode = DebugLightFilterMode.None; /// Current Full Screen Lighting debug mode. public DebugLightingMode debugLightingMode = DebugLightingMode.None; /// True if light layers visualization is enabled. public bool debugLightLayers = false; /// Current Light Layers Filtering mode. public DebugLightLayersMask debugLightLayersFilterMask = (DebugLightLayersMask)(-1); // Select Everything by default /// True if light layers visualization uses light layers of the selected light. public bool debugSelectionLightLayers = false; /// True if light layers visualization uses shadow layers of the selected light. public bool debugSelectionShadowLayers = false; /// Rendering Layers Debug Colors. public Vector4[] debugRenderingLayersColors = GetDefaultRenderingLayersColorPalette(); /// Current Shadow Maps debug mode. public ShadowMapDebugMode shadowDebugMode = ShadowMapDebugMode.None; /// Current Probe Volume Debug Mode. [SerializeField] internal ProbeVolumeDebugMode probeVolumeDebugMode = ProbeVolumeDebugMode.None; /// Current Probe Volume Atlas Slicing Mode. [SerializeField] internal ProbeVolumeAtlasSliceMode probeVolumeAtlasSliceMode = ProbeVolumeAtlasSliceMode.IrradianceSH00; /// The minimum display threshold for atlas slices. [SerializeField] internal float probeVolumeMinValue = 0.0f; /// The maximum display threshold for atlas slices. [SerializeField] internal float probeVolumeMaxValue = 1.0f; /// True if Shadow Map debug mode should be displayed for the currently selected light. public bool shadowDebugUseSelection = false; /// Index in the list of currently visible lights of the shadow map to display. public uint shadowMapIndex = 0; /// Shadow Map debug display visual remapping minimum value. public float shadowMinValue = 0.0f; /// Shadow Map debug display visual remapping maximum value. public float shadowMaxValue = 1.0f; /// Use this value to force a rescale of all shadow atlases. public float shadowResolutionScaleFactor = 1.0f; /// Clear shadow atlases each frame. public bool clearShadowAtlas = false; /// Override smoothness of the whole scene for lighting debug. public bool overrideSmoothness = false; /// Value used when overriding smoothness. public float overrideSmoothnessValue = 0.5f; /// Override albedo of the whole scene for lighting debug. public bool overrideAlbedo = false; /// Color used when overriding albedo. public Color overrideAlbedoValue = new Color(0.5f, 0.5f, 0.5f); /// Override normal of the whole scene with object normals for lighting debug. public bool overrideNormal = false; /// Override ambient occlusion of the whole scene for lighting debug. public bool overrideAmbientOcclusion = false; /// Value used when overriding ambient occlusion. public float overrideAmbientOcclusionValue = 1.0f; /// Override specular color of the whole scene for lighting debug. public bool overrideSpecularColor = false; /// Color used when overriding specular color. public Color overrideSpecularColorValue = new Color(1.0f, 1.0f, 1.0f); /// Override emissive color of the whole scene for lighting debug. public bool overrideEmissiveColor = false; /// Color used when overriding emissive color. public Color overrideEmissiveColorValue = new Color(1.0f, 1.0f, 1.0f); /// Display sky reflection cubemap as an overlay. public bool displaySkyReflection = false; /// Mip map of the displayed sky reflection. public float skyReflectionMipmap = 0.0f; /// Display lights bounding volumes as a transparent overlay in the scene. public bool displayLightVolumes = false; /// Type of light bounding volumes to display. public LightVolumeDebug lightVolumeDebugByCategory = LightVolumeDebug.Gradient; /// Maximum number of lights against which the light overdraw gradient is displayed. public uint maxDebugLightCount = 24; /// Exposure debug mode. public ExposureDebugMode exposureDebugMode = ExposureDebugMode.None; /// Exposure compensation to apply on current scene exposure. public float debugExposure = 0.0f; /// Obsolete, please use the lens attenuation mode in HDRP Default Settings. [Obsolete("Please use the lens attenuation mode in HDRP Default Settings", true)] public float debugLensAttenuation = 0.65f; /// Whether to show tonemap curve in the histogram debug view or not. public bool showTonemapCurveAlongHistogramView = true; /// Whether to center the histogram debug view around the middle-grey point or not. public bool centerHistogramAroundMiddleGrey = false; /// Whether to show tonemap curve in the histogram debug view or not. public bool displayFinalImageHistogramAsRGB = false; /// Whether to show the only the mask in the picture in picture. If unchecked, the mask view is weighted by the scene color. public bool displayMaskOnly = false; /// Display the light cookies atlas. public bool displayCookieAtlas = false; /// Display the light cookies cubemap array. public bool displayCookieCubeArray = false; /// Index of the light cubemap to display. public uint cubeArraySliceIndex = 0; /// Mip level of the cookie cubemap display. public uint cookieAtlasMipLevel = 0; /// Clear cookie atlas each frame. public bool clearCookieAtlas = false; /// Display the planar reflection atlas. public bool displayPlanarReflectionProbeAtlas = false; /// Mip level of the planar reflection atlas display. public uint planarReflectionProbeMipLevel = 0; /// Clear planar reflection atlas each frame. public bool clearPlanarReflectionProbeAtlas = false; /// True if punctual lights should be displayed in the scene. public bool showPunctualLight = true; /// True if directional lights should be displayed in the scene. public bool showDirectionalLight = true; /// True if area lights should be displayed in the scene. public bool showAreaLight = true; /// True if reflection probes lights should be displayed in the scene. public bool showReflectionProbe = true; /// Tile and Cluster debug mode. public TileClusterDebug tileClusterDebug = TileClusterDebug.None; /// Category for tile and cluster debug mode. public TileClusterCategoryDebug tileClusterDebugByCategory = TileClusterCategoryDebug.Punctual; /// Cluster Debug mode. public ClusterDebugMode clusterDebugMode = ClusterDebugMode.VisualizeOpaque; /// Distance at which clusters will be visualized. public float clusterDebugDistance = 1.0f; // Internal APIs internal bool IsDebugDisplayRemovePostprocess() { return debugLightingMode == DebugLightingMode.LuxMeter || debugLightingMode == DebugLightingMode.LuminanceMeter || debugLightingMode == DebugLightingMode.VisualizeCascade || debugLightingMode == DebugLightingMode.VisualizeShadowMasks || debugLightingMode == DebugLightingMode.IndirectDiffuseOcclusion || debugLightingMode == DebugLightingMode.IndirectSpecularOcclusion || debugLightingMode == DebugLightingMode.ProbeVolume; } internal static Vector4[] GetDefaultRenderingLayersColorPalette() { var colors = new Vector4[32]; var lightLayers = 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 }; int i = 0; for (; i < lightLayers.Length; i++) colors[i] = lightLayers[i]; for (; i < colors.Length; i++) colors[i] = new Vector4(0, 0, 0); return colors; } } }