Add AfterGBufferPass for custom PostFx location
This commit is contained in:
@@ -635,7 +635,7 @@ API_ENUM() enum class PostProcessEffectLocation
|
||||
Default = 0,
|
||||
|
||||
/// <summary>
|
||||
///The 'before' in-build PostFx pass (bloom, color grading, etc.). After Forward Pass (transparency) and fog effects.
|
||||
/// The 'before' in-build PostFx pass (bloom, color grading, etc.). After Forward Pass (transparency) and fog effects.
|
||||
/// </summary>
|
||||
BeforePostProcessingPass = 1,
|
||||
|
||||
@@ -659,6 +659,11 @@ API_ENUM() enum class PostProcessEffectLocation
|
||||
/// </summary>
|
||||
CustomUpscale = 5,
|
||||
|
||||
/// <summary>
|
||||
/// The 'after' GBuffer rendering pass. Can be used to render custom geometry into GBuffer. Output is light buffer, single-target only (no output).
|
||||
/// </summary>
|
||||
AfterGBufferPass = 6,
|
||||
|
||||
API_ENUM(Attributes="HideInEditor")
|
||||
MAX,
|
||||
};
|
||||
|
||||
@@ -146,7 +146,7 @@ void DebugOverrideDrawCallsMaterial(const RenderContext& renderContext, IMateria
|
||||
|
||||
#endif
|
||||
|
||||
void GBufferPass::Fill(RenderContext& renderContext, GPUTextureView* lightBuffer)
|
||||
void GBufferPass::Fill(RenderContext& renderContext, GPUTexture* lightBuffer)
|
||||
{
|
||||
PROFILE_GPU_CPU("GBuffer");
|
||||
|
||||
@@ -155,7 +155,7 @@ void GBufferPass::Fill(RenderContext& renderContext, GPUTextureView* lightBuffer
|
||||
auto context = device->GetMainContext();
|
||||
GPUTextureView* targetBuffers[5] =
|
||||
{
|
||||
lightBuffer,
|
||||
lightBuffer->View(),
|
||||
renderContext.Buffers->GBuffer0->View(),
|
||||
renderContext.Buffers->GBuffer1->View(),
|
||||
renderContext.Buffers->GBuffer2->View(),
|
||||
@@ -168,7 +168,7 @@ void GBufferPass::Fill(RenderContext& renderContext, GPUTextureView* lightBuffer
|
||||
PROFILE_GPU_CPU_NAMED("Clear");
|
||||
|
||||
context->ClearDepth(*renderContext.Buffers->DepthBuffer);
|
||||
context->Clear(lightBuffer, Color::Transparent);
|
||||
context->Clear(lightBuffer->View(), Color::Transparent);
|
||||
context->Clear(renderContext.Buffers->GBuffer0->View(), Color::Transparent);
|
||||
context->Clear(renderContext.Buffers->GBuffer1->View(), Color::Transparent);
|
||||
context->Clear(renderContext.Buffers->GBuffer2->View(), Color(1, 0, 0, 0));
|
||||
@@ -192,7 +192,7 @@ void GBufferPass::Fill(RenderContext& renderContext, GPUTextureView* lightBuffer
|
||||
renderContext.List->Sky->ApplySky(context, renderContext, Matrix::Identity);
|
||||
GPUPipelineState* materialPs = context->GetState();
|
||||
const float complexity = (float)Math::Min(materialPs->Complexity, MATERIAL_COMPLEXITY_LIMIT) / MATERIAL_COMPLEXITY_LIMIT;
|
||||
context->Clear(lightBuffer, Color(complexity, complexity, complexity, 1.0f));
|
||||
context->Clear(lightBuffer->View(), Color(complexity, complexity, complexity, 1.0f));
|
||||
renderContext.List->Sky = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -208,16 +208,20 @@ void GBufferPass::Fill(RenderContext& renderContext, GPUTextureView* lightBuffer
|
||||
renderContext.List->ExecuteDrawCalls(renderContext, DrawCallsListType::GBuffer);
|
||||
|
||||
// Draw decals
|
||||
DrawDecals(renderContext, lightBuffer);
|
||||
DrawDecals(renderContext, lightBuffer->View());
|
||||
|
||||
// Draw objects that cannot get decals
|
||||
context->SetRenderTarget(*renderContext.Buffers->DepthBuffer, ToSpan(targetBuffers, ARRAY_COUNT(targetBuffers)));
|
||||
renderContext.List->ExecuteDrawCalls(renderContext, DrawCallsListType::GBufferNoDecals);
|
||||
|
||||
GPUTexture* nullTexture = nullptr;
|
||||
renderContext.List->RunCustomPostFxPass(context, renderContext, PostProcessEffectLocation::AfterGBufferPass, lightBuffer, nullTexture);
|
||||
|
||||
// Draw sky
|
||||
if (renderContext.List->Sky && _skyModel && _skyModel->CanBeRendered())
|
||||
{
|
||||
PROFILE_GPU_CPU_NAMED("Sky");
|
||||
context->SetRenderTarget(*renderContext.Buffers->DepthBuffer, ToSpan(targetBuffers, ARRAY_COUNT(targetBuffers)));
|
||||
DrawSky(renderContext, context);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
/// </summary>
|
||||
/// <param name="renderContext">The rendering context.</param>
|
||||
/// <param name="lightBuffer">Light buffer to output material emissive light and precomputed indirect lighting</param>
|
||||
void Fill(RenderContext& renderContext, GPUTextureView* lightBuffer);
|
||||
void Fill(RenderContext& renderContext, GPUTexture* lightBuffer);
|
||||
|
||||
/// <summary>
|
||||
/// Render debug view
|
||||
|
||||
@@ -268,7 +268,7 @@ void RenderList::RunPostFxPass(GPUContext* context, RenderContext& renderContext
|
||||
{
|
||||
if (fx->Location == locationB)
|
||||
{
|
||||
if (fx->UseSingleTarget)
|
||||
if (fx->UseSingleTarget || output == nullptr)
|
||||
{
|
||||
fx->Render(context, renderContext, input, nullptr);
|
||||
}
|
||||
@@ -301,9 +301,9 @@ void RenderList::RunMaterialPostFxPass(GPUContext* context, RenderContext& rende
|
||||
bindParams.Input = *input;
|
||||
material->Bind(bindParams);
|
||||
context->DrawFullscreenTriangle();
|
||||
context->ResetRenderTarget();
|
||||
Swap(output, input);
|
||||
}
|
||||
context->ResetRenderTarget();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ void RenderList::RunCustomPostFxPass(GPUContext* context, RenderContext& renderC
|
||||
{
|
||||
if (fx->Location == location)
|
||||
{
|
||||
if (fx->UseSingleTarget)
|
||||
if (fx->UseSingleTarget || output == nullptr)
|
||||
{
|
||||
fx->Render(context, renderContext, input, nullptr);
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont
|
||||
}
|
||||
|
||||
// Fill GBuffer
|
||||
GBufferPass::Instance()->Fill(renderContext, lightBuffer->View());
|
||||
GBufferPass::Instance()->Fill(renderContext, lightBuffer);
|
||||
|
||||
// Debug drawing
|
||||
if (renderContext.View.Mode == ViewMode::GlobalSDF)
|
||||
|
||||
Reference in New Issue
Block a user