Add GlobalSDFDistance to graphics settings for default GlobalSDF range

#2664
This commit is contained in:
Wojtek Figat
2024-05-31 23:21:07 +02:00
parent 19ad91d5d8
commit f78bbc6b70
3 changed files with 12 additions and 2 deletions

View File

@@ -84,6 +84,12 @@ public:
API_FIELD(Attributes="EditorOrder(2000), EditorDisplay(\"Global SDF\")")
bool EnableGlobalSDF = false;
/// <summary>
/// Draw distance of the Global SDF. Actual value can be large when using DDGI.
/// </summary>
API_FIELD(Attributes="EditorOrder(2001), EditorDisplay(\"Global SDF\"), Limit(1000), ValueCategory(Utils.ValueCategory.Distance)")
float GlobalSDFDistance = 15000.0f;
/// <summary>
/// The Global SDF quality. Controls the volume texture resolution and amount of cascades to use.
/// </summary>

View File

@@ -358,7 +358,7 @@ API_STRUCT() struct FLAXENGINE_API GlobalIlluminationSettings : ISerializable
float BounceIntensity = 1.0f;
/// <summary>
/// Defines how quickly GI blends between the the current frame and the history buffer. Lower values update GI faster, but with more jittering and noise. If the camera in your game doesn't move much, we recommend values closer to 1.
/// Defines how quickly GI blends between the current frame and the history buffer. Lower values update GI faster, but with more jittering and noise. If the camera in your game doesn't move much, we recommend values closer to 1.
/// </summary>
API_FIELD(Attributes="EditorOrder(20), Limit(0, 1), PostProcessSetting((int)GlobalIlluminationSettingsOverride.TemporalResponse)")
float TemporalResponse = 0.9f;

View File

@@ -5,6 +5,7 @@
#include "Engine/Core/Math/Vector3.h"
#include "Engine/Core/Math/Matrix3x4.h"
#include "Engine/Core/Collections/HashSet.h"
#include "Engine/Core/Config/GraphicsSettings.h"
#include "Engine/Engine/Engine.h"
#include "Engine/Content/Content.h"
#include "Engine/Graphics/GPUContext.h"
@@ -411,7 +412,10 @@ bool GlobalSignDistanceFieldPass::Render(RenderContext& renderContext, GPUContex
}
const int32 resolutionMip = Math::DivideAndRoundUp(resolution, GLOBAL_SDF_RASTERIZE_MIP_FACTOR);
auto& giSettings = renderContext.List->Settings.GlobalIllumination;
const float distance = Math::Min(giSettings.Mode == GlobalIlluminationMode::DDGI ? giSettings.Distance : 15000.0f, renderContext.View.Far);
float distance = GraphicsSettings::Get()->GlobalSDFDistance;
if (giSettings.Mode == GlobalIlluminationMode::DDGI)
distance = Math::Max(distance, giSettings.Distance);
distance = Math::Min(distance, renderContext.View.Far);
const float cascadesDistanceScales[] = { 1.0f, 2.5f, 5.0f, 10.0f };
const float distanceExtent = distance / cascadesDistanceScales[cascadesCount - 1];