void EvaluateShadowDebugView(CommandBuffer cmd, HDCamera hdCamera) { // If this is the right debug mode and the index we are asking for is in the range HDRenderPipeline hdrp = (RenderPipelineManager.currentPipeline as HDRenderPipeline); if (FullScreenDebugMode.ScreenSpaceShadows == hdrp.m_CurrentDebugDisplaySettings.data.fullScreenDebugMode) { if (!hdrp.rayTracingSupported || (m_ScreenSpaceShadowChannelSlot <= hdrp.m_CurrentDebugDisplaySettings.data.screenSpaceShadowIndex)) { // In this case we have not rendered any screenspace shadows, so push a black texture on the debug display hdrp.PushFullScreenDebugTexture(hdCamera, cmd, TextureXR.GetBlackTextureArray(), FullScreenDebugMode.ScreenSpaceShadows); return; } // Fetch the buffer where we we will store our result RTHandle debugResultBuffer = GetRayTracingBuffer(InternalRayTracingBuffers.RGBA0); // Generate the debug view SSShadowDebugParameters sssdParams = PrepareSSShadowDebugParameters(hdCamera, (int)hdrp.m_CurrentDebugDisplaySettings.data.screenSpaceShadowIndex); SSShadowDebugResources sssdResources = PrepareSSShadowDebugResources(debugResultBuffer); ExecuteShadowDebugView(cmd, sssdParams, sssdResources); // Push the full screen debug texture hdrp.PushFullScreenDebugTexture(hdCamera, cmd, debugResultBuffer, FullScreenDebugMode.ScreenSpaceShadows); } }
TextureHandle EvaluateShadowDebugView(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle screenSpaceShadowArray) { // If this is the right debug mode and the index we are asking for is in the range if (!rayTracingSupported || (m_ScreenSpaceShadowChannelSlot <= m_CurrentDebugDisplaySettings.data.screenSpaceShadowIndex)) { return(m_RenderGraph.defaultResources.blackTextureXR); } using (var builder = renderGraph.AddRenderPass <ScreenSpaceShadowDebugPassData>("Screen Space Shadows Debug", out var passData, ProfilingSampler.Get(HDProfileId.ScreenSpaceShadowsDebug))) { passData.parameters = PrepareSSShadowDebugParameters(hdCamera, (int)m_CurrentDebugDisplaySettings.data.screenSpaceShadowIndex); passData.screenSpaceShadowArray = builder.ReadTexture(screenSpaceShadowArray); passData.outputBuffer = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true) { colorFormat = GraphicsFormat.R16G16B16A16_SFloat, enableRandomWrite = true, name = "EvaluateShadowDebug" })); builder.SetRenderFunc( (ScreenSpaceShadowDebugPassData data, RenderGraphContext context) => { SSShadowDebugResources resources = new SSShadowDebugResources(); resources.screenSpaceShadowArray = data.screenSpaceShadowArray; resources.outputBuffer = data.outputBuffer; ExecuteShadowDebugView(context.cmd, data.parameters, resources); }); return(passData.outputBuffer); } }
SSShadowDebugResources PrepareSSShadowDebugResources(RTHandle debugResultBuffer) { SSShadowDebugResources sssdResources = new SSShadowDebugResources(); sssdResources.screenSpaceShadowArray = m_ScreenSpaceShadowTextureArray; sssdResources.outputBuffer = debugResultBuffer; return(sssdResources); }
static void ExecuteShadowDebugView(CommandBuffer cmd, SSShadowDebugParameters sssdParams, SSShadowDebugResources sssdResources) { // Evaluate the dispatch parameters int shadowTileSize = 8; int numTilesX = (sssdParams.texWidth + (shadowTileSize - 1)) / shadowTileSize; int numTilesY = (sssdParams.texHeight + (shadowTileSize - 1)) / shadowTileSize; // If the screen space shadows we are asked to deliver is available output it to the intermediate texture cmd.SetComputeIntParam(sssdParams.shadowFilter, HDShaderIDs._DenoisingHistorySlot, sssdParams.targetShadow); cmd.SetComputeTextureParam(sssdParams.shadowFilter, sssdParams.debugKernel, HDShaderIDs._ScreenSpaceShadowsTextureRW, sssdResources.screenSpaceShadowArray); cmd.SetComputeTextureParam(sssdParams.shadowFilter, sssdParams.debugKernel, HDShaderIDs._DenoiseOutputTextureRW, sssdResources.outputBuffer); cmd.DispatchCompute(sssdParams.shadowFilter, sssdParams.debugKernel, numTilesX, numTilesY, sssdParams.viewCount); }