浏览代码

HDRenderPipeline: Update tile/cluster debug menu

/main
Sebastien Lagarde 7 年前
当前提交
2b182986
共有 4 个文件被更改,包括 50 次插入25 次删除
  1. 9
      ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs
  2. 12
      ScriptableRenderPipeline/HDRenderPipeline/Debug/LightingDebugPanel.cs
  3. 5
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  4. 49
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs

9
ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs


public static string kFullScreenDebugMip = "Fullscreen Debug Mip";
public static string kDisplaySkyReflectionDebug = "Display Sky Reflection";
public static string kSkyReflectionMipmapDebug = "Sky Reflection Mipmap";
public static string kTileDebug = "Tile Debug By Category";
public static string kTileClusterCategoryDebug = "Tile/Cluster Debug By Category";
public static string kTileClusterDebug = "Tile/Cluster Debug";
public float debugOverlayRatio = 0.33f;

DebugMenuManager.instance.AddDebugItem<LightingDebugPanel, Color>(kDebugLightingAlbedo, () => lightingDebugSettings.debugLightingAlbedo, (value) => lightingDebugSettings.debugLightingAlbedo = (Color)value);
DebugMenuManager.instance.AddDebugItem<bool>("Lighting", kDisplaySkyReflectionDebug, () => lightingDebugSettings.displaySkyReflection, (value) => lightingDebugSettings.displaySkyReflection = (bool)value);
DebugMenuManager.instance.AddDebugItem<LightingDebugPanel, float>(kSkyReflectionMipmapDebug, () => lightingDebugSettings.skyReflectionMipmap, (value) => lightingDebugSettings.skyReflectionMipmap = (float)value, DebugItemFlag.None, new DebugItemHandlerFloatMinMax(0.0f, 1.0f));
DebugMenuManager.instance.AddDebugItem<LightingDebugPanel, TilePass.TileSettings.TileDebug>(kTileDebug,() => lightingDebugSettings.tileDebugByCategory, (value) => lightingDebugSettings.tileDebugByCategory = (TilePass.TileSettings.TileDebug)value);
DebugMenuManager.instance.AddDebugItem<LightingDebugPanel, TilePass.TileSettings.TileClusterDebug>(kTileClusterDebug,() => lightingDebugSettings.tileClusterDebug, (value) => lightingDebugSettings.tileClusterDebug = (TilePass.TileSettings.TileClusterDebug)value);
DebugMenuManager.instance.AddDebugItem<LightingDebugPanel, TilePass.TileSettings.TileClusterCategoryDebug>(kTileClusterCategoryDebug,() => lightingDebugSettings.tileClusterDebugByCategory, (value) => lightingDebugSettings.tileClusterDebugByCategory = (TilePass.TileSettings.TileClusterCategoryDebug)value);
DebugMenuManager.instance.AddDebugItem<bool>("Rendering", "Display Opaque",() => renderingDebugSettings.displayOpaqueObjects, (value) => renderingDebugSettings.displayOpaqueObjects = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("Rendering", "Display Transparency",() => renderingDebugSettings.displayTransparentObjects, (value) => renderingDebugSettings.displayTransparentObjects = (bool)value);

public bool displaySkyReflection = false;
public float skyReflectionMipmap = 0.0f;
public TilePass.TileSettings.TileDebug tileDebugByCategory = TilePass.TileSettings.TileDebug.None;
public TilePass.TileSettings.TileClusterDebug tileClusterDebug = TilePass.TileSettings.TileClusterDebug.None;
public TilePass.TileSettings.TileClusterCategoryDebug tileClusterDebugByCategory = TilePass.TileSettings.TileClusterCategoryDebug.Punctual;
public void OnValidate()
{

12
ScriptableRenderPipeline/HDRenderPipeline/Debug/LightingDebugPanel.cs


using UnityEngine;
using UnityEngine;
using System;
#if UNITY_EDITOR

break;
}
m_DebugPanel.GetDebugItem(DebugDisplaySettings.kTileDebug).handler.OnEditorGUI();
DebugItem tileClusterDebug = m_DebugPanel.GetDebugItem(DebugDisplaySettings.kTileClusterDebug);
tileClusterDebug.handler.OnEditorGUI();
if ((int)tileClusterDebug.GetValue() != 0 && (int)tileClusterDebug.GetValue() != 3) // None and FeatureVariant
{
EditorGUI.indentLevel++;
m_DebugPanel.GetDebugItem(DebugDisplaySettings.kTileClusterCategoryDebug).handler.OnEditorGUI();
EditorGUI.indentLevel--;
}
DebugItem displaySkyReflecItem = m_DebugPanel.GetDebugItem(DebugDisplaySettings.kDisplaySkyReflectionDebug);
displaySkyReflecItem.handler.OnEditorGUI();

5
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


RenderForward(m_CullResults, camera, renderContext, cmd, ForwardPass.Opaque);
RenderForwardError(m_CullResults, camera, renderContext, cmd, ForwardPass.Opaque);
RenderLightingDebug(hdCamera, cmd, m_CameraColorBufferRT, m_CurrentDebugDisplaySettings, true);
RenderSky(hdCamera, cmd);

// Render all type of transparent forward (unlit, lit, complex (hair...)) to keep the sorting between transparent objects.
RenderForward(m_CullResults, camera, renderContext, cmd, ForwardPass.Transparent);
RenderForwardError(m_CullResults, camera, renderContext, cmd, ForwardPass.Transparent);
RenderLightingDebug(hdCamera, cmd, m_CameraColorBufferRT, m_CurrentDebugDisplaySettings, false);
PushFullScreenDebugTexture(cmd, m_CameraColorBuffer, camera, renderContext, FullScreenDebugMode.NanTracker);

}
}
RenderDebug(hdCamera, cmd);
if (camera.cameraType != CameraType.Reflection)
RenderDebug(hdCamera, cmd);
#if UNITY_EDITOR
// bind depth surface for editor grid/gizmo/selection rendering

49
ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs


[Range(0.0f, 1.0f)]
public float specularGlobalDimmer = 1.0f;
public enum TileDebug : int
public enum TileClusterDebug : int
{
None,
Tile,
Cluster,
FeatureVariants
};
public enum TileClusterCategoryDebug : int
None = 0, Punctual = 1, Area = 2, AreaAndPunctual = 3, Environment = 4, EnvironmentAndPunctual = 5, EnvironmentAndArea = 6, EnvironmentAndAreaAndPunctual = 7,
FeatureVariants = 8
}; //TODO: we should probably make this checkboxes
Punctual = 1,
Area = 2,
AreaAndPunctual = 3,
Environment = 4,
EnvironmentAndPunctual = 5,
EnvironmentAndArea = 6,
EnvironmentAndAreaAndPunctual = 7
};
public TileSettings()
{

public void RenderLightingDebug(HDCamera hdCamera, CommandBuffer cmd, RenderTargetIdentifier colorBuffer, DebugDisplaySettings debugDisplaySettings, bool renderOpaque)
{
LightingDebugSettings lightingDebug = debugDisplaySettings.lightingDebugSettings;
if (lightingDebug.tileDebugByCategory == TileSettings.TileDebug.None)
return;
if (lightingDebug.tileClusterDebug == TileSettings.TileClusterDebug.None ||
renderOpaque && lightingDebug.tileClusterDebug == TileSettings.TileClusterDebug.Cluster || // Cluster if for transparent
!renderOpaque && lightingDebug.tileClusterDebug == TileSettings.TileClusterDebug.Tile) // Tile is for opaque
return ;
using (new ProfilingSample(cmd, "Tiled Lighting Debug", HDRenderPipeline.GetSampler(CustomSamplerId.TPTiledLightingDebug)))
using (new ProfilingSample(cmd, "Tiled/cluster Lighting Debug", HDRenderPipeline.GetSampler(CustomSamplerId.TPTiledLightingDebug)))
bool bUseClusteredForDeferred = !renderOpaque;
int w = hdCamera.camera.pixelWidth;
int h = hdCamera.camera.pixelHeight;
int numTilesX = (w + 15) / 16;

Vector2 mousePixelCoord = Input.mousePosition;
#if UNITY_EDITOR
#if UNITY_EDITOR
#endif
#endif
if (lightingDebug.tileDebugByCategory == TileSettings.TileDebug.FeatureVariants)
if (lightingDebug.tileClusterDebug == TileSettings.TileClusterDebug.FeatureVariants)
m_DebugViewTilesMaterial.SetInt(HDShaderIDs._ViewTilesFlags, (int)lightingDebug.tileDebugByCategory);
m_DebugViewTilesMaterial.SetInt(HDShaderIDs._ViewTilesFlags, (int)lightingDebug.tileClusterDebugByCategory);
m_DebugViewTilesMaterial.EnableKeyword(bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST");
m_DebugViewTilesMaterial.DisableKeyword(!bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST");
m_DebugViewTilesMaterial.EnableKeyword("USE_FPTL_LIGHTLIST");
m_DebugViewTilesMaterial.DisableKeyword("USE_CLUSTERED_LIGHTLIST");
m_DebugViewTilesMaterial.DisableKeyword("SHOW_LIGHT_CATEGORIES");
m_DebugViewTilesMaterial.EnableKeyword("SHOW_FEATURE_VARIANTS");
cmd.SetRenderTarget(colorBuffer);

else if (lightingDebug.tileDebugByCategory != TileSettings.TileDebug.None)
else // tile or cluster
bool bUseClusteredForDeferred = lightingDebug.tileClusterDebug == TileSettings.TileClusterDebug.Cluster;
m_DebugViewTilesMaterial.SetInt(HDShaderIDs._ViewTilesFlags, (int)lightingDebug.tileDebugByCategory);
m_DebugViewTilesMaterial.SetInt(HDShaderIDs._ViewTilesFlags, (int)lightingDebug.tileClusterDebugByCategory);
m_DebugViewTilesMaterial.SetVector(HDShaderIDs._MousePixelCoord, mousePixelCoord);
m_DebugViewTilesMaterial.EnableKeyword(bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST");
m_DebugViewTilesMaterial.DisableKeyword(!bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST");

正在加载...
取消
保存