diff --git a/Source/Engine/Graphics/RenderBuffers.cpp b/Source/Engine/Graphics/RenderBuffers.cpp index 32d0d1848..e0f4869ad 100644 --- a/Source/Engine/Graphics/RenderBuffers.cpp +++ b/Source/Engine/Graphics/RenderBuffers.cpp @@ -128,6 +128,8 @@ void RenderBuffers::SetUseAlpha(bool value) const RenderBuffers::CustomBuffer* RenderBuffers::FindCustomBuffer(const StringView& name) const { + if (LinkedCustomBuffers) + return LinkedCustomBuffers->FindCustomBuffer(name); for (const CustomBuffer* e : CustomBuffers) { if (e->Name == name) @@ -196,6 +198,7 @@ bool RenderBuffers::Init(int32 width, int32 height) void RenderBuffers::Release() { LastEyeAdaptationTime = 0; + LinkedCustomBuffers = nullptr; for (int32 i = 0; i < _resources.Count(); i++) _resources[i]->ReleaseGPU(); diff --git a/Source/Engine/Graphics/RenderBuffers.h b/Source/Engine/Graphics/RenderBuffers.h index 23db15523..4010760c9 100644 --- a/Source/Engine/Graphics/RenderBuffers.h +++ b/Source/Engine/Graphics/RenderBuffers.h @@ -178,6 +178,8 @@ public: template T* GetCustomBuffer(const StringView& name) { + if (LinkedCustomBuffers) + return LinkedCustomBuffers->GetCustomBuffer(name); CustomBuffer* result = (CustomBuffer*)FindCustomBuffer(name); if (!result) { @@ -206,6 +208,11 @@ public: /// API_FIELD(ReadOnly) GPUTexture* MotionVectors; + /// + /// External Render Buffers used to redirect FindCustomBuffer/GetCustomBuffer calls. Can be linked to other rendering task (eg. main game viewport) to reuse graphics effect state from it (eg. use GI from main game view in in-game camera renderer). + /// + API_FIELD() RenderBuffers* LinkedCustomBuffers = nullptr; + public: /// /// Allocates the buffers. diff --git a/Source/Engine/Renderer/Config.h b/Source/Engine/Renderer/Config.h index ac3fcbd6e..659369a71 100644 --- a/Source/Engine/Renderer/Config.h +++ b/Source/Engine/Renderer/Config.h @@ -117,6 +117,3 @@ PACK_STRUCT(struct ProbeData { // Default format for the shadow map textures #define SHADOW_MAPS_FORMAT PixelFormat::D16_UNorm - -// Material distortion offsets output pass (material uses PS_Distortion, ForwardPass resolves the offsets) -#define Distortion_Pass_Output_Format PixelFormat::R8G8B8A8_UNorm diff --git a/Source/Engine/Renderer/ForwardPass.cpp b/Source/Engine/Renderer/ForwardPass.cpp index 0eb637eea..53c9b74bd 100644 --- a/Source/Engine/Renderer/ForwardPass.cpp +++ b/Source/Engine/Renderer/ForwardPass.cpp @@ -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(); diff --git a/Source/Engine/Renderer/RenderList.cpp b/Source/Engine/Renderer/RenderList.cpp index 17bd8ee16..1a4cc0205 100644 --- a/Source/Engine/Renderer/RenderList.cpp +++ b/Source/Engine/Renderer/RenderList.cpp @@ -2,9 +2,6 @@ #include "RenderList.h" #include "Engine/Core/Collections/Sorting.h" -#if !BUILD_RELEASE -#include "Engine/Core/Utilities.h" -#endif #include "Engine/Graphics/Materials/IMaterial.h" #include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/GPUContext.h" @@ -649,9 +646,6 @@ void RenderList::ExecuteDrawCalls(const RenderContext& renderContext, DrawCallsL { if (list.IsEmpty()) return; -#if !BUILD_RELEASE - CHECK(Utilities::CountBits((uint32)renderContext.View.Pass) == 1); // Ensure proper pass is set (single bit flag) -#endif PROFILE_GPU_CPU("Drawing"); const auto* drawCallsData = drawCalls.Get(); const auto* listData = list.Indices.Get(); diff --git a/Source/Shaders/GI/DDGI.shader b/Source/Shaders/GI/DDGI.shader index 7090b9f94..258b38474 100644 --- a/Source/Shaders/GI/DDGI.shader +++ b/Source/Shaders/GI/DDGI.shader @@ -576,7 +576,7 @@ void PS_IndirectLighting(Quad_VS2PS input, out float4 output : SV_Target0) // Calculate lighting float3 diffuseColor = GetDiffuseColor(gBuffer); float3 diffuse = Diffuse_Lambert(diffuseColor); - output = float4(diffuse * irradiance * gBuffer.AO, saturate(length(irradiance))); + output.rgb = diffuse * irradiance * gBuffer.AO; } #endif