浏览代码

Renamed shadow debug API based on feedback and added the slice parameter.

/RenderPassXR_Sandbox
Julien Ignace 8 年前
当前提交
c4442bb9
共有 4 个文件被更改,包括 35 次插入20 次删除
  1. 7
      Assets/ScriptableRenderPipeline/Core/Shadow/Resources/DebugDisplayShadowMap.shader
  2. 24
      Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs
  3. 20
      Assets/ScriptableRenderPipeline/Core/Shadow/ShadowBase.cs
  4. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs

7
Assets/ScriptableRenderPipeline/Core/Shadow/Resources/DebugDisplayShadowMap.shader


#include "../../../ShaderLibrary/Common.hlsl"
#define SHADOW_TILEPASS // TODO: Not sure it must be define, ask uygar
#include "../../../ShaderLibrary/Shadow/Shadow.hlsl"
#undef SHADOW_TILEPASS
float _TextureSlice;
SamplerState ltc_linear_clamp_sampler;
TEXTURE2D_ARRAY(_AtlasTexture);

float4 FragAtlas(Varyings input) : SV_Target
{
return SAMPLE_TEXTURE2D_ARRAY(_AtlasTexture, ltc_linear_clamp_sampler, input.texcoord, 0).xxxx;
return SAMPLE_TEXTURE2D_ARRAY(_AtlasTexture, ltc_linear_clamp_sampler, input.texcoord, _TextureSlice).xxxx;
}
ENDHLSL

24
Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs


// Nothing to do for this implementation here, as the atlas is reconstructed each frame, instead of keeping state across frames
}
override public void DisplayShadowMap(ScriptableRenderContext renderContext, Vector4 scaleBias, float screenX, float screenY, float screenSizeX, float screenSizeY)
override public void DisplayShadowMap(ScriptableRenderContext renderContext, Vector4 scaleBias, uint slice, float screenX, float screenY, float screenSizeX, float screenSizeY)
{
CommandBuffer debugCB = new CommandBuffer();
debugCB.name = "";

propertyBlock.SetVector("_TextureScaleBias", scaleBias);
propertyBlock.SetFloat("_TextureSlice", (float)slice);
debugCB.Dispose();
}
}

return (uint)m_Shadowmaps.Length;
}
public override uint GetShadowMapSliceCount(uint shadowMapIndex)
{
if (shadowMapIndex >= m_Shadowmaps.Length)
return 0;
return m_Shadowmaps[shadowMapIndex].slices;
}
public override uint GetShadowRequestCount()
{
return m_TmpRequests.Count();

}
}
public override void DisplayShadows(ScriptableRenderContext renderContext, int shadowMapRequestIndex, uint faceIndex, float screenX, float screenY, float screenSizeX, float screenSizeY)
public override void DisplayShadow(ScriptableRenderContext renderContext, int shadowRequestIndex, uint faceIndex, float screenX, float screenY, float screenSizeX, float screenSizeY)
uint index = Math.Max(0, Math.Min((uint)(m_ShadowIndices.Count() - 1), (uint)shadowMapRequestIndex));
uint index = Math.Max(0, Math.Min((uint)(m_ShadowIndices.Count() - 1), (uint)shadowRequestIndex));
m_Shadowmaps[texID].DisplayShadowMap(renderContext, faceData.scaleOffset, screenX, screenY, screenSizeX, screenSizeY);
m_Shadowmaps[texID].DisplayShadowMap(renderContext, faceData.scaleOffset, slice, screenX, screenY, screenSizeX, screenSizeY);
public override void DisplayShadowAtlas(ScriptableRenderContext renderContext, uint atlasIndex, float screenX, float screenY, float screenSizeX, float screenSizeY)
public override void DisplayShadowMap(ScriptableRenderContext renderContext, uint shadowMapIndex, uint sliceIndex, float screenX, float screenY, float screenSizeX, float screenSizeY)
uint index = Math.Max(0, Math.Min((uint)(m_Shadowmaps.Length - 1), atlasIndex));
m_Shadowmaps[index].DisplayShadowMap(renderContext, new Vector4(1.0f, 1.0f, 0.0f, 0.0f), screenX, screenY, screenSizeX, screenSizeY);
uint index = Math.Max(0, Math.Min((uint)(m_Shadowmaps.Length - 1), shadowMapIndex));
m_Shadowmaps[index].DisplayShadowMap(renderContext, new Vector4(1.0f, 1.0f, 0.0f, 0.0f), sliceIndex, screenX, screenY, screenSizeX, screenSizeY);
}
public override void SyncData()

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


protected readonly ShadowSupport m_ShadowSupport;
protected CullResults m_CullResults; // TODO: Temporary, due to CullResults dependency in ShadowUtils' matrix extraction code. Remove this member once that dependency is gone.
public uint width { get { return m_Width; } }
public uint height { get { return m_Height; } }
public uint slices { get { return m_Slices; } }
public struct BaseInit
{
public uint width; // width of the shadowmap

abstract public void ReserveSlots( ShadowContextStorage sc );
abstract public void Fill( ShadowContextStorage cs );
abstract protected void Register( GPUShadowType type, ShadowRegistry registry );
abstract public void DisplayShadowMap(ScriptableRenderContext renderContext, Vector4 scaleBias, float screenX, float screenY, float screenSizeX, float screenSizeY);
abstract public void DisplayShadowMap(ScriptableRenderContext renderContext, Vector4 scaleBias, uint slice, float screenX, float screenY, float screenSizeX, float screenSizeY);
}
interface IShadowManager

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, int shadowMapIndex, uint faceIndex, float screenX, float screenY, float screenSizeX, float screenSizeY);
void DisplayShadowAtlas(ScriptableRenderContext renderContext, uint atlasIndex, float screenX, float screenY, float screenSizeX, float screenSizeY);
// Debug function to display a shadow at the screen coordinate
void DisplayShadow(ScriptableRenderContext renderContext, int shadowIndex, uint faceIndex, float screenX, float screenY, float screenSizeX, float screenSizeY);
void DisplayShadowMap(ScriptableRenderContext renderContext, uint shadowMapIndex, uint sliceIndex, 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

uint GetShadowMapCount();
uint GetShadowMapSliceCount(uint shadowMapIndex);
uint GetShadowRequestCount();

{
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, int shadowMapIndex, uint faceIndex, float screenX, float screenY, float screenSizeX, float screenSizeY);
public abstract void DisplayShadowAtlas(ScriptableRenderContext renderContext, uint atlasIndex, float screenX, float screenY, float screenSizeX, float screenSizeY);
public abstract void DisplayShadow(ScriptableRenderContext renderContext, int shadowIndex, uint faceIndex, float screenX, float screenY, float screenSizeX, float screenSizeY);
public abstract void DisplayShadowMap(ScriptableRenderContext renderContext, uint shadowMapIndex, uint sliceIndex, 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 );

protected abstract void AllocateShadows( FrameId frameId, VisibleLight[] lights, uint totalGranted, ref VectorArray<ShadowmapBase.ShadowRequest> grantedRequests, ref VectorArray<int> shadowIndices, ref VectorArray<ShadowData> shadowmapDatas, ref VectorArray<ShadowPayload> shadowmapPayload );
public abstract uint GetShadowMapCount();
public abstract uint GetShadowMapSliceCount(uint shadowMapIndex);
public abstract uint GetShadowRequestCount();
public abstract uint GetShadowRequestFaceCount(uint requestIndex);
public abstract int GetShadowRequestIndex(Light light);

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


uint faceCount = m_ShadowMgr.GetShadowRequestFaceCount((uint)index);
for (uint i = 0; i < faceCount; ++i)
{
m_ShadowMgr.DisplayShadows(renderContext, index, i, x, y, overlaySize, overlaySize);
m_ShadowMgr.DisplayShadow(renderContext, index, i, x, y, overlaySize, overlaySize);
Utilities.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, camera.pixelWidth);
}
}

m_ShadowMgr.DisplayShadowAtlas(renderContext, lightingDebug.shadowAtlasIndex, x, y, overlaySize, overlaySize);
m_ShadowMgr.DisplayShadowMap(renderContext, lightingDebug.shadowAtlasIndex, 0, x, y, overlaySize, overlaySize);
Utilities.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, camera.pixelWidth);
}
}

正在加载...
取消
保存