Add BounceIntensity to Global Illumination settings
This commit is contained in:
BIN
Content/Shaders/GI/GlobalSurfaceAtlas.flax
(Stored with Git LFS)
BIN
Content/Shaders/GI/GlobalSurfaceAtlas.flax
(Stored with Git LFS)
Binary file not shown.
@@ -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);
|
||||
|
||||
@@ -296,10 +296,15 @@ API_ENUM(Attributes="Flags") enum class GlobalIlluminationSettingsOverride : int
|
||||
/// </summary>
|
||||
FallbackIrradiance = 1 << 4,
|
||||
|
||||
/// <summary>
|
||||
/// Overrides <see cref="GlobalIlluminationSettings.BounceIntensity"/> property.
|
||||
/// </summary>
|
||||
BounceIntensity = 1 << 5,
|
||||
|
||||
/// <summary>
|
||||
/// All properties.
|
||||
/// </summary>
|
||||
All = Mode | Intensity | TemporalResponse | Distance | FallbackIrradiance,
|
||||
All = Mode | Intensity | TemporalResponse | Distance | FallbackIrradiance | BounceIntensity,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Global Illumination infinite indirect lighting bounce intensity scale. Can be used to boost or reduce GI effect for the light bouncing on the surfaces.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="EditorOrder(11), Limit(0, 10, 0.01f), PostProcessSetting((int)GlobalIlluminationSettingsOverride.BounceIntensity)")
|
||||
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.
|
||||
/// </summary>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user