h3r2tic / tony-mc-mapface

A cool-headed display transform
Apache License 2.0
325 stars 10 forks source link

Any estimate on when the source implementation will be out ? #5

Open Froyok opened 1 year ago

Froyok commented 1 year ago

Hi,

I really like Tony McMapface, it has a really great behavior and I have it currently integrated in my engine. However I'm starting to want to combine some effects (notably LUT based color grading) with it.

So I was wondering @h3r2tic if you had an estimate on when you plan to provide the source code implementation ? This would also make its adoption easier. ;)

h3r2tic commented 1 year ago

Ohai! I'm glad that you like Tony :D Regarding the source code... I don't have a timeline for that just yet, but I also don't suppose it would necessarily change much for you. The LUT version is what you'd likely want to use anyway -- unless of course you fancy integrating a dozen header files of utils, and the very slow shader code used for the LUT derivation :sweat_smile: But if that's the case anyway, I'd be curious to hear why!

FWIW Tony is based on https://github.com/h3r2tic/notorious6/blob/main/shaders/inc/display_transform.hlsl, with a bunch of fixes and tweaks, and just like the display transform in notorious6, the calculation involves all too many color space transforms, geometric line-gamut intersection, and a few smaller ad-hoc LUTs. There's also a bunch of nonsense in it, which I wouldn't want spreading too far and wide. Meanwhile a LUT can hide some of the dust bunnies :P

There's one element that's I'm particularly unsatisfied with, and that's a custom Helmholtz-Kohlrausch approximation, which is currently a crappy Catmull-Rom fit-on-top-of-a-fit -- Tony has a variant of this code. To clean it up, I need to first construct a bit of an app to let me eyeball equivalent luminance for a bunch of colors, then gather more samples, document the process, and make a better LUT... sort of in the spirit of "G0 Revisited as Equally Bright Reference Boundary".

Froyok commented 1 year ago

Thank you for the links, I had noticed some of that stuff already in some updates of Kajiya but I didn't had the courage to look into it yet.

As for why:

kriNon commented 9 months ago

I'm in a pretty weird/rare situation where I don't have c++ access to bind a texture to my shader, so I'm unable to use a 3D Lut. So I would be interested in trying my hand at doing a source-code level integration (if possible).

h3r2tic commented 9 months ago

Can you perhaps bind a 2D texture with the depth slices side-by side? You really wouldn't want to be using the generator code directly 😅

kriNon commented 9 months ago

I can't even bind a 2D textures. Currently I'm looking into trying to approximate the LUT using multivariate polynomials, which is looking like it might be promising.

Hopefully that approach works, but if not, I'm not really sure what other approach I can take. I was hoping that maybe I can do some amount of approximation to speed up the generator if it is that slow.

kriNon commented 8 months ago

To get it working with my setup, I ended up training a neural network to memorize a compressed representation of the LUT, and then converted the neural network to a shader. It's a suboptimal & complex approach, but I was able to get it working and see what it looks like in engine. I was really impressed by just how well it works!

I would really like to perform a better integration, because at the moment I am running into a lot of difficulties. I could do a much better job of optimizing my integration if I had access to the sourcecode of the generator. There are also some modifications that I would like to make in order to perform the integration as best as I can: My engine gives me the color in AP1 gamut, and I would ideally like to use that gamut directly when tonemapping (because I'm not just tonemapping to SRGB or Rec709, but I'd also like to tonemap to other colour spaces.

I'm worried that I might be distracting from the main topic of this issue. If that's the case, perhaps it would be more appropriate to shift this conversation to private messages. Could you please let me know the preferred method to contact you?

Thanks!

Filoppi commented 5 months ago

Is there still a plan to release the full source code? It would be also useful to expand the tonemapper to use different color space and ranges (e.g. HDR output support), and increase the quality of the LUT, given it's just 16px now.