Add realtime sky/skybox capturing for GI
This commit is contained in:
@@ -272,6 +272,7 @@ bool DynamicDiffuseGlobalIlluminationPass::Render(RenderContext& renderContext,
|
||||
GlobalSurfaceAtlasPass::BindingData bindingDataSurfaceAtlas;
|
||||
if (GlobalSurfaceAtlasPass::Instance()->Render(renderContext, context, bindingDataSurfaceAtlas))
|
||||
return true;
|
||||
GPUTextureView* skybox = GBufferPass::Instance()->RenderSkybox(renderContext, context);
|
||||
|
||||
// Skip if already done in the current frame
|
||||
const auto currentFrame = Engine::FrameCount;
|
||||
@@ -411,6 +412,7 @@ bool DynamicDiffuseGlobalIlluminationPass::Render(RenderContext& renderContext,
|
||||
context->BindSR(10, bindingDataSurfaceAtlas.AtlasDepth->View());
|
||||
context->BindSR(11, bindingDataSurfaceAtlas.AtlasLighting->View());
|
||||
context->BindSR(12, ddgiData.Result.ProbesState);
|
||||
context->BindSR(13, skybox);
|
||||
context->BindUA(0, ddgiData.ProbesTrace->View());
|
||||
context->Dispatch(_csTraceRays, probeRaysCount / DDGI_TRACE_RAYS_GROUP_SIZE_X, probesCount, 1);
|
||||
context->ResetUA();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "GlobalSurfaceAtlasPass.h"
|
||||
#include "../GlobalSignDistanceFieldPass.h"
|
||||
#include "../GBufferPass.h"
|
||||
#include "../RenderList.h"
|
||||
#include "../ShadowsPass.h"
|
||||
#include "Engine/Core/Math/Matrix3x3.h"
|
||||
@@ -36,7 +37,7 @@ PACK_STRUCT(struct Data0
|
||||
{
|
||||
Vector3 ViewWorldPos;
|
||||
float ViewNearPlane;
|
||||
float Padding00;
|
||||
float SkyboxIntensity;
|
||||
uint32 CulledObjectsCapacity;
|
||||
float LightShadowsStrength;
|
||||
float ViewFarPlane;
|
||||
@@ -815,11 +816,12 @@ void GlobalSurfaceAtlasPass::RenderDebug(RenderContext& renderContext, GPUContex
|
||||
context->Draw(output, renderContext.Buffers->GBuffer0);
|
||||
return;
|
||||
}
|
||||
GPUTextureView* skybox = GBufferPass::Instance()->RenderSkybox(renderContext, context);
|
||||
|
||||
PROFILE_GPU_CPU("Global Surface Atlas Debug");
|
||||
const Vector2 outputSize(output->Size());
|
||||
Data0 data;
|
||||
{
|
||||
Data0 data;
|
||||
data.ViewWorldPos = renderContext.View.Position;
|
||||
data.ViewNearPlane = renderContext.View.Near;
|
||||
data.ViewFarPlane = renderContext.View.Far;
|
||||
@@ -827,6 +829,7 @@ void GlobalSurfaceAtlasPass::RenderDebug(RenderContext& renderContext, GPUContex
|
||||
data.ViewFrustumWorldRays[i] = Vector4(renderContext.List->FrustumCornersWs[i + 4], 0);
|
||||
data.GlobalSDF = bindingDataSDF.Constants;
|
||||
data.GlobalSurfaceAtlas = bindingData.Constants;
|
||||
data.SkyboxIntensity = 1.0f;
|
||||
context->UpdateCB(_cb0, &data);
|
||||
context->BindCB(0, _cb0);
|
||||
}
|
||||
@@ -838,6 +841,7 @@ void GlobalSurfaceAtlasPass::RenderDebug(RenderContext& renderContext, GPUContex
|
||||
context->BindSR(8, bindingData.Chunks ? bindingData.Chunks->View() : nullptr);
|
||||
context->BindSR(9, bindingData.CulledObjects ? bindingData.CulledObjects->View() : nullptr);
|
||||
context->BindSR(10, bindingData.AtlasDepth->View());
|
||||
context->BindSR(12, skybox);
|
||||
context->SetState(_psDebug);
|
||||
context->SetRenderTarget(output->View());
|
||||
{
|
||||
@@ -850,6 +854,10 @@ void GlobalSurfaceAtlasPass::RenderDebug(RenderContext& renderContext, GPUContex
|
||||
context->SetScissor(Rectangle(0, 0, outputSizeTwoThird.X, outputSize.Y));
|
||||
context->DrawFullscreenTriangle();
|
||||
|
||||
// Disable skybox
|
||||
data.SkyboxIntensity = 0.0f;
|
||||
context->UpdateCB(_cb0, &data);
|
||||
|
||||
// Bottom left - diffuse
|
||||
context->BindSR(11, bindingData.AtlasGBuffer0->View());
|
||||
context->SetViewportAndScissors(Viewport(outputSizeTwoThird.X, 0, outputSizeThird.X, outputSizeThird.Y));
|
||||
|
||||
Reference in New Issue
Block a user