Blend Environment glow before tonemapping and change default blend mode to screen.

Additionally, change the minimum `tonemap_white` parameter to `1.0`; users can increase `tonemap_exposure` for a similar effect to decreasing `tonemap_white` below `1.0`.

Co-authored-by: Hei <40064911+Lielay9@users.noreply.github.com>
Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
This commit is contained in:
Allen Pestaluky 2025-09-17 17:09:46 -04:00
parent 9a5d6d1049
commit cafc012b05
11 changed files with 150 additions and 80 deletions

View file

@ -208,7 +208,13 @@ void RendererEnvironmentStorage::environment_set_tonemap(RID p_env, RS::Environm
ERR_FAIL_NULL(env);
env->exposure = p_exposure;
env->tone_mapper = p_tone_mapper;
env->white = p_white;
if (p_tone_mapper == RS::ENV_TONE_MAPPER_LINEAR) {
env->white = 1.0; // With HDR output, this should be the output max value instead.
} else if (p_tone_mapper == RS::ENV_TONE_MAPPER_AGX) {
env->white = 16.29;
} else {
env->white = MAX(1.0, p_white); // Glow with screen blend mode does not work when white < 1.0.
}
}
RS::EnvironmentToneMapper RendererEnvironmentStorage::environment_get_tone_mapper(RID p_env) const {
@ -471,7 +477,7 @@ Vector<float> RendererEnvironmentStorage::environment_get_glow_levels(RID p_env)
float RendererEnvironmentStorage::environment_get_glow_intensity(RID p_env) const {
Environment *env = environment_owner.get_or_null(p_env);
ERR_FAIL_NULL_V(env, 0.8);
ERR_FAIL_NULL_V(env, 0.3);
return env->glow_intensity;
}
@ -495,7 +501,7 @@ float RendererEnvironmentStorage::environment_get_glow_mix(RID p_env) const {
RS::EnvironmentGlowBlendMode RendererEnvironmentStorage::environment_get_glow_blend_mode(RID p_env) const {
Environment *env = environment_owner.get_or_null(p_env);
ERR_FAIL_NULL_V(env, RS::ENV_GLOW_BLEND_MODE_SOFTLIGHT);
ERR_FAIL_NULL_V(env, RS::ENV_GLOW_BLEND_MODE_SCREEN);
return env->glow_blend_mode;
}

View file

@ -98,11 +98,11 @@ private:
// Glow
bool glow_enabled = false;
Vector<float> glow_levels;
float glow_intensity = 0.8;
float glow_intensity = 0.3;
float glow_strength = 1.0;
float glow_bloom = 0.0;
float glow_mix = 0.01;
RS::EnvironmentGlowBlendMode glow_blend_mode = RS::ENV_GLOW_BLEND_MODE_SOFTLIGHT;
RS::EnvironmentGlowBlendMode glow_blend_mode = RS::ENV_GLOW_BLEND_MODE_SCREEN;
float glow_hdr_bleed_threshold = 1.0;
float glow_hdr_luminance_cap = 12.0;
float glow_hdr_bleed_scale = 2.0;