diff --git a/Content/Shaders/GI/GlobalSurfaceAtlas.flax b/Content/Shaders/GI/GlobalSurfaceAtlas.flax index dedc2d667..113c96beb 100644 --- a/Content/Shaders/GI/GlobalSurfaceAtlas.flax +++ b/Content/Shaders/GI/GlobalSurfaceAtlas.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cd43051dd43bb23828e1f2f2001d9a2b008ebad085df44f1188a0e482f6f7e34 -size 12851 +oid sha256:16457c650f2c3f2e04356e579423ccf8cba776555409af7cbaf8f4dec407c1db +size 12835 diff --git a/Source/Engine/Graphics/PostProcessSettings.cpp b/Source/Engine/Graphics/PostProcessSettings.cpp index 0496a2a82..c49f46bf0 100644 --- a/Source/Engine/Graphics/PostProcessSettings.cpp +++ b/Source/Engine/Graphics/PostProcessSettings.cpp @@ -29,6 +29,7 @@ void GlobalIlluminationSettings::BlendWith(GlobalIlluminationSettings& other, fl const bool isHalf = weight >= 0.5f; BLEND_BOOL(Mode); BLEND_FLOAT(Intensity); + BLEND_FLOAT(BounceIntensity); BLEND_FLOAT(TemporalResponse); BLEND_FLOAT(Distance); BLEND_COL(FallbackIrradiance); diff --git a/Source/Engine/Graphics/PostProcessSettings.h b/Source/Engine/Graphics/PostProcessSettings.h index 4a3524c2a..cc59b5b4e 100644 --- a/Source/Engine/Graphics/PostProcessSettings.h +++ b/Source/Engine/Graphics/PostProcessSettings.h @@ -296,10 +296,15 @@ API_ENUM(Attributes="Flags") enum class GlobalIlluminationSettingsOverride : int /// FallbackIrradiance = 1 << 4, + /// + /// Overrides property. + /// + BounceIntensity = 1 << 5, + /// /// All properties. /// - All = Mode | Intensity | TemporalResponse | Distance | FallbackIrradiance, + All = Mode | Intensity | TemporalResponse | Distance | FallbackIrradiance | BounceIntensity, }; /// @@ -329,6 +334,12 @@ API_STRUCT() struct FLAXENGINE_API GlobalIlluminationSettings : ISerializable API_FIELD(Attributes="EditorOrder(10), Limit(0, 10, 0.01f), PostProcessSetting((int)GlobalIlluminationSettingsOverride.Intensity)") float Intensity = 1.0f; + /// + /// Global Illumination infinite indirect lighting bounce intensity scale. Can be used to boost or reduce GI effect for the light bouncing on the surfaces. + /// + API_FIELD(Attributes="EditorOrder(11), Limit(0, 10, 0.01f), PostProcessSetting((int)GlobalIlluminationSettingsOverride.BounceIntensity)") + float BounceIntensity = 1.0f; + /// /// 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. /// diff --git a/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp b/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp index d5c3b7efa..c56b1ec23 100644 --- a/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp +++ b/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp @@ -1000,12 +1000,12 @@ bool GlobalSurfaceAtlasPass::Render(RenderContext& renderContext, GPUContext* co // Draw draw indirect light from Global Illumination if (renderContext.View.Flags & ViewFlags::GI) { - switch (renderContext.List->Settings.GlobalIllumination.Mode) + switch (giSettings.Mode) { case GlobalIlluminationMode::DDGI: { DynamicDiffuseGlobalIlluminationPass::BindingData bindingDataDDGI; - if (!DynamicDiffuseGlobalIlluminationPass::Instance()->Get(renderContext.Buffers, bindingDataDDGI)) + if (giSettings.BounceIntensity > ZeroTolerance && !DynamicDiffuseGlobalIlluminationPass::Instance()->Get(renderContext.Buffers, bindingDataDDGI)) { _vertexBuffer->Clear(); for (const auto& e : surfaceAtlasData.Objects) @@ -1025,6 +1025,7 @@ bool GlobalSurfaceAtlasPass::Render(RenderContext& renderContext, GPUContext* co break; PROFILE_GPU_CPU("DDGI"); data.DDGI = bindingDataDDGI.Constants; + data.Light.Radius = giSettings.BounceIntensity / bindingDataDDGI.Constants.IndirectLightingIntensity; // Reuse for smaller CB context->BindSR(5, bindingDataDDGI.ProbesState); context->BindSR(6, bindingDataDDGI.ProbesDistance); context->BindSR(7, bindingDataDDGI.ProbesIrradiance); diff --git a/Source/Shaders/GI/GlobalSurfaceAtlas.shader b/Source/Shaders/GI/GlobalSurfaceAtlas.shader index 4bfdf168d..a9375e105 100644 --- a/Source/Shaders/GI/GlobalSurfaceAtlas.shader +++ b/Source/Shaders/GI/GlobalSurfaceAtlas.shader @@ -130,18 +130,16 @@ float4 PS_Lighting(AtlasVertexOutput input) : SV_Target gBuffer.WorldPos = mul(float4(gBufferTilePos, 1), tileLocalToWorld).xyz; // Boost material diffuse color to improve GI - gBuffer.Color *= 1.1f; + //gBuffer.Color *= 1.1f; #if INDIRECT_LIGHT // Sample irradiance - float bias = 1.0f; - float3 irradiance = SampleDDGIIrradiance(DDGI, ProbesState, ProbesDistance, ProbesIrradiance, gBuffer.WorldPos, gBuffer.Normal, bias); - irradiance /= DDGI.IndirectLightingIntensity; - //irradiance = 0; + float3 irradiance = SampleDDGIIrradiance(DDGI, ProbesState, ProbesDistance, ProbesIrradiance, gBuffer.WorldPos, gBuffer.Normal); + irradiance *= Light.Radius; // Cached BounceIntensity / IndirectLightingIntensity // Calculate lighting float3 diffuseColor = GetDiffuseColor(gBuffer); - diffuseColor = min(diffuseColor, 0.98f); // Nothing reflects diffuse like perfectly in the real world (ensure to have energy loss at each light bounce) + diffuseColor = min(diffuseColor, 0.9f); // Nothing reflects diffuse like perfectly in the real world (ensure to have energy loss at each light bounce) float3 diffuse = Diffuse_Lambert(diffuseColor); float4 light = float4(diffuse * irradiance * gBuffer.AO, 1); #else