/// <inheritdoc /> public override void Setup(ScriptableRenderContext context, ref RenderingData renderingData) { CommandBuffer cmd = CommandBufferPool.Get(m_profilerTag); int width = renderingData.cameraData.cameraTargetDescriptor.width; int height = renderingData.cameraData.cameraTargetDescriptor.height; cmd.GetTemporaryRT(m_CameraColor.id, width, height); cmd.GetTemporaryRT(m_CameraDepth.id, width, height, 16); context.ExecuteCommandBuffer(cmd); CommandBufferPool.Release(cmd); ConfigureCameraTarget(m_CameraColor.Identifier(), m_CameraDepth.Identifier()); // 1) Render different colors to the MRT outputs (render a blue quad to output#0 and a red quad to output#1) //m_ColorToMrtOutputs[0] = m_CameraColor; m_ColorsToMrtsPass.Setup(ref renderingData, cameraColorTarget, m_ColorToMrtOutputs); EnqueuePass(m_ColorsToMrtsPass); // Notice that the renderPass clearColor (yellow) is applied. // 2) Copy results to the camera target // layout (margin/blit/margin/..) // x: <-0.04-><-0.44-><-0.04-><-0.44-><-0.04-> // y: <-0.25-><-0.50-><-0.25-> m_Viewport.x = 0.04f * width; m_Viewport.width = 0.44f * width; m_Viewport.y = 0.25f * height; m_Viewport.height = 0.50f * height; m_CopyToViewportPasses[0].Setup(m_ColorToMrtOutputs[0].Identifier(), m_CameraColor, m_Viewport); EnqueuePass(m_CopyToViewportPasses[0]); m_Viewport.x = (0.04f + 0.44f + 0.04f) * width; m_CopyToViewportPasses[1].Setup(m_ColorToMrtOutputs[1].Identifier(), m_CameraColor, m_Viewport); EnqueuePass(m_CopyToViewportPasses[1]); // 3) Final blit to the backbuffer m_FinalBlitPass.Setup(renderingData.cameraData.cameraTargetDescriptor, m_CameraColor); EnqueuePass(m_FinalBlitPass); }
/// <inheritdoc /> public override void Setup(ScriptableRenderContext context, ref RenderingData renderingData) { CommandBuffer cmd = CommandBufferPool.Get(m_profilerTag); cmd.GetTemporaryRT(Shader.PropertyToID(m_CameraColor.name), 1280, 720); cmd.GetTemporaryRT(Shader.PropertyToID(m_CameraDepth.name), 1280, 720, 16); context.ExecuteCommandBuffer(cmd); CommandBufferPool.Release(cmd); ConfigureCameraTarget(m_CameraColor.nameID, m_CameraDepth.nameID); // 1) Depth pre-pass m_DepthPrepass.Setup(renderingData.cameraData.cameraTargetDescriptor, m_CameraDepth); EnqueuePass(m_DepthPrepass); // 2) Forward opaque EnqueuePass(m_RenderOpaqueForwardPass); // will render to renderingData.cameraData.camera // 3) Final blit to the backbuffer m_FinalBlitPass.Setup(renderingData.cameraData.cameraTargetDescriptor, m_CameraColor); EnqueuePass(m_FinalBlitPass); }