Skip to content

Commit

Permalink
Add GlobalSDFDistance to graphics settings for default GlobalSDF range
Browse files Browse the repository at this point in the history
  • Loading branch information
mafiesto4 committed May 31, 2024
1 parent 19ad91d commit f78bbc6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Source/Engine/Core/Config/GraphicsSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings", NoConstructor) class
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>
Expand Down
2 changes: 1 addition & 1 deletion Source/Engine/Graphics/PostProcessSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion Source/Engine/Renderer/GlobalSignDistanceFieldPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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];

Expand Down

0 comments on commit f78bbc6

Please sign in to comment.