Add Global Surface Atlas resolution setting

This commit is contained in:
Wojciech Figat
2022-06-13 12:38:01 +02:00
parent 1fc26a63a7
commit 78afe60343
5 changed files with 19 additions and 6 deletions

View File

@@ -15,4 +15,5 @@ void GraphicsSettings::Apply()
Graphics::AllowCSMBlending = AllowCSMBlending;
Graphics::GlobalSDFQuality = GlobalSDFQuality;
Graphics::GIQuality = GIQuality;
Graphics::GlobalSurfaceAtlasResolution = GlobalSurfaceAtlasResolution;
}

View File

@@ -71,7 +71,7 @@ public:
/// <summary>
/// The Global SDF quality. Controls the volume texture resolution and amount of cascades to use.
/// </summary>
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:
/// <summary>
/// The Global Illumination quality. Controls the quality of the GI effect.
/// </summary>
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;
/// <summary>
/// The Global Surface Atlas resolution. Adjust it if atlas `flickers` due to overflow (eg. to 4096).
/// </summary>
API_FIELD(Attributes="EditorOrder(2130), Limit(256, 8192), EditorDisplay(\"Global Illumination\")")
int32 GlobalSurfaceAtlasResolution = 2048;
public:
/// <summary>
/// Gets the instance of the settings asset (default value if missing). Object returned by this method is always loaded with valid data to use.

View File

@@ -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();

View File

@@ -63,6 +63,11 @@ public:
/// </summary>
API_FIELD() static Quality GIQuality;
/// <summary>
/// The Global Surface Atlas resolution. Adjust it if atlas `flickers` due to overflow.
/// </summary>
API_FIELD() static int32 GlobalSurfaceAtlasResolution;
public:
/// <summary>

View File

@@ -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());