Lighting probe: Option 1 SDFGI with low post-tonemap gamma and calibrated exposure

This commit is contained in:
Meta Vens 2026-12-05 23:16:40 +01:00
commit 9fd06b0370
3 changed files with 19 additions and 43 deletions

View file

@ -90,7 +90,7 @@ public static class AtmosphereLutBaker
MieScattering: new Vector3(3.2e-6f, 3.2e-6f, 3.2e-6f),
MieG: 0.78f,
SolarIrradiance: 17.5f,
CalibratedSunEnergy: 2.55f,
CalibratedSunEnergy: 2.85f,
FogMaxLengthMeters: 460f,
VolumetricFogDensity: 0.0008f,
VolumetricFogDetailSpread: 2.4f,
@ -120,7 +120,7 @@ public static class AtmosphereLutBaker
MieScattering: new Vector3(10.5e-6f, 8.8e-6f, 6.6e-6f),
MieG: 0.74f,
SolarIrradiance: 16.0f,
CalibratedSunEnergy: 2.05f,
CalibratedSunEnergy: 2.55f,
FogMaxLengthMeters: 380f,
VolumetricFogDensity: 0.0012f,
VolumetricFogDetailSpread: 2.2f,

View file

@ -16,8 +16,6 @@ public partial class AtmosphereSystem : Node
private Sky _sky = null!;
private ShaderMaterial _skyMat = null!;
private DirectionalLight3D _sun = null!;
private DirectionalLight3D _skyFill = null!;
private DirectionalLight3D _groundBounce = null!;
private FogVolume _valleyFog = null!;
private FogMaterial _valleyFogMat = null!;
private CanvasLayer _filmGrainLayer = null!;
@ -69,13 +67,20 @@ public partial class AtmosphereSystem : Node
Sky = _sky,
AmbientLightSource = Godot.Environment.AmbientSource.Disabled,
AmbientLightEnergy = 0.0f,
SdfgiEnabled = false,
// Option 1 (Low-Gamma): SDFGI multi-bounce + occlusion with zero flat ambient
SdfgiEnabled = true,
SdfgiUseOcclusion = true,
SdfgiBounceFeedback = 0.60f,
SdfgiCascades = 4,
SdfgiMinCellSize = 0.4f,
SdfgiEnergy = 0.85f,
// AgX tonemapping preserves orange/amber combat hues while rolling off HDR emitters smoothly
TonemapMode = Godot.Environment.ToneMapper.Agx,
TonemapAgxWhite = 6.0f,
TonemapAgxContrast = 1.35f,
TonemapExposure = 1.0f,
TonemapAgxContrast = 1.50f,
TonemapExposure = 0.84f,
// Normalized additive bloom strictly above GlowHdrThreshold=1.0 (zero diffuse screen smear)
GlowEnabled = true,
@ -98,12 +103,12 @@ public partial class AtmosphereSystem : Node
// Screen-space ambient occlusion for mech foot & building contact grounding
SsaoEnabled = true,
SsaoRadius = 1.15f,
SsaoIntensity = 2.2f,
SsaoIntensity = 1.85f,
SsaoPower = 1.5f,
SsaoDetail = 0.45f,
SsaoHorizon = 0.06f,
SsaoSharpness = 0.98f,
SsaoLightAffect = 0.24f,
SsaoLightAffect = 0.12f,
SsaoAOChannelAffect = 0.5f,
// Tier 1: Froxel volumetric fog (0..380/460m)
@ -181,24 +186,6 @@ public partial class AtmosphereSystem : Node
};
AddChild(_sun);
_skyFill = new DirectionalLight3D
{
Name = "SkyHemisphereFill",
ShadowEnabled = false,
LightVolumetricFogEnergy = 0.0f,
LightAngularDistance = 0.0f
};
AddChild(_skyFill);
_groundBounce = new DirectionalLight3D
{
Name = "GroundBounceFill",
ShadowEnabled = false,
LightVolumetricFogEnergy = 0.0f,
LightAngularDistance = 0.0f
};
AddChild(_groundBounce);
_valleyFogMat = new FogMaterial
{
Density = 0.0038f,
@ -217,6 +204,7 @@ public partial class AtmosphereSystem : Node
?? throw new InvalidOperationException("Failed to load res://film_grain.gdshader");
_filmGrainMat = new ShaderMaterial { Shader = grainShader };
_filmGrainMat.SetShaderParameter("grain_strength", 0.018f);
_filmGrainMat.SetShaderParameter("post_gamma", 1.32f);
_filmGrainLayer = new CanvasLayer
{
@ -263,20 +251,6 @@ public partial class AtmosphereSystem : Node
_sun.LightEnergy = baked.SunLightEnergy;
_sun.DirectionalShadowMaxDistance = preset.ShadowMaxDistance;
// Option 2: Shadowless directional sky-hemisphere + ground-bounce fill (zero flat ambient, zero SDFGI cost)
bool isSion = mapKind == ArenaMapKind.Sion;
_skyFill.RotationDegrees = new Vector3(-68f, preset.SunYawDeg + 180f, 0f);
_skyFill.LightColor = isSion
? new Color(0.56f, 0.72f, 0.98f)
: new Color(0.60f, 0.74f, 0.96f);
_skyFill.LightEnergy = isSion ? 0.14f : 0.07f;
_groundBounce.RotationDegrees = new Vector3(82f, preset.SunYawDeg, 0f);
_groundBounce.LightColor = isSion
? new Color(0.86f, 0.80f, 0.68f)
: new Color(0.92f, 0.70f, 0.44f);
_groundBounce.LightEnergy = isSion ? 0.08f : 0.05f;
_env.AmbientLightEnergy = preset.AmbientLightEnergy;
Color haze = baked.HazeColor;

View file

@ -6,6 +6,7 @@ render_mode blend_mix;
uniform sampler2D screen_tex : hint_screen_texture, filter_nearest;
uniform float grain_strength : hint_range(0.0, 0.1) = 0.018;
uniform float post_gamma : hint_range(0.5, 2.5) = 1.32;
float interleaved_gradient_noise(vec2 frag_xy, float frame_idx) {
vec2 p = frag_xy + vec2(frame_idx * 17.0, frame_idx * 31.0);
@ -14,12 +15,13 @@ float interleaved_gradient_noise(vec2 frag_xy, float frame_idx) {
void fragment() {
vec4 src = texture(screen_tex, SCREEN_UV);
vec3 graded = pow(max(src.rgb, vec3(0.0)), vec3(post_gamma));
float frame_idx = mod(floor(fract(TIME * 0.001) * 60000.0), 64.0);
float n = interleaved_gradient_noise(FRAGCOORD.xy, frame_idx);
float luma = dot(src.rgb, vec3(0.2126, 0.7152, 0.0722));
float luma = dot(graded, vec3(0.2126, 0.7152, 0.0722));
float midtone_weight = smoothstep(0.02, 0.18, luma) * (1.0 - 0.65 * smoothstep(0.65, 1.0, luma));
vec3 grained = clamp(src.rgb + vec3((n - 0.5) * 2.0 * grain_strength * midtone_weight), vec3(0.0), vec3(1.0));
vec3 grained = clamp(graded + vec3((n - 0.5) * 2.0 * grain_strength * midtone_weight), vec3(0.0), vec3(1.0));
COLOR = vec4(grained, src.a);
}