Skip to content
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

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

Open
Froyok opened this issue May 21, 2023 · 7 comments
Open

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

Froyok opened this issue May 21, 2023 · 7 comments

Comments

@Froyok
Copy link

Froyok commented May 21, 2023

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
Copy link
Owner

h3r2tic commented May 21, 2023

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 😅 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
Copy link
Author

Froyok commented May 22, 2023

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:

  • Well, it's always nice to have access to the source, either as a way to be able to regenerate it or to learn stuff. 😄
  • I was assuming the code wouldn't be to complex in order to combine for grading and Tony inside a single LUT in order to cache the color transformation. But given what you described, I guess I will find another method (maybe just chaining LUTs).
  • I would have liked to fiddle a bit with the code to adjust its behavior (with my limited knowledge, but I like tinkering). Main reason right now is that I found the path to white a bit odd compared to an implementation of mine, I mostly wanted to adjust the shoulder of the tone curve. Here is a comparison between my own cooked stuff and Tony, notice the "halo" around the sphere. Adding AGX as well for comparison.
    • Custom:
      close_up_hybrid
    • Tony:
      close_up_tony
    • AGX:
      close_up_agx
      While my own recipe and AGX show the issue with the blue turning purple, Tony shows that noticeable halo which I dislike. I would have expected a longer tail/transition (a bit like AGX).

@kriNon
Copy link

kriNon commented Dec 15, 2023

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
Copy link
Owner

h3r2tic commented Dec 16, 2023

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
Copy link

kriNon commented Dec 17, 2023

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
Copy link

kriNon commented Dec 27, 2023

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
Copy link

Filoppi commented Apr 14, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants