Add RenderBuffers::LinkedCustomBuffers to reuse main game viewport rendered state (eg. GI) in sub-rendered view

This commit is contained in:
Wojtek Figat
2023-02-01 11:05:29 +01:00
parent 831af77eff
commit ab51ecddb4
6 changed files with 14 additions and 15 deletions

View File

@@ -107,7 +107,7 @@ void ForwardPass::Render(RenderContext& renderContext, GPUTexture* input, GPUTex
const int32 height = renderContext.Buffers->GetHeight();
const int32 distortionWidth = width;
const int32 distortionHeight = height;
const auto tempDesc = GPUTextureDescription::New2D(distortionWidth, distortionHeight, Distortion_Pass_Output_Format);
const auto tempDesc = GPUTextureDescription::New2D(distortionWidth, distortionHeight, PixelFormat::R8G8B8A8_UNorm);
auto distortionRT = RenderTargetPool::Get(tempDesc);
RENDER_TARGET_POOL_SET_NAME(distortionRT, "Forward.Distortion");
@@ -119,15 +119,13 @@ void ForwardPass::Render(RenderContext& renderContext, GPUTexture* input, GPUTex
// Render distortion pass
view.Pass = DrawPass::Distortion;
mainCache->ExecuteDrawCalls(renderContext, distortionList);
// Copy combined frame with distortion from transparent materials
context->SetViewportAndScissors((float)width, (float)height);
context->ResetRenderTarget();
context->ResetSR();
// Bind inputs
context->BindSR(0, input);
context->BindSR(1, distortionRT);
// Copy combined frame with distortion from transparent materials
context->SetRenderTarget(output->View());
context->SetState(_psApplyDistortion);
context->DrawFullscreenTriangle();