Improve GI quality

This commit is contained in:
Wojciech Figat
2022-06-02 18:13:15 +02:00
parent 641d04a50e
commit d05c09a33d
7 changed files with 16 additions and 17 deletions

BIN
Content/Shaders/GI/DDGI.flax (Stored with Git LFS)

Binary file not shown.

BIN
Content/Shaders/GI/GlobalSurfaceAtlas.flax (Stored with Git LFS)

Binary file not shown.

View File

@@ -208,11 +208,4 @@ void FoliageType::Deserialize(DeserializeStream& stream, ISerializeModifier* mod
DESERIALIZE(PlacementRandomRollAngle); DESERIALIZE(PlacementRandomRollAngle);
DESERIALIZE_BIT(PlacementAlignToNormal); DESERIALIZE_BIT(PlacementAlignToNormal);
DESERIALIZE_BIT(PlacementRandomYaw); DESERIALIZE_BIT(PlacementRandomYaw);
// [Deprecated on 07.02.2022, expires on 07.02.2024]
if (modifier->EngineBuild <= 6330)
DrawModes |= DrawPass::GlobalSDF;
// [Deprecated on 27.04.2022, expires on 27.04.2024]
if (modifier->EngineBuild <= 6331)
DrawModes |= DrawPass::GlobalSurfaceAtlas;
} }

View File

@@ -132,7 +132,7 @@ public:
/// <summary> /// <summary>
/// The draw passes to use for rendering this foliage type. /// The draw passes to use for rendering this foliage type.
/// </summary> /// </summary>
API_FIELD() DrawPass DrawModes = DrawPass::Default; API_FIELD() DrawPass DrawModes = DrawPass::Depth | DrawPass::GBuffer | DrawPass::Forward;
/// <summary> /// <summary>
/// The shadows casting mode. /// The shadows casting mode.

View File

@@ -28,6 +28,8 @@
#define GLOBAL_SURFACE_ATLAS_OBJECT_DATA_STRIDE 6 // Amount of float4s per-object #define GLOBAL_SURFACE_ATLAS_OBJECT_DATA_STRIDE 6 // Amount of float4s per-object
#define GLOBAL_SURFACE_ATLAS_TILE_DATA_STRIDE 5 // Amount of float4s per-tile #define GLOBAL_SURFACE_ATLAS_TILE_DATA_STRIDE 5 // Amount of float4s per-tile
#define GLOBAL_SURFACE_ATLAS_TILE_PADDING 1 // 1px padding to prevent color bleeding between tiles #define GLOBAL_SURFACE_ATLAS_TILE_PADDING 1 // 1px padding to prevent color bleeding between tiles
#define GLOBAL_SURFACE_ATLAS_TILE_SIZE_MIN 8 // The minimum size of the tile
#define GLOBAL_SURFACE_ATLAS_TILE_SIZE_MAX 192 // The maximum size of the tile
#define GLOBAL_SURFACE_ATLAS_TILE_PROJ_PLANE_OFFSET 0.1f // Small offset to prevent clipping with the closest triangles (shifts near and far planes) #define GLOBAL_SURFACE_ATLAS_TILE_PROJ_PLANE_OFFSET 0.1f // Small offset to prevent clipping with the closest triangles (shifts near and far planes)
#define GLOBAL_SURFACE_ATLAS_DEBUG_FORCE_REDRAW_TILES 0 // Forces to redraw all object tiles every frame #define GLOBAL_SURFACE_ATLAS_DEBUG_FORCE_REDRAW_TILES 0 // Forces to redraw all object tiles every frame
#define GLOBAL_SURFACE_ATLAS_DEBUG_DRAW_OBJECTS 0 // Debug draws object bounds on redraw (and tile draw projection locations) #define GLOBAL_SURFACE_ATLAS_DEBUG_DRAW_OBJECTS 0 // Debug draws object bounds on redraw (and tile draw projection locations)
@@ -1013,8 +1015,8 @@ void GlobalSurfaceAtlasPass::RasterizeActor(Actor* actor, void* actorObject, con
} }
// Clamp tile resolution (in pixels) // Clamp tile resolution (in pixels)
static_assert(GLOBAL_SURFACE_ATLAS_TILE_PADDING < 8, "Invalid tile size configuration. Minimum tile size must be larger than padding."); static_assert(GLOBAL_SURFACE_ATLAS_TILE_PADDING < GLOBAL_SURFACE_ATLAS_TILE_SIZE_MIN, "Invalid tile size configuration. Minimum tile size must be larger than padding.");
tileResolution = Math::Clamp<uint16>(tileResolution, 8, 128); tileResolution = Math::Clamp<uint16>(tileResolution, GLOBAL_SURFACE_ATLAS_TILE_SIZE_MIN, GLOBAL_SURFACE_ATLAS_TILE_SIZE_MAX);
// Snap tiles resolution (down) which allows to reuse atlas slots once object gets resizes/replaced by other object // Snap tiles resolution (down) which allows to reuse atlas slots once object gets resizes/replaced by other object
tileResolution = Math::AlignDown<uint16>(tileResolution, 8); tileResolution = Math::AlignDown<uint16>(tileResolution, 8);

View File

@@ -320,12 +320,13 @@ void CS_UpdateProbes(uint3 DispatchThreadId : SV_DispatchThreadID, uint GroupInd
#endif #endif
float3 irradianceDelta = result.rgb - previous; float3 irradianceDelta = result.rgb - previous;
float irradianceDeltaMax = Max3(abs(irradianceDelta)); float irradianceDeltaMax = Max3(abs(irradianceDelta));
if (irradianceDeltaMax > 0.25f) float irradianceDeltaLen = length(irradianceDelta);
if (irradianceDeltaMax > 0.2f)
{ {
// Reduce history weight after significant lighting change // Reduce history weight after significant lighting change
historyWeight = max(historyWeight - 0.2f, 0.0f); historyWeight = max(historyWeight - 0.7f, 0.0f);
} }
if (irradianceDeltaMax > 0.8f) if (irradianceDeltaLen > 2.0f)
{ {
// Reduce flickering during rapid brightness changes // Reduce flickering during rapid brightness changes
result.rgb = previous + (irradianceDelta * 0.25f); result.rgb = previous + (irradianceDelta * 0.25f);

View File

@@ -113,6 +113,9 @@ float4 PS_Lighting(AtlasVertexOutput input) : SV_Target
float4x4 tileLocalToWorld = Inverse(tile.WorldToLocal); float4x4 tileLocalToWorld = Inverse(tile.WorldToLocal);
gBuffer.WorldPos = mul(float4(gBufferTilePos, 1), tileLocalToWorld).xyz; gBuffer.WorldPos = mul(float4(gBufferTilePos, 1), tileLocalToWorld).xyz;
// Boost material diffuse color to improve GI
gBuffer.Color *= 1.1f;
#if INDIRECT_LIGHT #if INDIRECT_LIGHT
// Sample irradiance // Sample irradiance
float bias = 1.0f; float bias = 1.0f;