Open MaxG2D opened 1 year ago
Before: After:
Firstly, thanks for the PR.
Full disclosure: I've not at all been active in ReShade shader development for well over an year now, so I apologize in advance if I come off a little rusty or dismissive, that is not my intention at all.
Looking over the tonemap algorithm, it seems to me that it is simply the Uncharted 2 tonemapper with different constants. Normally in cases like this where two things are so similar, I'd prefer to merge both with some sort of macro or function that can have the constants as parameters.
Also the reason for the UC2 tonemapper port to lack a W parameter is simply because it is canonically set to 1.0
, which makes it redundant in the algorithm (obviously not if you do change it).
Regarding the random color shifts/precision loss, that is the same case with the UC2 tonemapper. Maybe it's due to there being way too many variables involved (it is a rather convoluted algorithm, just compare it to ACES).
Lastly, about the fix for #3, if I understand correctly all it does is set the adaptation texture to always have a single mip level outside of OpenGL. That'd break the whole point of using mipmaps though, no? The reason for them is to get an average of the entire texture, which is possible through the last mip level of a texture. When working with OpenGL it seems it tends to not like non power of two (NPOT) textures when using mipmaps, but I thought maybe it was not an issue with DirectX since it did not break for me.
Maybe always using the OpenGL path would work? It'd make the last texture 1:1 rather than follow the aspect ratio of the game though.
I can resolve some nitpicks with further commits while pulling the PR though so don't worry about that.
Thanks for the detailed reply!
The color loss was mostly me being stupid and doing things wrong, with my last commit, it's very close to what ENB would output, AKA, real HDR bloom, so I'm pretty happy with the result.
It is indeed Uncharted 2 function, with different constant values and added White point parameter, that's how F4 tonemapping works apparently. While it totally could be made by promoting the static floats to UI configuration, I felt like it would be more user friendly if I would supply it as a preset. Not everybody will dig enough to get the knowledge of how F4 tonemapper works.
Regarding the compiling problem, you're right it would be better to simply set it to 1:1 pixels. Not really sure what's causing the problem for Reshade, this error is weird, cause it works just fine in some games, but doesn't in others.
Anyways, I just thought I'd share my stuff and some people might enjoy it. BTW, thank you very much for you work, it's some awesome stuff and it allows to create some very nice results!
@luluco250 Hey, I've worked on it a bit more, so here's a bunch of key notes:
Hey @luluco250, I think I've pushed a last update, don't see much to add anymore to this wonderful shader of yours. Out of notable new changes, I've added border UV to sampler, so that gets rid of bloom going crazy at the screen edges, added optional contrast function to bloom texture, and as you suggested, 1x1 pixel adaptation from OpenGL implementation is now used in every API to avoid #3 issue. Feel free to merge, or not, no pressure, and thanks for making all the awesome shaders for ReShade throughout the years :)
Just a heads up @luluco250, I've recently got myself a HDR display, and I've did some more edits to make MagicHDR compatible with HDR input\output. Feel free it use it however you want, it works pretty well for my use case, perhaps it will be also useful to somebody else :)
Thanks, I'll keep it in mind.
Only reason I haven't merged is because I'm not currently working with ReShade so I don't have time to review/integrate it, but thanks a lot!
All credit goes to kingeric1992 at ENB Forums for deciphering the formula (http://enbseries.enbdev.com/forum/viewtopic.php?f=7&t=4695).
Also, added a naive fix to a Issue #3 , reusing the OpenGL route, otherwise, it was throwing the same error in Fo4 on 3440x1440 resolution.