diff --git a/Source/Engine/Core/Config/GraphicsSettings.cpp b/Source/Engine/Core/Config/GraphicsSettings.cpp
index 654e671db..33e669034 100644
--- a/Source/Engine/Core/Config/GraphicsSettings.cpp
+++ b/Source/Engine/Core/Config/GraphicsSettings.cpp
@@ -15,4 +15,5 @@ void GraphicsSettings::Apply()
Graphics::AllowCSMBlending = AllowCSMBlending;
Graphics::GlobalSDFQuality = GlobalSDFQuality;
Graphics::GIQuality = GIQuality;
+ Graphics::GlobalSurfaceAtlasResolution = GlobalSurfaceAtlasResolution;
}
diff --git a/Source/Engine/Core/Config/GraphicsSettings.h b/Source/Engine/Core/Config/GraphicsSettings.h
index 85caf77d8..0e42fafd0 100644
--- a/Source/Engine/Core/Config/GraphicsSettings.h
+++ b/Source/Engine/Core/Config/GraphicsSettings.h
@@ -71,7 +71,7 @@ public:
///
/// The Global SDF quality. Controls the volume texture resolution and amount of cascades to use.
///
- API_FIELD(Attributes="EditorOrder(2005), DefaultValue(Quality.High), EditorDisplay(\"Quality\")")
+ API_FIELD(Attributes="EditorOrder(2005), DefaultValue(Quality.High), EditorDisplay(\"Global SDF\")")
Quality GlobalSDFQuality = Quality::High;
#if USE_EDITOR
@@ -85,9 +85,15 @@ public:
///
/// The Global Illumination quality. Controls the quality of the GI effect.
///
- API_FIELD(Attributes="EditorOrder(2100), DefaultValue(Quality.High), EditorDisplay(\"Quality\")")
+ API_FIELD(Attributes="EditorOrder(2100), DefaultValue(Quality.High), EditorDisplay(\"Global Illumination\")")
Quality GIQuality = Quality::High;
+ ///
+ /// The Global Surface Atlas resolution. Adjust it if atlas `flickers` due to overflow (eg. to 4096).
+ ///
+ API_FIELD(Attributes="EditorOrder(2130), Limit(256, 8192), EditorDisplay(\"Global Illumination\")")
+ int32 GlobalSurfaceAtlasResolution = 2048;
+
public:
///
/// Gets the instance of the settings asset (default value if missing). Object returned by this method is always loaded with valid data to use.
diff --git a/Source/Engine/Graphics/Graphics.cpp b/Source/Engine/Graphics/Graphics.cpp
index f1baee478..6e6ee5731 100644
--- a/Source/Engine/Graphics/Graphics.cpp
+++ b/Source/Engine/Graphics/Graphics.cpp
@@ -16,6 +16,7 @@ Quality Graphics::ShadowMapsQuality = Quality::Medium;
bool Graphics::AllowCSMBlending = false;
Quality Graphics::GlobalSDFQuality = Quality::High;
Quality Graphics::GIQuality = Quality::High;
+int32 Graphics::GlobalSurfaceAtlasResolution = 2048;
#if GRAPHICS_API_NULL
extern GPUDevice* CreateGPUDeviceNull();
diff --git a/Source/Engine/Graphics/Graphics.h b/Source/Engine/Graphics/Graphics.h
index 01fa60749..a49380e9a 100644
--- a/Source/Engine/Graphics/Graphics.h
+++ b/Source/Engine/Graphics/Graphics.h
@@ -63,6 +63,11 @@ public:
///
API_FIELD() static Quality GIQuality;
+ ///
+ /// The Global Surface Atlas resolution. Adjust it if atlas `flickers` due to overflow.
+ ///
+ API_FIELD() static int32 GlobalSurfaceAtlasResolution;
+
public:
///
diff --git a/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp b/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp
index 58fcd43d0..42b984247 100644
--- a/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp
+++ b/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp
@@ -11,6 +11,7 @@
#include "Engine/Engine/Engine.h"
#include "Engine/Content/Content.h"
#include "Engine/Graphics/GPUDevice.h"
+#include "Engine/Graphics/Graphics.h"
#include "Engine/Graphics/RenderTask.h"
#include "Engine/Graphics/RenderBuffers.h"
#include "Engine/Graphics/RenderTargetPool.h"
@@ -344,8 +345,7 @@ bool GlobalSurfaceAtlasPass::Render(RenderContext& renderContext, GPUContext* co
PROFILE_GPU_CPU("Global Surface Atlas");
// Setup options
- // TODO: configurable via graphics settings
- const int32 resolution = 2048;
+ const int32 resolution = Math::Clamp(Graphics::GlobalSurfaceAtlasResolution, 256, GPU_MAX_TEXTURE_SIZE);
const float resolutionInv = 1.0f / resolution;
auto& giSettings = renderContext.List->Settings.GlobalIllumination;
const float distance = giSettings.Distance;
@@ -524,7 +524,7 @@ bool GlobalSurfaceAtlasPass::Render(RenderContext& renderContext, GPUContext* co
}
}
context->SetState(_psClear);
- context->SetViewportAndScissors(Viewport(0, 0, resolution, resolution));
+ context->SetViewportAndScissors(Viewport(0, 0, (float)resolution, (float)resolution));
VB_DRAW();
}
}
@@ -747,7 +747,7 @@ bool GlobalSurfaceAtlasPass::Render(RenderContext& renderContext, GPUContext* co
context->CopyTexture(surfaceAtlasData.AtlasLighting, 0, 0, 0, 0, surfaceAtlasData.AtlasEmissive, 0);
}
- context->SetViewportAndScissors(Viewport(0, 0, resolution, resolution));
+ context->SetViewportAndScissors(Viewport(0, 0, (float)resolution, (float)resolution));
context->SetRenderTarget(surfaceAtlasData.AtlasLighting->View());
context->BindSR(0, surfaceAtlasData.AtlasGBuffer0->View());
context->BindSR(1, surfaceAtlasData.AtlasGBuffer1->View());