New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NOSQUASH] Fix tonemapping and apply saturation even if tonemapping is disabled #14109
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conceptually, I agree with both of your changes. I think it would be good to split them into two commits.
However, I think that applying tonemapping and saturation before exposure and bloom doesn't make sense. Tonemapping should stay at the end of the "second stage" shader. Maybe you could move tonemapping after
minetest/client/shaders/second_stage/opengl_fragment.glsl
Lines 125 to 126 in 16c2247
// return to sRGB colorspace (approximate) | |
color.rgb = pow(color.rgb, vec3(1.0 / 2.2)); |
instead?
Sounds good. I'll move it, split the PR into two commits and mark it as NOSQUASH. |
c9ab02a
to
91aa09a
Compare
Done. I also edited lua_api.md to remove the mention of saturation requiring tonemapping. Hopefully I've re-applied everything correctly. |
cc @lhofhansl |
From @x2048
|
@@ -61,14 +61,17 @@ vec3 uncharted2Tonemap(vec3 x) | |||
|
|||
vec4 applyToneMapping(vec4 color) | |||
{ | |||
const float exposureBias = 2.0; | |||
color = vec4(pow(color.rgb, vec3(2.2)), color.a); | |||
const float gamma = 1.6; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These constants come out of nowhere somehow.
In any case I looked up the original commit (9df79a4) that changed this behavior, and these constants were there before.
So that's good then as long as we're happy with the visual outcome - which I think we are.
Tried it. Looks good to me. |
@@ -8001,9 +8001,8 @@ child will follow movement and rotation of that bone. | |||
* Passing no arguments resets lighting to its default values. | |||
* `light_definition` is a table with the following optional fields: | |||
* `saturation` sets the saturation (vividness; default: `1.0`). | |||
values > 1 increase the saturation | |||
values in [0,1) decrease the saturation | |||
* This value has no effect on clients who have the "Tone Mapping" shader disabled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it still has no effect if shaders are disabled entirely
Please rebase. |
values in [0,1) decrease the saturation | ||
* This value has no effect on clients who have the "Tone Mapping" shader disabled. | ||
* values > 1 increase the saturation | ||
* values in [0,1] decrease the saturation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually that was meant to read [0,1). In math ')' denotes the end of an interval excluding the end value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please write that out, don't rely on math notation like that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
This commit has changed the tone mapping function. In the old code, the EOTF was executed at the beginning in In the current code, the EOTF is executed before calling So, if I understand it correctly, to make the tone mapping work like it did before, only two changes in
However, there is low contrast, so I may be wrong: master, with tone mapping and the above-mentioned changes applied: |
@HybridDog I agree. But is better than before. Let's get this in, and then we can refine. @rollerozxa Can you please rebase? :) |
will do, sorry for the delay |
91aa09a
to
81b168c
Compare
Fixes #14088
This PR fixes the tonemapping effect and makes it look like it used to before bloom being added, by moving it above the "linear colorspace" conversion and reverting the changes made in
applyToneMapping
.It also moves the saturation effect outside of
ENABLE_TONE_MAPPING
so it's possible to use it without requiring tone mapping to be enabled. I don't know why it was made like that and it still works when moving it outside of the preprocessor blocks. If that should be moved into a separate PR then let me know.To do
This PR is Ready for Review.
How to test
Test with tonemapping enabled, see that it looks like it used to. (See #14088 (comment))
Also test such that other shader effects such as saturation aren't messed up because of the change (to test the saturation effect, you can install the Saturation Adjustment mod)