-
Notifications
You must be signed in to change notification settings - Fork 867
Expand file tree
/
Copy pathDebugDisplay.cs
More file actions
2284 lines (2059 loc) · 142 KB
/
DebugDisplay.cs
File metadata and controls
2284 lines (2059 loc) · 142 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor.Rendering;
using UnityEngine.Rendering.HighDefinition.Attributes;
using UnityEngine.Rendering.RenderGraphModule;
using UnityEngine.Experimental.Rendering;
using NameAndTooltip = UnityEngine.Rendering.DebugUI.Widget.NameAndTooltip;
namespace UnityEngine.Rendering.HighDefinition
{
[GenerateHLSL(needAccessors = false, generateCBuffer = true)]
unsafe struct ShaderVariablesDebugDisplay
{
[HLSLArray(32, typeof(Vector4))]
public fixed float _DebugRenderingLayersColors[32 * 4];
[HLSLArray(11, typeof(ShaderGenUInt4))]
public fixed uint _DebugViewMaterialArray[11 * 4]; // Contain the id (define in various materialXXX.cs.hlsl) of the property to display
[HLSLArray(7, typeof(Vector4))] // Must match ProbeBrickIndex.kMaxSubdivisionLevels
public fixed float _DebugAPVSubdivColors[7 * 4];
public int _DebugLightingMode; // Match enum DebugLightingMode
public int _DebugLightLayersMask;
public int _DebugShadowMapMode;
public int _DebugMipMapMode; // Match enum DebugMipMapMode
public int _DebugFullScreenMode;
public float _DebugTransparencyOverdrawWeight;
public int _DebugMipMapModeTerrainTexture; // Match enum DebugMipMapModeTerrainTexture
public int _ColorPickerMode; // Match enum ColorPickerDebugMode
public float _DebugMipMapOpacity;
public int _DebugMipMapStatusMode;
public int _DebugMipMapShowStatusCode;
public float _DebugMipMapRecentlyUpdatedCooldown;
public Vector4 _DebugViewportSize; //Frame viewport size used during rendering.
public Vector4 _DebugLightingAlbedo; // x == bool override, yzw = albedo for diffuse
public Vector4 _DebugLightingSmoothness; // x == bool override, y == override value
public Vector4 _DebugLightingNormal; // x == bool override
public Vector4 _DebugLightingAmbientOcclusion; // x == bool override, y == override value
public Vector4 _DebugLightingSpecularColor; // x == bool override, yzw = specular color
public Vector4 _DebugLightingEmissiveColor; // x == bool override, yzw = emissive color
public Vector4 _DebugLightingMaterialValidateHighColor; // user can specific the colors for the validator error conditions
public Vector4 _DebugLightingMaterialValidateLowColor;
public Vector4 _DebugLightingMaterialValidatePureMetalColor;
public Vector4 _MousePixelCoord; // xy unorm, zw norm
public Vector4 _MouseClickPixelCoord; // xy unorm, zw norm
public int _MatcapMixAlbedo;
public float _MatcapViewScale;
public int _DebugSingleShadowIndex;
public int _DebugIsLitShaderModeDeferred;
public float _DebugCurrentRealTime; // current time since start of editor/game
public int _DebugAOVOutput;
public float _ShaderVariablesDebugDisplayPad0;
public float _ShaderVariablesDebugDisplayPad1;
}
/// <summary>
/// Full Screen Debug Mode.
/// </summary>
[GenerateHLSL]
public enum FullScreenDebugMode
{
/// <summary>No Full Screen debug mode.</summary>
None,
// Lighting
/// <summary>Minimum Full Screen Lighting debug mode value (used internally).</summary>
MinLightingFullScreenDebug,
/// <summary>Display Screen Space Ambient Occlusion buffer.</summary>
ScreenSpaceAmbientOcclusion,
/// <summary>Display Screen Space Reflections buffer used for lighting.</summary>
ScreenSpaceReflections,
/// <summary>Display the Transparent Screen Space Reflections buffer.</summary>
TransparentScreenSpaceReflections,
/// <summary>Display Screen Space Reflections buffer of the previous frame accumulated.</summary>
ScreenSpaceReflectionsPrev,
/// <summary>Display Screen Space Reflections buffer of the current frame hit.</summary>
ScreenSpaceReflectionsAccum,
/// <summary>Display Screen Space Reflections rejection used for PBR Accumulation algorithm.</summary>
ScreenSpaceReflectionSpeedRejection,
/// <summary>Display Contact Shadows buffer.</summary>
ContactShadows,
/// <summary>Display Contact Shadows fade.</summary>
ContactShadowsFade,
/// <summary>Display Screen Space Shadows.</summary>
ScreenSpaceShadows,
/// <summary>Displays the color pyramid before the refraction pass.</summary>
PreRefractionColorPyramid,
/// <summary>Display the Depth Pyramid.</summary>
DepthPyramid,
/// <summary>Display the final color pyramid for the frame.</summary>
FinalColorPyramid,
// Raytracing Only
/// <summary>Display ray tracing light cluster.</summary>
LightCluster,
/// <summary>Display screen space global illumination.</summary>
ScreenSpaceGlobalIllumination,
/// <summary>Display recursive ray tracing.</summary>
RecursiveRayTracing,
/// <summary>Display ray-traced sub-surface scattering.</summary>
RayTracedSubSurface,
// Volumetric Clouds
/// <summary>Display the volumetric clouds in-scattering x transmittance.</summary>
VolumetricClouds,
/// <summary>Display the volumetric clouds shadow at ground level.</summary>
VolumetricCloudsShadow,
/// <summary>Display atmospheric scattering applied on opaque geometry.</summary>
VolumetricFog,
/// <summary>Display the ray tracing acceleration structure</summary>
RayTracingAccelerationStructure,
/// <summary>Maximum Full Screen Lighting debug mode value (used internally).</summary>
MaxLightingFullScreenDebug,
// Rendering
/// <summary>Minimum Full Screen Rendering debug mode value (used internally).</summary>
MinRenderingFullScreenDebug,
/// <summary>Display Motion Vectors.</summary>
MotionVectors,
/// <summary>Display Motion Vectors Intensity.</summary>
MotionVectorsIntensity,
/// <summary>Display the world space positions.</summary>
WorldSpacePosition,
/// <summary>Display NaNs.</summary>
NanTracker,
/// <summary>Display Log of the color buffer.</summary>
ColorLog,
/// <summary>Display Depth of Field circle of confusion.</summary>
DepthOfFieldCoc,
/// <summary>Display Depth of Field tile classification. Red is slow in-focus, green is fast de-focus and blue is fast in-focus.</summary>
DepthOfFieldTileClassification,
/// <summary>Display Transparency Overdraw.</summary>
TransparencyOverdraw,
/// <summary>Display Quad Overdraw.</summary>
QuadOverdraw,
/// <summary>Display Local Volumetric Fog Overdraw.</summary>
LocalVolumetricFogOverdraw,
/// <summary>Display Vertex Density.</summary>
VertexDensity,
/// <summary>Display Requested Virtual Texturing tiles, colored by the mip</summary>
RequestedVirtualTextureTiles,
/// <summary>Black background to visualize the Lens Flare Data Driven</summary>
LensFlareDataDriven,
/// <summary>Black background to visualize the Lens Flare Screen Space</summary>
LensFlareScreenSpace,
/// <summary>Thickness Computed with 'ComputeThickness' pass</summary>
ComputeThickness,
/// <summary>Display Line Renderer Debug Modes.</summary>
HighQualityLines,
/// <summary>Display STP Debug Modes.</summary>
STP,
/// <summary>Maximum Full Screen Rendering debug mode value (used internally).</summary>
MaxRenderingFullScreenDebug,
//Material
/// <summary>Minimum Full Screen Material debug mode value (used internally).</summary>
MinMaterialFullScreenDebug,
/// <summary>Display Diffuse Color validation mode.</summary>
ValidateDiffuseColor,
/// <summary>Display specular Color validation mode.</summary>
ValidateSpecularColor,
/// <summary>Maximum Full Screen Material debug mode value (used internally).</summary>
MaxMaterialFullScreenDebug,
}
/// <summary>
/// List of RTAS Full Screen Debug views.
/// </summary>
public enum RTASDebugView
{
/// <summary>
/// Debug view of the RTAS for shadows.
/// </summary>
Shadows,
/// <summary>
/// Debug view of the RTAS for ambient occlusion.
/// </summary>
AmbientOcclusion,
/// <summary>
/// Debug view of the RTAS for global illumination.
/// </summary>
GlobalIllumination,
/// <summary>
/// Debug view of the RTAS for reflections.
/// </summary>
Reflections,
/// <summary>
/// Debug view of the RTAS for recursive ray tracing.
/// </summary>
RecursiveRayTracing,
/// <summary>
/// Debug view of the RTAS for path tracing.
/// </summary>
PathTracing
}
/// <summary>
/// List of RTAS Full Screen Debug modes.
/// </summary>
public enum RTASDebugMode
{
/// <summary>
/// Displacing the instanceID as the RTAS Debug view.
/// </summary>
InstanceID,
/// <summary>
/// Displacing the primitiveID as the RTAS Debug view.
/// </summary>
PrimitiveID,
}
/// <summary>
/// List of RTAS Full Screen Debug views.
/// </summary>
public enum VolumetricCloudsDebug
{
/// <summary>
/// Display the lighting of the volumetric clouds.
/// </summary>
Lighting,
/// <summary>
/// Display the depth of the volumetric clouds.
/// </summary>
Depth,
}
/// <summary>
/// List of Depth Pyramid Full Screen Debug views.
/// </summary>
public enum DepthPyramidDebugView
{
/// <summary>
/// Closest depth.
/// </summary>
ClosestDepth,
/// <summary>
/// Checkerboard of minimum and maximum depth.
/// </summary>
CheckerboardDepth,
}
/// <summary>
/// Class managing debug display in HDRP.
/// </summary>
public partial class DebugDisplaySettings : IDebugData
{
static string k_PanelMaterials = "Material";
static string k_PanelLighting = "Lighting";
static string k_PanelRendering = "Rendering";
DebugUI.Widget[] m_DebugMaterialItems;
DebugUI.Widget[] m_DebugLightingItems;
DebugUI.Widget[] m_DebugRenderingItems;
static GUIContent[] s_LightingFullScreenDebugStrings = null;
static int[] s_LightingFullScreenDebugValues = null;
static GUIContent[] s_RenderingFullScreenDebugStrings = null;
static int[] s_RenderingFullScreenDebugValues = null;
static GUIContent[] s_MaterialFullScreenDebugStrings = null;
static int[] s_MaterialFullScreenDebugValues = null;
static GUIContent[] s_RenderingHistoryBuffersStrings = null;
static int[] s_RenderingHistoryBuffersValues = null;
static GUIContent[] s_RenderingMipmapDebugMaterialTextureSlotStrings = null;
static int[] s_RenderingMipmapDebugMaterialTextureSlotValues = null;
static List<GUIContent> s_CameraNames = new List<GUIContent>() { new("None") };
static GUIContent[] s_CameraNamesStrings = { new ("No Visible Camera") };
static int[] s_CameraNamesValues = { 0 };
static bool needsRefreshingCameraFreezeList = true;
#if ENABLE_NVIDIA && ENABLE_NVIDIA_MODULE
internal UnityEngine.NVIDIA.DebugView nvidiaDebugView { get; } = new UnityEngine.NVIDIA.DebugView();
#endif
/// <summary>
/// Debug data.
/// </summary>
public partial class DebugData
{
/// <summary>Ratio of the screen size in which overlays are rendered.</summary>
public float debugOverlayRatio = 0.33f;
/// <summary>Current full screen debug mode.</summary>
public FullScreenDebugMode fullScreenDebugMode = FullScreenDebugMode.None;
/// <summary>Enable range remapping.</summary>
public bool enableDebugDepthRemap = false; // False per default to be compliant with AOV depth output (AOV depth must export unmodified linear depth)
/// <summary>Depth Range remapping values for some of the fullscreen mode. Only x and y are used.</summary>
public Vector4 fullScreenDebugDepthRemap = new Vector4(0.0f, 1.0f, 0.0f, 0.0f);
/// <summary>Current full screen debug mode mip level (when applicable).</summary>
public float fullscreenDebugMip = 0.0f;
/// <summary>Enable to show checkerboard depths instead of closest depths (when applicable).</summary>
public DepthPyramidDebugView depthPyramidView = DepthPyramidDebugView.ClosestDepth;
/// <summary>Index of the light used for contact shadows display.</summary>
public int fullScreenContactShadowLightIndex = 0;
/// <summary>XR single pass test mode.</summary>
[Obsolete("#from(2022.2)")]
public bool xrSinglePassTestMode = false;
/// <summary>Whether to display the average timings every second.</summary>
public bool averageProfilerTimingsOverASecond = false;
/// <summary>Current history buffers view.</summary>
public int historyBuffersView = -1;
/// <summary>Current material debug settings.</summary>
public MaterialDebugSettings materialDebugSettings = new MaterialDebugSettings();
/// <summary>Current lighting debug settings.</summary>
public LightingDebugSettings lightingDebugSettings = new LightingDebugSettings();
/// <summary>Current mip map debug settings.</summary>
public MipMapDebugSettings mipMapDebugSettings = new MipMapDebugSettings();
/// <summary>Current color picker debug settings.</summary>
public ColorPickerDebugSettings colorPickerDebugSettings = new ColorPickerDebugSettings();
/// <summary>Current monitors debug settings.</summary>
public MonitorsDebugSettings monitorsDebugSettings = new MonitorsDebugSettings();
/// <summary>Current false color debug settings.</summary>
public FalseColorDebugSettings falseColorDebugSettings = new FalseColorDebugSettings();
/// <summary>Current decals debug settings.</summary>
[Obsolete("decalsDebugSettings has been deprecated, please use HDDebugDisplaySettings.Instance.decalSettings instead. #from(2023.1)")]
public DecalsDebugSettings decalsDebugSettings = HDDebugDisplaySettings.Instance.decalSettings.m_Data;
/// <summary>Current transparency debug settings.</summary>
public TransparencyDebugSettings transparencyDebugSettings = new TransparencyDebugSettings();
/// <summary>Index of screen space shadow to display.</summary>
public uint screenSpaceShadowIndex = 0;
/// <summary>Max quad cost for quad overdraw display.</summary>
public uint maxQuadCost = 5;
/// <summary>Max vertex density for vertex density display.</summary>
public uint maxVertexDensity = 10;
/// <summary>Display ray tracing ray count per frame.</summary>
[Obsolete("Obsolete, moved to HDDebugDisplayStats. #from(2023.1)")]
public bool countRays = false;
/// <summary>Display Show Lens Flare Data Driven Only.</summary>
public bool showLensFlareDataDrivenOnly = false;
/// <summary>Index of the camera to freeze for visibility.</summary>
public int debugCameraToFreeze = 0;
internal RTASDebugView rtasDebugView = RTASDebugView.Shadows;
internal RTASDebugMode rtasDebugMode = RTASDebugMode.InstanceID;
internal VolumetricCloudsDebug volumetricCloudDebug = VolumetricCloudsDebug.Lighting;
/// <summary>Thickness Layer Index from ComputeThicknessPass.</summary>
public uint computeThicknessLayerIndex = 0;
/// <summary>Thickness Overlap Count from ComputeThicknessPass.</summary>
public bool computeThicknessShowOverlapCount = false;
/// <summary>Thickness Scale used for visualization.</summary>
public float computeThicknessScale = 1.0f;
/// <summary>Minimum length a motion vector needs to be to be displayed in the debug display. Unit is pixels.</summary>
public float minMotionVectorLength = 0.0f;
/// <summary>The scale to apply to motion vector lengths (in Normalized Device Coordinates) to be applied before display.</summary>
public float motionVecVisualizationScale = 40.0f;
/// <summary>Whether to visualize motion vector intensity as heat map or greyscale (if off).</summary>
public bool motionVecIntensityHeat = false;
/// <summary>Whether to apply exposure to certain fullscreen debug outputs.</summary>
public bool applyExposure = false;
/// <summary>The debug mode used for high quality line rendering.</summary>
public LineRendering.DebugMode lineRenderingDebugMode = LineRendering.DebugMode.SegmentsPerTile;
/// <summary>The debug view index used for STP.</summary>
internal int stpDebugViewIndex = 0;
// TODO: The only reason this exist is because of Material/Engine debug enums
// They have repeating values, which caused issues when iterating through the enum, thus the need for explicit indices
// Once we refactor material/engine debug to avoid repeating values, we should be able to remove that.
//saved enum fields for when repainting
internal int lightingDebugModeEnumIndex;
internal int lightingFulscreenDebugModeEnumIndex;
internal int materialValidatorDebugModeEnumIndex;
internal int tileClusterDebugEnumIndex;
internal int mipMapsEnumIndex;
internal int engineEnumIndex;
internal int attributesEnumIndex;
internal int propertiesEnumIndex;
internal int gBufferEnumIndex;
internal int shadowDebugModeEnumIndex;
internal int tileClusterDebugByCategoryEnumIndex;
internal int clusterDebugModeEnumIndex;
internal int lightVolumeDebugTypeEnumIndex;
internal int renderingFulscreenDebugModeEnumIndex;
internal int renderingHistoryBuffersViewEnumIndex;
internal int terrainTextureEnumIndex;
internal int colorPickerDebugModeEnumIndex;
internal int exposureDebugModeEnumIndex;
internal int hdrDebugModeEnumIndex;
internal int msaaSampleDebugModeEnumIndex;
internal int debugCameraToFreezeEnumIndex;
internal int rtasDebugViewEnumIndex;
internal int rtasDebugModeEnumIndex;
internal int volumetricCloudsDebugModeEnumIndex;
internal int lineRenderingDebugModeEnumIndex;
internal int lightClusterCategoryDebug;
internal int historyBufferFrameIndex = 0;
internal int stpDebugModeEnumIndex;
internal int depthPyramidViewEnumIndex;
private float m_DebugGlobalMipBiasOverride = 0.0f;
/// <summary>
/// Returns the current mip bias override specified in the debug panel.
/// </summary>
/// <returns>Mip bias override</returns>
public float GetDebugGlobalMipBiasOverride()
{
return m_DebugGlobalMipBiasOverride;
}
/// <summary>
/// Sets the mip bias override to be imposed in the rendering pipeline.
/// </summary>
/// <param name="value">mip bias override value.</param>
public void SetDebugGlobalMipBiasOverride(float value)
{
m_DebugGlobalMipBiasOverride = value;
}
private bool m_UseDebugGlobalMipBiasOverride = false;
internal bool UseDebugGlobalMipBiasOverride()
{
return m_UseDebugGlobalMipBiasOverride;
}
internal void SetUseDebugGlobalMipBiasOverride(bool value)
{
m_UseDebugGlobalMipBiasOverride = value;
}
internal bool SupportsExposure()
{
return historyBuffersView == (int)HDCameraFrameHistoryType.PathTracingOutput ||
historyBuffersView == (int)HDCameraFrameHistoryType.PathTracingDenoised ||
historyBuffersView == (int)HDCameraFrameHistoryType.PathTracingVolumetricFogDenoised ||
historyBuffersView == (int)HDCameraFrameHistoryType.PathTracingVolumetricFog;
}
// When settings mutually exclusives enum values, we need to reset the other ones.
internal void ResetExclusiveEnumIndices()
{
materialDebugSettings.materialEnumIndex = 0;
lightingDebugModeEnumIndex = 0;
mipMapsEnumIndex = 0;
engineEnumIndex = 0;
attributesEnumIndex = 0;
propertiesEnumIndex = 0;
gBufferEnumIndex = 0;
lightingFulscreenDebugModeEnumIndex = 0;
renderingFulscreenDebugModeEnumIndex = 0;
materialValidatorDebugModeEnumIndex = 0;
renderingHistoryBuffersViewEnumIndex = -1;
}
}
DebugData m_Data;
/// <summary>
/// Debug data.
/// </summary>
public DebugData data { get => m_Data; }
// Had to keep those public because HDRP tests using it (as a workaround to access proper enum values for this debug)
/// <summary>List of Full Screen Rendering Debug mode names.</summary>
public static GUIContent[] renderingFullScreenDebugStrings => s_RenderingFullScreenDebugStrings;
/// <summary>List of Full Screen Rendering Debug mode values.</summary>
public static int[] renderingFullScreenDebugValues => s_RenderingFullScreenDebugValues;
/// <summary>List of Full Screen Lighting Debug mode names.</summary>
public static GUIContent[] lightingFullScreenDebugStrings => s_LightingFullScreenDebugStrings;
/// <summary>List of Full Screen Lighting Debug mode values.</summary>
public static int[] lightingFullScreenDebugValues => s_LightingFullScreenDebugValues;
internal DebugDisplaySettings()
{
FillFullScreenDebugEnum(ref s_LightingFullScreenDebugStrings, ref s_LightingFullScreenDebugValues, FullScreenDebugMode.MinLightingFullScreenDebug, FullScreenDebugMode.MaxLightingFullScreenDebug);
FillFullScreenDebugEnum(ref s_RenderingFullScreenDebugStrings, ref s_RenderingFullScreenDebugValues, FullScreenDebugMode.MinRenderingFullScreenDebug, FullScreenDebugMode.MaxRenderingFullScreenDebug);
FillFullScreenDebugEnum(ref s_MaterialFullScreenDebugStrings, ref s_MaterialFullScreenDebugValues, FullScreenDebugMode.MinMaterialFullScreenDebug, FullScreenDebugMode.MaxMaterialFullScreenDebug);
FillMipmapDebugMaterialTextureSlotArrays(ref s_RenderingMipmapDebugMaterialTextureSlotStrings, ref s_RenderingMipmapDebugMaterialTextureSlotValues);
var device = SystemInfo.graphicsDeviceType;
if (device == GraphicsDeviceType.Metal || device == GraphicsDeviceType.PlayStation4 || device == GraphicsDeviceType.PlayStation5 || device == GraphicsDeviceType.PlayStation5NGGC || device == GraphicsDeviceType.Switch2)
{
s_RenderingFullScreenDebugStrings = s_RenderingFullScreenDebugStrings.Where((val, idx) => (idx + FullScreenDebugMode.MinRenderingFullScreenDebug) != FullScreenDebugMode.VertexDensity).ToArray();
s_RenderingFullScreenDebugValues = s_RenderingFullScreenDebugValues.Where((val, idx) => (idx + FullScreenDebugMode.MinRenderingFullScreenDebug) != FullScreenDebugMode.VertexDensity).ToArray();
s_RenderingFullScreenDebugStrings = s_RenderingFullScreenDebugStrings.Where((val, idx) => (idx + FullScreenDebugMode.MinRenderingFullScreenDebug) != FullScreenDebugMode.QuadOverdraw).ToArray();
s_RenderingFullScreenDebugValues = s_RenderingFullScreenDebugValues.Where((val, idx) => (idx + FullScreenDebugMode.MinRenderingFullScreenDebug) != FullScreenDebugMode.QuadOverdraw).ToArray();
}
FillHistoryBuffersEnum(ref s_RenderingHistoryBuffersStrings, ref s_RenderingHistoryBuffersValues);
s_MaterialFullScreenDebugStrings[(int)FullScreenDebugMode.ValidateDiffuseColor - ((int)FullScreenDebugMode.MinMaterialFullScreenDebug)] = new GUIContent("Diffuse Color");
s_MaterialFullScreenDebugStrings[(int)FullScreenDebugMode.ValidateSpecularColor - ((int)FullScreenDebugMode.MinMaterialFullScreenDebug)] = new GUIContent("Metal or SpecularColor");
m_Data = new DebugData();
}
/// <summary>
/// Get Reset action.
/// </summary>
/// <returns></returns>
Action IDebugData.GetReset() => () =>
{
m_Data = new DebugData();
// This is not a debug property owned by `DebugData`, 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 float[] GetDebugMaterialIndexes()
{
return data.materialDebugSettings.GetDebugMaterialIndexes();
}
/// <summary>
/// Returns the current Light filtering mode.
/// </summary>
/// <returns>Current Light filtering mode.</returns>
public DebugLightFilterMode GetDebugLightFilterMode()
{
return data.lightingDebugSettings.debugLightFilterMode;
}
/// <summary>
/// Returns the current Lighting Debug Mode.
/// </summary>
/// <returns>Current Lighting Debug Mode.</returns>
public DebugLightingMode GetDebugLightingMode()
{
return data.lightingDebugSettings.debugLightingMode;
}
/// <summary>
/// Enable or disable Rendering layers Debug
/// </summary>
/// <param name="value">Desired Rendering Layers Debug Mode.</param>
public void SetDebugLightLayersMode(bool value)
{
if (value)
{
data.ResetExclusiveEnumIndices();
data.lightingDebugSettings.debugLightFilterMode = DebugLightFilterMode.None;
var builtins = typeof(Builtin.BuiltinData);
var attr = builtins.GetCustomAttributes(true)[0] as GenerateHLSL;
var renderingLayers = Array.IndexOf(builtins.GetFields(), builtins.GetField("renderingLayers"));
SetDebugViewMaterial(attr.paramDefinesStart + renderingLayers);
}
else
{
SetDebugViewMaterial(0);
}
}
internal bool IsDebuggingRenderingLayers()
{
var builtins = typeof(Builtin.BuiltinData);
var attr = builtins.GetCustomAttributes(true)[0] as GenerateHLSL;
var renderingLayers = Array.IndexOf(builtins.GetFields(), builtins.GetField("renderingLayers"));
return data.materialDebugSettings.debugViewMaterial[0] == 1 && data.materialDebugSettings.debugViewMaterial[1] == attr.paramDefinesStart + renderingLayers;
}
/// <summary>
/// Returns the current Light Layers Debug Mask.
/// </summary>
/// <returns>Current Light Layers Debug Mask.</returns>
public RenderingLayerMask GetDebugLightLayersMask()
{
var settings = data.lightingDebugSettings;
#if UNITY_EDITOR
if (settings.debugSelectionLightLayers)
{
if (UnityEditor.Selection.activeGameObject == null)
return 0;
var light = UnityEditor.Selection.activeGameObject.GetComponent<HDAdditionalLightData>();
if (light == null)
return 0;
if (settings.debugSelectionShadowLayers)
return (RenderingLayerMask)light.GetShadowLayers();
return (RenderingLayerMask)light.GetLightLayers();
}
#endif
return settings.debugLightLayersFilterMask;
}
/// <summary>
/// Returns the current Shadow Map Debug Mode.
/// </summary>
/// <returns>Current Shadow Map Debug Mode.</returns>
public ShadowMapDebugMode GetDebugShadowMapMode()
{
return data.lightingDebugSettings.shadowDebugMode;
}
/// <summary>
/// Returns the current Debug Mode for texture mipmap streaming.
/// </summary>
/// <returns>Current Debug Mode for texture mipmap streaming.</returns>
public DebugMipMapMode GetDebugMipMapMode()
{
return data.mipMapDebugSettings.debugMipMapMode;
}
/// <summary>
/// Returns the current Material Texture Slot for texture mipmap streaming.
/// </summary>
/// <returns>Current Material Texture Slot for texture mipmap streaming.</returns>
public int GetDebugMipMapMaterialTextureSlot()
{
return data.mipMapDebugSettings.materialTextureSlot;
}
/// <summary>
/// Returns the current aggregation mode when debug information can be aggregated per material.
/// </summary>
/// <returns>Current aggregation mode when debug information can be aggregated per material</returns>
public DebugMipMapStatusMode GetDebugMipMapStatusMode()
{
return data.mipMapDebugSettings.statusMode;
}
/// <summary>
/// Returns whether the status codes are rendered when the Texture Streaming Status debug mode is enabled.
/// </summary>
/// <returns>True if the status codes are rendered when the Texture Streaming Status debug mode is enabled.</returns>
public bool GetDebugMipMapShowStatusCode()
{
return data.mipMapDebugSettings.showStatusCode;
}
/// <summary>
/// Returns the opacity for texture mipmap streaming debugging colors.
/// </summary>
/// <returns>Opacity for texture mipmap streaming debugging colors.</returns>
public float GetDebugMipMapOpacity()
{
return data.mipMapDebugSettings.mipmapOpacity;
}
/// <summary>
/// Returns the amount of time (in seconds) that a texture should be considered recently updated.
/// </summary>
/// <returns>The amount of time (in seconds) that a texture should be considered recently updated.</returns>
public float GetDebugMipMapRecentlyUpdatedCooldown()
{
return data.mipMapDebugSettings.recentlyUpdatedCooldown;
}
/// <summary>
/// Returns the current Terrain Layer for texture mipmap streaming.
/// </summary>
/// <returns>Current Terrain Layer for texture mipmap streaming.</returns>
public DebugMipMapModeTerrainTexture GetDebugMipMapModeTerrainTexture()
{
return data.mipMapDebugSettings.terrainTexture;
}
/// <summary>
/// Returns the current Color Picker Mode.
/// </summary>
/// <returns>Current Color Picker Mode.</returns>
public ColorPickerDebugMode GetDebugColorPickerMode()
{
return data.colorPickerDebugSettings.colorPickerMode;
}
/// <summary>
/// Returns true if camera visibility is frozen.
/// </summary>
/// <returns>True if camera visibility is frozen</returns>
public bool IsCameraFreezeEnabled()
{
return data.debugCameraToFreeze != 0;
}
/// <summary>
/// Returns true if a specific camera is frozen for visibility.
/// </summary>
/// <param name="camera">Camera to be tested.</param>
/// <returns>True if a specific camera is frozen for visibility.</returns>
public bool IsCameraFrozen(Camera camera)
{
return IsCameraFreezeEnabled() && camera.name.Equals(s_CameraNamesStrings[data.debugCameraToFreeze].text);
}
/// <summary>
/// Returns true if any debug display is enabled.
/// </summary>
/// <returns>True if any debug display is enabled.</returns>
public bool IsDebugDisplayEnabled()
{
return data.materialDebugSettings.IsDebugDisplayEnabled() || data.lightingDebugSettings.IsDebugDisplayEnabled() || data.mipMapDebugSettings.IsDebugDisplayEnabled() || IsDebugFullScreenEnabled();
}
/// <summary>
/// Returns true if any material debug display is enabled.
/// </summary>
/// <returns>True if any material debug display is enabled.</returns>
public bool IsDebugMaterialDisplayEnabled()
{
return data.materialDebugSettings.IsDebugDisplayEnabled();
}
/// <summary>
/// Returns true if any full screen debug display is enabled.
/// </summary>
/// <returns>True if any full screen debug display is enabled.</returns>
public bool IsDebugFullScreenEnabled()
{
return data.fullScreenDebugMode != FullScreenDebugMode.None;
}
/// <summary>
/// Returns true if a full screen debug display supporting the FullScreenDebug pass is enabled.
/// </summary>
/// <returns>True if a full screen debug display supporting the FullScreenDebug pass is enabled.</returns>
internal bool IsFullScreenDebugPassEnabled()
{
return data.fullScreenDebugMode == FullScreenDebugMode.QuadOverdraw ||
data.fullScreenDebugMode == FullScreenDebugMode.VertexDensity;
}
/// <summary>
/// Returns true if any full screen exposure debug display is enabled.
/// </summary>
/// <returns>True if any full screen exposure debug display is enabled.</returns>
public bool IsDebugExposureModeEnabled()
{
return data.lightingDebugSettings.exposureDebugMode != ExposureDebugMode.None;
}
/// <summary>
/// Returns true if any full screen HDR debug display is enabled.
/// </summary>
/// <returns>True if any full screen exposure debug display is enabled.</returns>
public bool IsHDRDebugModeEnabled()
{
return data.lightingDebugSettings.hdrDebugMode != HDRDebugMode.None;
}
/// <summary>
/// Returns true if material validation is enabled.
/// </summary>
/// <returns>True if any material validation is enabled.</returns>
public bool IsMaterialValidationEnabled()
{
return (data.fullScreenDebugMode == FullScreenDebugMode.ValidateDiffuseColor) || (data.fullScreenDebugMode == FullScreenDebugMode.ValidateSpecularColor);
}
/// <summary>
/// Returns true if mip map debug display is enabled.
/// </summary>
/// <returns>True if any mip mapdebug display is enabled.</returns>
public bool IsDebugMipMapDisplayEnabled()
{
return data.mipMapDebugSettings.IsDebugDisplayEnabled();
}
/// <summary>
/// Returns true if matcap view is enabled for a particular camera.
/// </summary>
/// <param name="camera">Input camera.</param>
/// <returns>True if matcap view is enabled for a particular camera.</returns>
public bool IsMatcapViewEnabled(HDCamera camera)
{
bool sceneViewLightingDisabled = CoreUtils.IsSceneLightingDisabled(camera.camera);
return sceneViewLightingDisabled || GetDebugLightingMode() == DebugLightingMode.MatcapView;
}
private void DisableNonMaterialDebugSettings()
{
data.fullScreenDebugMode = FullScreenDebugMode.None;
data.lightingDebugSettings.debugLightingMode = DebugLightingMode.None;
data.mipMapDebugSettings.debugMipMapMode = DebugMipMapMode.None;
}
/// <summary>
/// Set the current shared material properties debug view.
/// </summary>
/// <param name="value">Desired shared material property to display.</param>
public void SetDebugViewCommonMaterialProperty(MaterialSharedProperty value)
{
if (value != MaterialSharedProperty.None)
DisableNonMaterialDebugSettings();
data.materialDebugSettings.SetDebugViewCommonMaterialProperty(value);
}
/// <summary>
/// Set the current material debug view.
/// </summary>
/// <param name="value">Desired material debug view.</param>
public void SetDebugViewMaterial(int value)
{
if (value != 0)
DisableNonMaterialDebugSettings();
data.materialDebugSettings.SetDebugViewMaterial(value);
}
/// <summary>
/// Set the current engine debug view.
/// </summary>
/// <param name="value">Desired engine debug view.</param>
public void SetDebugViewEngine(int value)
{
if (value != 0)
DisableNonMaterialDebugSettings();
data.materialDebugSettings.SetDebugViewEngine(value);
}
/// <summary>
/// Set current varying debug view.
/// </summary>
/// <param name="value">Desired varying debug view.</param>
public void SetDebugViewVarying(DebugViewVarying value)
{
if (value != 0)
DisableNonMaterialDebugSettings();
data.materialDebugSettings.SetDebugViewVarying(value);
}
/// <summary>
/// Set the current Material Property debug view.
/// </summary>
/// <param name="value">Desired property debug view.</param>
public void SetDebugViewProperties(DebugViewProperties value)
{
if (value != 0)
DisableNonMaterialDebugSettings();
data.materialDebugSettings.SetDebugViewProperties(value);
}
/// <summary>
/// Set the current GBuffer debug view.
/// </summary>
/// <param name="value">Desired GBuffer debug view.</param>
public void SetDebugViewGBuffer(int value)
{
if (value != 0)
DisableNonMaterialDebugSettings();
data.materialDebugSettings.SetDebugViewGBuffer(value);
}
/// <summary>
/// Set the current Full Screen Debug Mode.
/// </summary>
/// <param name="value">Desired Full Screen Debug mode.</param>
public void SetFullScreenDebugMode(FullScreenDebugMode value)
{
if (data.lightingDebugSettings.shadowDebugMode == ShadowMapDebugMode.SingleShadow)
value = 0;
if (data.mipMapDebugSettings.debugMipMapMode != DebugMipMapMode.None)
value = 0;
if (value != FullScreenDebugMode.None)
{
data.lightingDebugSettings.debugLightingMode = DebugLightingMode.None;
data.materialDebugSettings.DisableMaterialDebug();
data.mipMapDebugSettings.debugMipMapMode = DebugMipMapMode.None;
data.historyBuffersView = -1;
}
data.fullScreenDebugMode = value;
}
/// <summary>
/// Set the current History Buffers View.
/// </summary>
/// <param name="value">Desired History Buffer to view.</param>
public void SetHistoryBufferView(int value)
{
if (data.lightingDebugSettings.shadowDebugMode == ShadowMapDebugMode.SingleShadow)
value = 0;
if (value != -1)
{
data.lightingDebugSettings.debugLightingMode = DebugLightingMode.None;
data.materialDebugSettings.DisableMaterialDebug();
data.mipMapDebugSettings.debugMipMapMode = DebugMipMapMode.None;
data.fullScreenDebugMode = FullScreenDebugMode.None;
}
data.historyBuffersView = value;
}
/// <summary>
/// Set the current RTAS Full Screen Debug view.
/// </summary>
/// <param name="value">Desired Full Screen RTAS Debug view.</param>
public void SetRTASDebugView(RTASDebugView value)
{
data.rtasDebugView = value;
}
/// <summary>
/// Set the current RTAS Full Screen Debug mode.
/// </summary>
/// <param name="value">Desired Full Screen RTAS Debug mode.</param>
public void SetRTASDebugMode(RTASDebugMode value)
{
data.rtasDebugMode = value;
}
/// <summary>
/// Set the current Volumetric Clouds Debug mode.
/// </summary>
/// <param name="value">Desired Full Screen Volumetric Clouds Debug mode.</param>
public void SetVolumetricCloudsDebugMode(VolumetricCloudsDebug value)
{
data.volumetricCloudDebug = value;
}
/// <summary>
/// Set the current Shadow Map Debug Mode.
/// </summary>
/// <param name="value">Desired Shadow Map debug mode.</param>
public void SetShadowDebugMode(ShadowMapDebugMode value)
{
// When SingleShadow is enabled, we don't render full screen debug modes
if (value == ShadowMapDebugMode.SingleShadow)
data.fullScreenDebugMode = 0;
data.lightingDebugSettings.shadowDebugMode = value;
}
/// <summary>
/// Set the current Light Filtering.
/// </summary>
/// <param name="value">Desired Light Filtering.</param>
public void SetDebugLightFilterMode(DebugLightFilterMode value)
{
if (value != 0)
{
data.materialDebugSettings.DisableMaterialDebug();
data.mipMapDebugSettings.debugMipMapMode = DebugMipMapMode.None;
}
data.lightingDebugSettings.debugLightFilterMode = value;
}
/// <summary>
/// Set the current Lighting Debug Mode.
/// </summary>
/// <param name="value">Desired Lighting Debug Mode.</param>
public void SetDebugLightingMode(DebugLightingMode value)
{
if (value != 0)
{
data.fullScreenDebugMode = FullScreenDebugMode.None;
data.materialDebugSettings.DisableMaterialDebug();
data.mipMapDebugSettings.debugMipMapMode = DebugMipMapMode.None;
}
data.lightingDebugSettings.debugLightingMode = value;
}
/// <summary>
/// Set the current Exposure Debug Mode.
/// </summary>
/// <param name="value">Desired Exposure Debug Mode.</param>
internal void SetExposureDebugMode(ExposureDebugMode value)
{
data.lightingDebugSettings.exposureDebugMode = value;
}
/// <summary>
/// Set the current HDR Debug Mode.
/// </summary>
/// <param name="value">Desired HDR output Debug Mode.</param>
internal void SetHDRDebugMode(HDRDebugMode value)
{
data.lightingDebugSettings.hdrDebugMode = value;
}
/// <summary>
/// Set the current Mip Map Debug Mode.
/// </summary>
/// <param name="value">Desired Mip Map debug mode.</param>
public void SetMipMapMode(DebugMipMapMode value)
{
if (value != 0)
{
data.materialDebugSettings.DisableMaterialDebug();
data.lightingDebugSettings.debugLightingMode = DebugLightingMode.None;
data.fullScreenDebugMode = FullScreenDebugMode.None;
}
data.mipMapDebugSettings.debugMipMapMode = value;
}
/// <summary>
/// Set the current Mip Map Debug Material Texture Slot.
/// </summary>
/// <param name="value">Desired Mip Map debug Material Texture Slot.</param>