浏览代码

User can now display shadow map of the currently selected light.

/RenderPassXR_Sandbox
Julien Ignace 7 年前
当前提交
70b0ab1e
共有 7 个文件被更改,包括 54 次插入8 次删除
  1. 3
      Assets/ScriptableRenderPipeline/Core/Debugging/DebugPanel.cs
  2. 8
      Assets/ScriptableRenderPipeline/Core/Debugging/DebugPanelUI.cs
  3. 11
      Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs
  4. 3
      Assets/ScriptableRenderPipeline/Core/Shadow/ShadowBase.cs
  5. 3
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs
  6. 5
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/LightingDebugPanel.cs
  7. 29
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs

3
Assets/ScriptableRenderPipeline/Core/Debugging/DebugPanel.cs


public enum DebugItemFlag
{
None,
DynamicDisplay
DynamicDisplay,
EditorOnly
}
public class DebugItem

8
Assets/ScriptableRenderPipeline/Core/Debugging/DebugPanelUI.cs


m_ItemsUI.Clear();
for (int i = 0; i < m_DebugPanel.itemCount; i++)
{
DebugItemHandler handler = m_DebugPanel.GetDebugItem(i).handler; // Should never be null, we have at least the default handler
m_ItemsUI.Add(handler.BuildGUI(parent));
DebugItem item = m_DebugPanel.GetDebugItem(i);
if(!((item.flags & DebugItemFlag.EditorOnly) != 0))
{
DebugItemHandler handler = item.handler; // Should never be null, we have at least the default handler
m_ItemsUI.Add(handler.BuildGUI(parent));
}
}
}

11
Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs


return m_TmpRequests[requestIndex].facecount;
}
public override int GetShadowRequestIndex(Light light)
{
for(int i = 0 ; i < m_TmpRequests.Count() ; ++i)
{
if (m_TmpRequests[(uint)i].instanceId == light.GetInstanceID())
return i;
}
return -1;
}
public ShadowManager( ShadowSettings shadowSettings, ref ShadowContext.CtxtInit ctxtInitializer, ShadowmapBase[] shadowmaps )
{
m_ShadowSettings = shadowSettings;

3
Assets/ScriptableRenderPipeline/Core/Shadow/ShadowBase.cs


uint GetShadowRequestCount();
uint GetShadowRequestFaceCount(uint requestIndex);
int GetShadowRequestIndex(Light light);
}
abstract public class ShadowManagerBase : ShadowRegistry, IShadowManager

public abstract uint GetShadowMapCount();
public abstract uint GetShadowRequestCount();
public abstract uint GetShadowRequestFaceCount(uint requestIndex);
public abstract int GetShadowRequestIndex(Light light);
}
} // end of namespace UnityEngine.Experimental.ScriptableRenderLoop

3
Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs


{
public static string kEnableShadowDebug = "Enable Shadows";
public static string kShadowDebugMode = "Shadow Debug Mode";
public static string kShadowSelectionDebug = "Use Selection";
public static string kShadowMapIndexDebug = "Shadow Map Index";
public static string kShadowAtlasIndexDebug = "Shadow Atlas Index";
public static string kLightingDebugMode = "Lighting Debug Mode";

DebugMenuManager.instance.AddDebugItem<LightingDebugPanel, bool>(kEnableShadowDebug, () => lightingDebugSettings.enableShadows, (value) => lightingDebugSettings.enableShadows = (bool)value);
DebugMenuManager.instance.AddDebugItem<LightingDebugPanel, ShadowMapDebugMode>(kShadowDebugMode, () => lightingDebugSettings.shadowDebugMode, (value) => lightingDebugSettings.shadowDebugMode = (ShadowMapDebugMode)value);
DebugMenuManager.instance.AddDebugItem<LightingDebugPanel, bool>(kShadowSelectionDebug, () => lightingDebugSettings.shadowDebugUseSelection, (value) => lightingDebugSettings.shadowDebugUseSelection = (bool)value, DebugItemFlag.EditorOnly);
DebugMenuManager.instance.AddDebugItem<LightingDebugPanel, uint>(kShadowMapIndexDebug, () => lightingDebugSettings.shadowMapIndex, (value) => lightingDebugSettings.shadowMapIndex = (uint)value, DebugItemFlag.None, new DebugItemHandlerShadowIndex(1));
DebugMenuManager.instance.AddDebugItem<LightingDebugPanel, uint>(kShadowAtlasIndexDebug, () => lightingDebugSettings.shadowAtlasIndex, (value) => lightingDebugSettings.shadowAtlasIndex = (uint)value, DebugItemFlag.None, new DebugItemHandlerShadowAtlasIndex(1));
DebugMenuManager.instance.AddDebugItem<LightingDebugPanel, FullScreenDebugMode>(kFullScreenDebugMode, () => lightingDebugSettings.fullScreenDebugMode, (value) => lightingDebugSettings.fullScreenDebugMode = (FullScreenDebugMode)value);

public DebugLightingMode debugLightingMode = DebugLightingMode.None;
public bool enableShadows = true;
public ShadowMapDebugMode shadowDebugMode = ShadowMapDebugMode.None;
public bool shadowDebugUseSelection = false;
public uint shadowMapIndex = 0;
public uint shadowAtlasIndex = 0;
public FullScreenDebugMode fullScreenDebugMode = FullScreenDebugMode.None;

5
Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/LightingDebugPanel.cs


if ((ShadowMapDebugMode)shadowDebug.GetValue() == ShadowMapDebugMode.VisualizeShadowMap)
{
EditorGUI.indentLevel++;
m_DebugPanel.GetDebugItem(DebugDisplaySettings.kShadowMapIndexDebug).handler.OnEditorGUI();
DebugItem shadowSelectionDebug = m_DebugPanel.GetDebugItem(DebugDisplaySettings.kShadowSelectionDebug);
shadowSelectionDebug.handler.OnEditorGUI();
if(!(bool)shadowSelectionDebug.GetValue())
m_DebugPanel.GetDebugItem(DebugDisplaySettings.kShadowMapIndexDebug).handler.OnEditorGUI();
EditorGUI.indentLevel--;
}
if ((ShadowMapDebugMode)shadowDebug.GetValue() == ShadowMapDebugMode.VisualizeAtlas)

29
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs


{
if (lightingDebug.shadowDebugMode == ShadowMapDebugMode.VisualizeShadowMap)
{
uint faceCount = m_ShadowMgr.GetShadowRequestFaceCount(lightingDebug.shadowMapIndex);
for (uint i = 0; i < faceCount; ++i )
int index = (int)lightingDebug.shadowMapIndex;
#if UNITY_EDITOR
if(lightingDebug.shadowDebugUseSelection)
{
index = -1;
if (UnityEditor.Selection.activeObject is GameObject)
{
GameObject go = UnityEditor.Selection.activeObject as GameObject;
Light light = go.GetComponent<Light>();
if (light != null)
{
index = m_ShadowMgr.GetShadowRequestIndex(light);
}
}
}
#endif
if(index != -1)
m_ShadowMgr.DisplayShadows(renderContext, (int)lightingDebug.shadowMapIndex, i, x, y, overlaySize, overlaySize);
Utilities.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, camera.pixelWidth);
uint faceCount = m_ShadowMgr.GetShadowRequestFaceCount((uint)index);
for (uint i = 0; i < faceCount; ++i)
{
m_ShadowMgr.DisplayShadows(renderContext, index, i, x, y, overlaySize, overlaySize);
Utilities.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, camera.pixelWidth);
}
}
}
else if (lightingDebug.shadowDebugMode == ShadowMapDebugMode.VisualizeAtlas)

正在加载...
取消
保存