Skip to content

Blend glow before tonemapping and change default to screen.#110671

Merged
clayjohn merged 1 commit into
godotengine:masterfrom
allenwp:environment-glow-consistent
Oct 15, 2025
Merged

Blend glow before tonemapping and change default to screen.#110671
clayjohn merged 1 commit into
godotengine:masterfrom
allenwp:environment-glow-consistent

Conversation

@allenwp
Copy link
Copy Markdown
Contributor

@allenwp allenwp commented Sep 18, 2025

Upgrading to Godot 4.6

This PR changed default values for glow effects. To restore similar behaviour of Godot 4.5 and earlier, please refer to the migration guide for the old glow default values.

This PR supersedes:

This PR is related to:

Rationale and screenshots

Rationale and additional screenshots for this PR can be found in godotengine/godot-proposals#13181.

Summary

Mobile and Forward+

Mobile and Forward+ now apply glow before the tonemap function, just like the Compatibility renderer, for all blend modes except for soft light. The white parameter is now used to normalize screen blend mode.

Notice how blending before tonemapping gives a softer, more realistic blending of the glow effect without hue shifts and harder edges introduced by blending after tonemapping:

Original scene Before tonemapping (screen, AgX, 16.29 white) After tonemapping (screen, AgX, 16.29 white)
original-scene before-tonemapping after-tonemapping

Compatibility

As described in the proposal, this PR applies glow to nonlinear sRGB encoded values in the Compatibility renderer.

Although blending is performed consistently between HDR 2D enabled and disabled, the result is substantially different. I believe this is related to other glow functions and is independent of the purpose of this PR (glow blending).

As a side effect of the new behaviour, #110670 is fixed.

Defaults

Previously the screen blend mode was the default for Compatibility and the soft light blend mode was used for Mobile and Forward+. This PR changes the default to be screen for all renderers.

I have also included defaults that were suggested in #52227, so this PR fully supersedes this original PR. (co-author added)

Future work

With other upcoming glow changes it might make sense to revisit these to ensure default level values are chosen to match Compatibility behaviour if Compatibility behaviour can be made to look acceptable. Or, if Compatibility can not be made to look as good as the other renderers, new defaults may be needed to better match new glow behaviour in Mobile and Forward+.

Performance

Blending glow before tonemapping improves performance by removing the need for a second tonemapping operation on glow values. Because glow is blended before tonemapping, tonemapping is applied only once to the final scene that includes the glow effect.

I've added mathematical simplifications and optimizations to the screen and soft light blend functions. Please let me know if you believe these should be in a separate PR instead. The soft light optimization comes from #110239. (co-author added)

To help with the performance impact of branching, specialization constants are likely needed in a followup PR for Mobile and Forward+ renderers.

Notes for reviewers

  1. Tonemap white parameter has been restricted to 1.0 and higher! Previously, you could set white to be less than 1.0, but that does not work with this new glow screen blend mode.
    • If users want to have a tonemap white that is less than 1.0, they should increase tonemap exposure instead. Decreasing tonemap white below 1.0 simply doesn't make sense.
  2. Should I avoid changing defaults for intensity and levels until Overhaul and optimize Glow in the mobile renderer #110077 has been implemented?
  3. [WIP Draft] The HDR mega-PR #110701 can be used to try out this glow PR with HDR support and the new HDR AgX tonemapper.

Comparisons

Screen blend mode

Renderer HDR 2D disabled HDR 2D enabled
Compatibility image image
Mobile image image
Forward+ image image

Soft light blend mode

Renderer HDR 2D disabled HDR 2D enabled
Mobile image image
Forward+ image image

@AThousandShips AThousandShips added this to the 4.x milestone Sep 19, 2025
@allenwp allenwp force-pushed the environment-glow-consistent branch 2 times, most recently from f3b8f80 to 7ff6a57 Compare September 22, 2025 21:40
@allenwp allenwp force-pushed the environment-glow-consistent branch 2 times, most recently from 6d1e33b to 8ad4e6c Compare September 24, 2025 20:48
@allenwp allenwp changed the title [WIP draft] Make Environment glow more consistent between rendering configurations Make Environment glow more consistent between rendering configurations Sep 24, 2025
@allenwp allenwp changed the title Make Environment glow more consistent between rendering configurations Make Environment glow blending more consistent between rendering configurations Sep 24, 2025
@allenwp allenwp force-pushed the environment-glow-consistent branch from 8ad4e6c to 8dc30a6 Compare September 29, 2025 14:45
@allenwp allenwp changed the title Make Environment glow blending more consistent between rendering configurations Make Environment glow blending more consistent between rendering configurations and add legacy mode. Sep 29, 2025
@allenwp
Copy link
Copy Markdown
Contributor Author

allenwp commented Sep 29, 2025

This PR is now ready for review.

@allenwp
Copy link
Copy Markdown
Contributor Author

allenwp commented Oct 1, 2025

I noticed a mistake in post.glsl (glow for Compatibility): Because glow is being applied before the nonlinear sRGB -> linear conversion, white needs to be transformed to nonlinear sRGB encoding first, otherwise there will be a mismatch between the white that is used in the tonemap function and the white that is used for screen blending on nonlinaer sRGB encoded values.

I've pushed a fix to correct this.

@allenwp allenwp force-pushed the environment-glow-consistent branch 2 times, most recently from ea557ac to 319bf81 Compare October 2, 2025 17:06
@allenwp
Copy link
Copy Markdown
Contributor Author

allenwp commented Oct 2, 2025

In yesterday's rendering meeting we discussed my proposed "Legacy mode" project setting for Environment effects and decided it was best to remove it from this PR. We came to this decision based on the following:

  • The maintenance cost of a legacy mode for glow and other environment effects is too high, given we would be looking at a timeframe of 5-10 years before Godot 5.
  • Few people would test legacy mode during development, so it would be prone to bugs and becoming broken in the future.
  • If some projects must maintain the exact visual behaviour of the existing environment effects, these game developers can create a custom build of the engine that uses the old effect behaviour.

While the last point is not ideal for some projects, our hope is that the new environment effects behaviour will be as capable as the existing behaviour. This means that there will be a pain point from upgrading because parameters will need to be readjusted to match the new behaviour. But our expectation is visuals that are as good, if not better, should be achievable with the new behaviour.

I will update the PR and proposal description to not include the original "Legacy mode" proposal.

I have pushed a new version of the PR and completed my work removing the "Legacy mode" from the code, so the PR is now again ready for review and testing.

@Repiteo
Copy link
Copy Markdown
Contributor

Repiteo commented Oct 3, 2025

Multiple reviewers is standard practice—something that implies compatibility breakage even moreso. Will wait for more rendering opinions first

@allenwp allenwp force-pushed the environment-glow-consistent branch from df547d3 to 87b4f24 Compare October 6, 2025 14:11
@allenwp
Copy link
Copy Markdown
Contributor Author

allenwp commented Oct 6, 2025

I've made a correction to the soft light blend mode documentation:

old (incorrectly referred to scene values):

Adds the glow effect to the image after modifying the glow influence based on the image value; dark values and bright values will not be influenced by glow and mid-range values will be highly influenced by glow. This approach avoids bright values becoming overly bright from the glow effect. The glow will have the largest influence on linear scene values of [code]0.25[/code] and will have no influence when applied to scene values greater than [code]1.0[/code].

new (correctly refers to post-tonemapped image values):

Adds the glow effect to the tonemapped image after modifying the glow influence based on the image value; dark values and bright values will not be influenced by glow and mid-range values will be highly influenced by glow. This approach avoids bright values becoming overly bright from the glow effect. The glow will have the largest influence on image values of [code]0.25[/code] and will have no influence when applied to image values greater than [code]1.0[/code].

@allenwp allenwp force-pushed the environment-glow-consistent branch from 87b4f24 to 37ae144 Compare October 8, 2025 20:41
@allenwp allenwp changed the title Make Environment glow blending more consistent between rendering configurations and add legacy mode. Make Environment glow blending more consistent between rendering configurations. Oct 8, 2025
@allenwp allenwp changed the title Make Environment glow blending more consistent between rendering configurations. Blend glow before tonemapping and change default to screen. Oct 9, 2025
@allenwp allenwp force-pushed the environment-glow-consistent branch from 37ae144 to 2aa6937 Compare October 9, 2025 14:35
@allenwp
Copy link
Copy Markdown
Contributor Author

allenwp commented Oct 9, 2025

In response to the discussion in last night's rendering meeting, I've updated this PR's text and commit text to better describe what this PR actually changes.

…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>
@allenwp allenwp force-pushed the environment-glow-consistent branch from 2aa6937 to cafc012 Compare October 10, 2025 16:08
@clayjohn clayjohn modified the milestones: 4.x, 4.6 Oct 15, 2025
Copy link
Copy Markdown
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Let's go ahead with this now since so many PRs are waiting for it.

As a note for other maintainers. This is a breaking change. It changes the default glow settings and changes the visual appearance of glow with all settings. This is necessary for 2 reasons:

  1. It simply looks better. Calculating glow before tonemapping just looks better when working with HDR content. Especially when using the new AgX tonemapper
  2. It makes glow behave consistently when using an HDR screen vs. an SDR screen. In 4.5, glow will look very different if you switch between the two. In the long run, making this change now, before adding HDR screen support will be worth it.

This has been discussed extensively with rendering contributors and we don't make this change lightly. Accordingly, we should call this out specifically in the dev release blog post, the beta blog post, and the release blog post. I will also call it out in the rendering update this fall.

@clayjohn clayjohn merged commit 36b9212 into godotengine:master Oct 15, 2025
20 checks passed
@clayjohn
Copy link
Copy Markdown
Member

Thank you!

@atirutw
Copy link
Copy Markdown
Contributor

atirutw commented Oct 15, 2025

Does this conflict with #52227 by any chance?

@AR-DEV-1
Copy link
Copy Markdown
Contributor

I don't think so because the PR is from 2021 & still hasn't been merged

Does this conflict with #52227 by any chance?

@Calinou
Copy link
Copy Markdown
Member

Calinou commented Oct 15, 2025

I don't think so because the PR is from 2021 & still hasn't been merged

Actually, yes, since all the new defaults from #52227 were incorporated into this PR. Therefore, I've closed #52227.

@clayjohn
Copy link
Copy Markdown
Member

Does this conflict with #52227 by any chance?

Ya, read the description. This PR specifically supersedes #52227

@gtibo
Copy link
Copy Markdown
Contributor

gtibo commented Jan 14, 2026

Hello @allenwp
I am currently gathering images and videos for the version 4.6 page.

I retrieved two images from your PR to illustrate this new feature on the release page. Unfortunately, the images on GitHub are not in the correct format and aspect ratio (HD 16:9). Do you happen to have any higher-quality images illustrating your PR?

Preferably, by presenting a clear side-by-side comparison, as you did with the street lamp.

image

For reference:
Release page draft: https://gtibo.github.io/godot-4.6-release-page/
And github repo: https://github.com/gtibo/godot-4.6-release-page

@allenwp
Copy link
Copy Markdown
Contributor Author

allenwp commented Jan 14, 2026

Sure, I can try and whip something up in the next week or two. I'm not the best for art/related stuff... so if you decide you'd like to make your own comparison, please message me on RocketChat and I can give you the exact configurations to use for screenshots that will highlight the changes!

@Nodragem
Copy link
Copy Markdown
Contributor

Nodragem commented Jan 16, 2026

Hello! I am trying 4.6.rc1 and the glow intensity has totally increased compared to 4.5:

4.6.rc1
Screenshot 2026-01-15 170227

4.5.1:
Screenshot 2026-01-15 170438

Do you know what is the factor by which I need to decrease the glow to get back to the original intensity? or should I just eyeball it?

EDIT: if I understand well, I just need to change the glow blending to softlight if I want the same effect as before?

@allenwp
Copy link
Copy Markdown
Contributor Author

allenwp commented Jan 16, 2026

If you have HDR 2D enabled, then yes, changing to soft light and changing the levels and intensity back to their 4.5.1 values will give you the same effect.

Changes to default values:

4.5.1 4.6
glow_levels = { 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0 } glow_levels = { 0.0, 0.8, 0.4, 0.1, 0.0, 0.0, 0.0 };
glow_intensity = 1.0 glow_intensity = 0.3
glow_blend_mode = Soft Light glow_blend_mode = Screen

If HDR 2D is disabled (the default for new projects), then there is no way to get the exact soft light behaviour from 4.5.1 and you will need to eyeball it. I recommend using the new default screen blend mode instead of soft light because soft light removes the glow effect when blending against dark backgrounds, which is typically not a desirable behaviour for a glow effect, even though it was previously the default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment