private void CopyCameraSortingLayerRenderTexture(ScriptableRenderContext context, RenderingData renderingData) { var cmd = CommandBufferPool.Get(); cmd.Clear(); this.CreateCameraSortingLayerRenderTexture(renderingData, cmd, m_Renderer2DData.cameraSortingLayerDownsamplingMethod); Material copyMaterial = m_Renderer2DData.cameraSortingLayerDownsamplingMethod == Downsampling._4xBox ? m_SamplingMaterial : m_BlitMaterial; RenderingUtils.Blit(cmd, colorAttachment, m_Renderer2DData.cameraSortingLayerRenderTarget.id, copyMaterial, 0, false, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); cmd.SetRenderTarget(colorAttachment); cmd.SetGlobalTexture(k_CameraSortingLayerTextureID, m_Renderer2DData.cameraSortingLayerRenderTarget.id); context.ExecuteCommandBuffer(cmd); }
/// <inheritdoc/> public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) { if (m_SamplingMaterial == null) { Debug.LogErrorFormat("Missing {0}. {1} render pass will not execute. Check for missing reference in the renderer resources.", m_SamplingMaterial, GetType().Name); return; } CommandBuffer cmd = CommandBufferPool.Get(); //It is possible that the given color target is now the frontbuffer if (source == renderingData.cameraData.renderer.GetCameraColorFrontBuffer(cmd)) { source = renderingData.cameraData.renderer.cameraColorTarget; } using (new ProfilingScope(cmd, ProfilingSampler.Get(URPProfileId.CopyColor))) { RenderTargetIdentifier opaqueColorRT = destination.Identifier(); ScriptableRenderer.SetRenderTarget(cmd, opaqueColorRT, BuiltinRenderTextureType.CameraTarget, clearFlag, clearColor); bool useDrawProceduleBlit = renderingData.cameraData.xr.enabled; switch (m_DownsamplingMethod) { case Downsampling.None: RenderingUtils.Blit(cmd, source, opaqueColorRT, m_CopyColorMaterial, 0, useDrawProceduleBlit); break; case Downsampling._2xBilinear: RenderingUtils.Blit(cmd, source, opaqueColorRT, m_CopyColorMaterial, 0, useDrawProceduleBlit); break; case Downsampling._4xBox: m_SamplingMaterial.SetFloat(m_SampleOffsetShaderHandle, 2); RenderingUtils.Blit(cmd, source, opaqueColorRT, m_SamplingMaterial, 0, useDrawProceduleBlit); break; case Downsampling._4xBilinear: RenderingUtils.Blit(cmd, source, opaqueColorRT, m_CopyColorMaterial, 0, useDrawProceduleBlit); break; } } context.ExecuteCommandBuffer(cmd); CommandBufferPool.Release(cmd); }