Improve Environment adjustments (favor old behavior and quality).#111897
Merged
Repiteo merged 1 commit intoOct 23, 2025
Merged
Conversation
This was referenced Oct 22, 2025
Environment adjustments (favor old behavior).Environment adjustments (favor old behavior and quality).
clayjohn
approved these changes
Oct 23, 2025
clayjohn
left a comment
Member
There was a problem hiding this comment.
Discussed in the rendering meeting today. Thanks for discussing this and being responsive to feedback. This approach looks great!
…HDR 2D contrast. This commit changes adjustments to behave as follows for all rendering configurations: - Apply brightness to linear-encoded values, preventing contrast, saturation, and hue from being affected. - Apply contrast to perceptually uniform (nonlinear sRGB-encoded) values, matching existing behavior when HDR 2D is disabled and producing optimal visual quality. - Apply saturation with even color channel weights. This causes brightness of certain colors to change, but matches existing behavior when HDR 2D is disabled. Adjustments are applied after glow and tonemapping to match existing behavior.
9876d9a to
0c7f013
Compare
Contributor
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Environmentadjustments. godot-proposals#13195This PR supersedes:
This commit changes adjustments to behave as follows for all rendering configurations:
Adjustments are applied after glow and tonemapping to match existing behavior.
Summary
This PR is an alternative approach to the following:
Environmentadjustments (favor performance). #110630The saturation adjustment can be further improved as a followup PR:
Environmentsaturation color adjustment. #111898Rationale and screenshots
Rationale and screenshots for this PR can be found in godotengine/godot-proposals#13195.
Changes and improvements
The following is a summary of the key points that are further detailed in the proposal.
Brightness
HDR 2D Disabled
Problem: When HDR 2D is disabled in Godot 4.5 and earlier, the brightness adjustment is applied as a scaling of nonlinear sRGB-encoded values. This is incorrect in terms of CIE colorimetry and results in a change in saturation, hue, and contrast when brightness is adjusted.
To correct this issue, scaling is applied to linear-encoded RGB values, which results in relative luminance being scaled directly without affecting hue or saturation:
This PR also removes clipping from the conversion to nonlinear sRGB encoding, which may have impact on some scenes with bright values. A future PR could add back in explicit user-controlled clipping of bright values before applying adjustments, but I believe that the new behaviour in this PR is generally preferred:
HDR 2D Enabled
Problem: When HDR 2D is enabled in Godot 4.3 through 4.5, the brightness adjustment is not perceptually uniform, which makes it difficult to use as a "fade to black" effect.
In this video I demonstrate the two approaches to the brightness adjustment: brightness fades in and out with the sRGB transfer function and then without (cycling back and forth between the two). Note that without the sRGB transfer function, the image fully darkens very suddenly, making for a more abrupt transition:
brightess-scale.mp4
This PR corrects this issue by making the brightness adjustment more perceptually uniform when HDR 2D is enabled by using the nonlinear sRGB transfer function. The brightness adjustment is still correctly applied to linear-encoded RGB values.
Contrast
Problem: The contrast adjustment heavily darkens the image when HDR 2D is enabled and is very difficult to use and fine-tune. This problem happens because the contrast pivot is at a linear value of
0.5instead of a more common value of around0.18(middle grey) or0.214041140482232(sRGB 50%).This PR corrects this problem by changing the contrast pivot point to be
0.214(sRGB 50%), which better matches industry standards. The contrast is further improved by being applied to perceptually uniform R, G, and B values.0.5pivot)0.214pivot)Saturation
Problem: Low-luminance colours change in apparent brightness when saturation is changed. A prime example is deep blue colours which appear to brighten when saturation is decreased and darken when saturation is increased.
This problem remains unresolved with this PR, but could be solved in a future PR.
Docs
I suggest to use
tonemap_exposureinstead of scene brightness becausecamera_attributesexposure does not affect scenes without a camera that target a "canvas" background mode. But currently,tonemap_exposureis just not implemented at all for the Compatibility renderer.Notes to reviewers