浏览代码

Merge pull request #260 from Unity-Technologies/Fix-shadow-debug-menu

HDRenderPipeline: Fix shadow debug menu (was not working after shadow merge)
/Branch_Batching2
GitHub 7 年前
当前提交
8a03f18c
共有 3 个文件被更改,包括 53 次插入31 次删除
  1. 50
      Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs
  2. 13
      Assets/ScriptableRenderPipeline/Core/Shadow/ShadowBase.cs
  3. 21
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs

50
Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs


{
switch( vl.lightType )
{
case LightType.Directional:
add = --m_MaxShadows[(int)GPUShadowType.Directional, 0] >= 0;
shadowType = GPUShadowType.Directional;
facecount = m_ShadowSettings.directionalLightCascadeCount;
case LightType.Directional:
add = --m_MaxShadows[(int)GPUShadowType.Directional, 0] >= 0;
shadowType = GPUShadowType.Directional;
facecount = m_ShadowSettings.directionalLightCascadeCount;
case LightType.Point:
add = --m_MaxShadows[(int)GPUShadowType.Point, 0] >= 0;
shadowType = GPUShadowType.Point;
facecount = 6;
case LightType.Point:
add = --m_MaxShadows[(int)GPUShadowType.Point, 0] >= 0;
shadowType = GPUShadowType.Point;
facecount = 6;
case LightType.Spot:
case LightType.Spot:
shadowType = GPUShadowType.Spot;
facecount = 1;
shadowType = GPUShadowType.Spot;
facecount = 1;
break;
}
}

{
sm.Update( frameId, renderContext, cullResults, lights );
}
}
}
public override void DisplayShadows(ScriptableRenderContext renderContext, Material displayMaterial, int shadowMapIndex, float screenX, float screenY, float screenSizeX, float screenSizeY)
{
using (new HDPipeline.Utilities.ProfilingSample("Display Shadows", renderContext))
{
// This code is specific to shadow atlas implementation
MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock();
CommandBuffer debugCB = new CommandBuffer();
debugCB.name = "Display shadow Overlay";
if (shadowMapIndex == -1) // Display the Atlas
{
propertyBlock.SetVector("_TextureScaleBias", new Vector4(1.0f, 1.0f, 0.0f, 0.0f));
}
else // Display particular index
{
VectorArray<ShadowData> shadowDatas = m_ShadowCtxt.shadowDatas;
uint shadowIdx = Math.Min((uint)shadowMapIndex, shadowDatas.Count());
propertyBlock.SetVector("_TextureScaleBias", shadowDatas[shadowIdx].scaleOffset);
}
debugCB.SetViewport(new Rect(screenX, screenY, screenSizeX, screenSizeY));
debugCB.DrawProcedural(Matrix4x4.identity, displayMaterial, 0, MeshTopology.Triangles, 3, 1, propertyBlock);
renderContext.ExecuteCommandBuffer(debugCB);
}
}

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


void ProcessShadowRequests( FrameId frameId, CullResults cullResults, Camera camera, VisibleLight[] lights, ref uint shadowRequestsCount, int[] shadowRequests, out int[] shadowDataIndices );
// Renders all shadows for lights the were deemed shadow casters after the last call to ProcessShadowRequests
void RenderShadows( FrameId frameId, ScriptableRenderContext renderContext, CullResults cullResults, VisibleLight[] lights );
// Debug function to display a shadow at the screen coordinate with the provided material.
void DisplayShadows(ScriptableRenderContext renderContext, Material displayMaterial, int shadowMapIndex, float screenX, float screenY, float screenSizeX, float screenSizeY);
// Synchronize data with GPU buffers
void SyncData();
// Binds resources to shader stages just before rendering the lighting pass

abstract public class ShadowManagerBase : ShadowRegistry, IShadowManager
{
public abstract void ProcessShadowRequests( FrameId frameId, CullResults cullResults, Camera camera, VisibleLight[] lights, ref uint shadowRequestsCount, int[] shadowRequests, out int[] shadowDataIndices );
public abstract void RenderShadows( FrameId frameId, ScriptableRenderContext renderContext, CullResults cullResults, VisibleLight[] lights );
public abstract void SyncData();
public abstract void BindResources( ScriptableRenderContext renderContext );
public abstract void UpdateCullingParameters( ref CullingParameters cullingParams );
public abstract void ProcessShadowRequests( FrameId frameId, CullResults cullResults, Camera camera, VisibleLight[] lights, ref uint shadowRequestsCount, int[] shadowRequests, out int[] shadowDataIndices );
public abstract void RenderShadows( FrameId frameId, ScriptableRenderContext renderContext, CullResults cullResults, VisibleLight[] lights );
public abstract void DisplayShadows(ScriptableRenderContext renderContext, Material displayMaterial, int shadowMapIndex, float screenX, float screenY, float screenSizeX, float screenSizeY);
public abstract void SyncData();
public abstract void BindResources( ScriptableRenderContext renderContext );
public abstract void UpdateCullingParameters( ref CullingParameters cullingParams );
// sort the shadow requests in descending priority - may only modify shadowRequests
protected abstract void PrioritizeShadowCasters( Camera camera, VisibleLight[] lights, uint shadowRequestsCount, int[] shadowRequests );
// prune the shadow requests - may modify shadowRequests and shadowsCountshadowRequestsCount

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


public override void RenderDebugOverlay(Camera camera, ScriptableRenderContext renderContext, DebugDisplaySettings debugDisplaySettings, ref float x, ref float y, float overlaySize, float width)
{
CommandBuffer debugCB = new CommandBuffer();
debugCB.name = "Lit Debug Overlay";
MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock();
LightingDebugSettings lightingDebug = debugDisplaySettings.lightingDebugSettings;
if (lightingDebug.shadowDebugMode != ShadowMapDebugMode.None)

m_ShadowMgr.DisplayShadows(renderContext, m_DebugDisplayShadowMap, (int)lightingDebug.shadowMapIndex, x, y, overlaySize, overlaySize);
Utilities.NextOverlayCoord(ref x, ref y, overlaySize, camera.pixelWidth);
// TODO: @Julien exchange shadowmapIndex by lightIndex and draw all slide like below
uint visualizeShadowIndex = Math.Min(lightingDebug.shadowMapIndex, (uint)(GetCurrentShadowCount() - 1));
ShadowLight shadowLight = m_ShadowsResult.shadowLights[visualizeShadowIndex];
for (int slice = 0; slice < shadowLight.shadowSliceCount; ++slice)
{
ShadowSliceData sliceData = m_ShadowsResult.shadowSlices[shadowLight.shadowSliceIndex + slice];

Utilities.NextOverlayCoord(ref x, ref y, overlaySize, camera.pixelWidth);
}
*/
*/
propertyBlock.SetVector("_TextureScaleBias", new Vector4(1.0f, 1.0f, 0.0f, 0.0f));
debugCB.SetViewport(new Rect(x, y, overlaySize, overlaySize));
debugCB.DrawProcedural(Matrix4x4.identity, m_DebugDisplayShadowMap, 0, MeshTopology.Triangles, 3, 1, propertyBlock);
m_ShadowMgr.DisplayShadows(renderContext, m_DebugDisplayShadowMap, -1, x, y, overlaySize, overlaySize);
renderContext.ExecuteCommandBuffer(debugCB);
}
}
}
正在加载...
取消
保存