Add IndirectLightingIntensity to Sky for GI intensity control
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
#include "Engine/Graphics/Shaders/GPUShader.h"
|
||||
#include "Engine/Serialization/Serialization.h"
|
||||
#include "Engine/Level/Scene/SceneRendering.h"
|
||||
#if USE_EDITOR
|
||||
#include "Engine/Renderer/Lightmaps.h"
|
||||
#endif
|
||||
|
||||
GPU_CB_STRUCT(Data {
|
||||
Matrix WVP;
|
||||
@@ -66,6 +69,10 @@ void Sky::InitConfig(ShaderAtmosphericFogData& config) const
|
||||
|
||||
config.AtmosphericFogSunPower = SunPower;
|
||||
config.AtmosphericFogDensityOffset = 0.0f;
|
||||
#if USE_EDITOR
|
||||
if (IsRunningRadiancePass)
|
||||
config.AtmosphericFogSunPower *= IndirectLightingIntensity;
|
||||
#endif
|
||||
|
||||
if (SunLight)
|
||||
{
|
||||
@@ -140,6 +147,7 @@ void Sky::Serialize(SerializeStream& stream, const void* otherObj)
|
||||
SERIALIZE_MEMBER(Sun, SunLight);
|
||||
SERIALIZE(SunDiscScale);
|
||||
SERIALIZE(SunPower);
|
||||
SERIALIZE(IndirectLightingIntensity);
|
||||
}
|
||||
|
||||
void Sky::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
|
||||
@@ -150,6 +158,7 @@ void Sky::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
|
||||
DESERIALIZE_MEMBER(Sun, SunLight);
|
||||
DESERIALIZE(SunDiscScale);
|
||||
DESERIALIZE(SunPower);
|
||||
DESERIALIZE(IndirectLightingIntensity);
|
||||
}
|
||||
|
||||
bool Sky::HasContentLoaded() const
|
||||
@@ -204,6 +213,11 @@ bool Sky::IsDynamicSky() const
|
||||
return !IsStatic() || (SunLight && !SunLight->IsStatic());
|
||||
}
|
||||
|
||||
float Sky::GetIndirectLightingIntensity() const
|
||||
{
|
||||
return IndirectLightingIntensity;
|
||||
}
|
||||
|
||||
void Sky::ApplySky(GPUContext* context, RenderContext& renderContext, const Matrix& world)
|
||||
{
|
||||
// Get precomputed cache and bind it to the pipeline
|
||||
|
||||
@@ -31,21 +31,27 @@ public:
|
||||
/// <summary>
|
||||
/// Directional light that is used to simulate the sun.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="EditorOrder(10), DefaultValue(null), EditorDisplay(\"Sky\")")
|
||||
API_FIELD(Attributes="EditorOrder(10), EditorDisplay(\"Sky\")")
|
||||
ScriptingObjectReference<DirectionalLight> SunLight;
|
||||
|
||||
/// <summary>
|
||||
/// The sun disc scale.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="EditorOrder(20), DefaultValue(2.0f), EditorDisplay(\"Sky\"), Limit(0, 100, 0.01f)")
|
||||
API_FIELD(Attributes="EditorOrder(20), EditorDisplay(\"Sky\"), Limit(0, 100, 0.01f)")
|
||||
float SunDiscScale = 2.0f;
|
||||
|
||||
/// <summary>
|
||||
/// The sun power.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="EditorOrder(30), DefaultValue(8.0f), EditorDisplay(\"Sky\"), Limit(0, 1000, 0.01f)")
|
||||
API_FIELD(Attributes="EditorOrder(30), EditorDisplay(\"Sky\"), Limit(0, 1000, 0.01f)")
|
||||
float SunPower = 8.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Controls how much sky will contribute indirect lighting. When set to 0, there is no GI from the sky. The default value is 1.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="EditorOrder(40), Limit(0, 100, 0.1f), EditorDisplay(\"Sky\")")
|
||||
float IndirectLightingIntensity = 1.0f;
|
||||
|
||||
private:
|
||||
#if COMPILE_WITH_DEV_ENV
|
||||
void OnShaderReloading(Asset* obj)
|
||||
@@ -76,6 +82,7 @@ public:
|
||||
|
||||
// [ISkyRenderer]
|
||||
bool IsDynamicSky() const override;
|
||||
float GetIndirectLightingIntensity() const override;
|
||||
void ApplySky(GPUContext* context, RenderContext& renderContext, const Matrix& world) override;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -94,6 +94,11 @@ bool Skybox::IsDynamicSky() const
|
||||
return !IsStatic();
|
||||
}
|
||||
|
||||
float Skybox::GetIndirectLightingIntensity() const
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
void Skybox::ApplySky(GPUContext* context, RenderContext& renderContext, const Matrix& world)
|
||||
{
|
||||
// Prepare mock draw call data
|
||||
|
||||
@@ -70,6 +70,7 @@ public:
|
||||
|
||||
// [ISkyRenderer]
|
||||
bool IsDynamicSky() const override;
|
||||
float GetIndirectLightingIntensity() const override;
|
||||
void ApplySky(GPUContext* context, RenderContext& renderContext, const Matrix& world) override;
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user