Announcement

Collapse
No announcement yet.

Another way to disable tonemapping

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • started a topic Another way to disable tonemapping

    Another way to disable tonemapping

    I've seen lots of posts asking how to disable tonemapping with a few people finding commands they can enter via blueprints to disable it.

    I wanted to share another quick way I've found that appears to disable tonemapping: replace the tonemapper post process pass with a simple shader:

    Click image for larger version  Name:	DisableTonemapping.png Views:	2 Size:	450.8 KB ID:	1600751

    This shader takes in the post process input and pipes it straight to the output. It's set to replace the tonemapper, and I gave it a priority of -1 so any other shaders we want to add at runtime that also replace the tonemapper can override it.

    Because we're doing singleplayer stuff, we have a function in our GameMode class, called by its PostBeginPlay(), that obtains or creates an unbound PostProcessVolume and adds this material to it:

    Code:
            APostProcessVolume* VolumeActor = nullptr;
            for (TActorIterator<APostProcessVolume> PostProcessActor(GetWorld()); PostProcessActor; ++PostProcessActor)
            {
                VolumeActor = *PostProcessActor;
                break;
            }
    
            // spawn a post process material if one was not found in the scene.
            if (!VolumeActor)
            {
                VolumeActor = GetWorld()->SpawnActor<APostProcessVolume>();
                VolumeActor->bUnbound = true;
            }
    
            UMaterial* DisableTonemapperMat = LoadObject<UMaterial>(nullptr, TEXT("/Game/Seg/MaterialLibrary/PostProcess/PP_DisableTonemapping"));
            if (DisableTonemapperMat)
            {
                VolumeActor->AddOrUpdateBlendable(DisableTonemapperMat, 1.0f);
            }
    If you're doing a multiplayer game, you'd probably need to do this in your PlayerController or something like that. Alternatively, I'm sure there are good ways to do this in Blueprint as well.

    Looking at "ProfileGPU", this appears to do the trick. No tonemapping pass is done!

    Thought I'd share.

  • replied
    Well the documentation itself states to use it in a PP material set to replace the tonemapper, exactly to do that - your own tonemapper

    Leave a comment:


  • replied
    Originally posted by Chosker View Post
    Very informational thread, subscribing

    Btw In theory the EyeAdaptation node in the postprocess material should help with controlling the auto exposure, but for me it doesnt do anything. Any thoughts?
    I've used it in the past in non-Post Process materials to have an emissive material that adjusts with the auto-exposure. Super useful for gameplay FX that should be visible at all times. But yeah, it's not working for me in a Post-Process Material and I haven't looked into it too much.

    Exposure is usually done before tonemapping, so it's possible when replacing the tonemapper that it's not available? I haven't tried it in a "Before Tonemapping" material yet, but that could be a start to know for sure. Or maybe it's just not available in the Post-Process shader.

    Leave a comment:


  • replied
    Very informational thread, subscribing

    Btw In theory the EyeAdaptation node in the postprocess material should help with controlling the auto exposure, but for me it doesnt do anything. Any thoughts?

    Leave a comment:


  • replied
    Originally posted by rosegoldslugs View Post
    I only mentioned the before/after because Luma/Luminance are separate and based on gamma correction. There are 2 issues here affecting your color, one being the tone curve of the ACES RRT having a very soft rolloff into highlights, so any value >= 1 will be desaturated(to the point where true 1.0/white is hard to reach without over-exposure), and the other being the multiple color spaces ACES steps through to work in the proprietary color space AP1 before you get back to your final display-referred image.

    If you like the contrast, and the curve parameters available in the Post-Process, you could remove the color space transforms in TonemapCommon.ush in the FilmToneMap() function to only work in the RGB color space, so the primaries won't shift but you'll still get the highlight desaturation. A little easier said than done though, or you could replace it all with an approximation of ACES from Krzysztof Narkowicz or Stephen Hill.

    If you don't like ACES at all, you could add in your own tonemapping operator in that same function. This was just a quick test but it looks like everything in the PostProcess stack still works as expected. You may want to comment out the rest of the ACES above it, but you might get issues if you're outputting to other display spaces. Definitely comment out the "return max(0, ToneColor)" since that's returning ACES.

    Click image for larger version Name:	Capture.JPG Views:	1 Size:	32.2 KB ID:	1664378

    You may also want to disable the Blue Correction(fixes ACES color space issue with saturated blues) and Expand Gamut in the Misc section of Color Grading in the Post-Process Volume.

    Edit: Ironic that I used the wrong term in my code, since I'm getting Luminance of the linear color, not Luma.
    Wow! Thanks!
    This was just the kind of information I was looking for. I have a tonemap that I know works and that I like so I´ll try to replace it in the TonemapCommon.ush next week.
    Have a nice weekend!

    Leave a comment:


  • replied
    I only mentioned the before/after because Luma/Luminance are separate and based on gamma correction. There are 2 issues here affecting your color, one being the tone curve of the ACES RRT having a very soft rolloff into highlights, so any value >= 1 will be desaturated(to the point where true 1.0/white is hard to reach without over-exposure), and the other being the multiple color spaces ACES steps through to work in the proprietary color space AP1 before you get back to your final display-referred image.

    If you like the contrast, and the curve parameters available in the Post-Process, you could remove the color space transforms in TonemapCommon.ush in the FilmToneMap() function to only work in the RGB color space, so the primaries won't shift but you'll still get the highlight desaturation. A little easier said than done though, or you could replace it all with an approximation of ACES from Krzysztof Narkowicz or Stephen Hill.

    If you don't like ACES at all, you could add in your own tonemapping operator in that same function. This was just a quick test but it looks like everything in the PostProcess stack still works as expected. You may want to comment out the rest of the ACES above it, but you might get issues if you're outputting to other display spaces. Definitely comment out the "return max(0, ToneColor)" since that's returning ACES.

    Click image for larger version  Name:	Capture.JPG Views:	1 Size:	32.2 KB ID:	1664378

    You may also want to disable the Blue Correction(fixes ACES color space issue with saturated blues) and Expand Gamut in the Misc section of Color Grading in the Post-Process Volume.

    Edit: Ironic that I used the wrong term in my code, since I'm getting Luminance of the linear color, not Luma.
    Last edited by rosegoldslugs; 09-13-2019, 11:29 AM.

    Leave a comment:


  • replied
    Originally posted by rosegoldslugs View Post

    Hmm, if you need Luma only, you should be able to just do a dot product of your tonemapped image with 0.2126, 0.751, 0.0722 in a Post-Process Material set to "After Tonemapping." If you need Luminance, do it "Before Tonemapping," unless I'm also not understanding what you want to do correctly
    Thank you, that is actually already a part of the custom tonemap. It wont matter if I would set it to run before or after the tonemap though as it is the tonemap in itself that is ruining my chroma. (Hence my desire to replace it altogether)
    Last edited by 2car; 09-13-2019, 09:03 AM.

    Leave a comment:


  • replied
    I would like to know why its called "Replace Tonemap" when in fact it is replacing the entire post process feature set.

    Leave a comment:


  • replied
    Originally posted by Rawalanche View Post

    Yes, well, my question was why. What do you want to achieve? From the two comparison pictures above, it appears to me that you are looking for an overcomplicated way to achieve same thing as slightly reducing exposure and tone mapper slope. The process will be very different, but the result will be most likely near identical.
    Thank you for trying to help me.
    I am after a tonemap that retains the original colors as they are in the diffuse texture. (top image)

    I tried your suggestion reducing the exposure (-0.25) and the tone mapper slope (-0.13) but since blacks were still very crushed a also had to lower the toe a bit (-0.15).
    This gave the following result in the (middle image).

    I still believe that the result from our custom neutral tonemap cannot be replicated with the standard tonemap. (bottom image)

    Will definitely not give this up just yet.
    Attached Files

    Leave a comment:


  • replied
    Originally posted by 2car View Post
    What I want to achieve:
    To preserve color accuracy. I don't want colors to change when switching between lit and basecolor buffer.
    So you want linear output after all

    In that case we go back to my question why. I personally was thrown off by this as well, when I realized there's no way in unreal to turn off tone mapping to a degree of seeing the clean linear output, but with time, I realized there are actually almost no valid reasons to desire that. Linear output was never really meant for human eye consumption.

    There are indeed some of the issues, such as input texture already having some sort of perceptual color transform applied to the once inside the input image, and it being applied twice in the final engine, but in the grand scheme of things, it's rather minor issue compared to the resulting gains in quality.

    I was asking about what your end goal this. Let's say you want to preserve the color accuracy, but why? This is just a workflow preference, not an end product. I suppose you are figuring out this piece of puzzle in order to achieve your final goal, which likely is producing a high visual quality game, cinematic or visualization. And this end goal can generally be achieved even without this piece of puzzle. Just different route to achieve same final level of quality.

    That being said, the reasonable built in solution for this should be some bundled material editor node which would apply inverse of the tone mapping operations.

    I know I get ******, when I ask about something I want to achieve, and someone instead of providing an answer starts convincing me I don't really want to do that, but in this case, I am afraid you will go a full circle before realizing you've been trying to do all this for nothing
    Last edited by Rawalanche; 09-13-2019, 05:06 AM.

    Leave a comment:


  • replied
    What I want to achieve:
    To preserve color accuracy. I don't want colors to change when switching between lit and basecolor buffer.

    Leave a comment:


  • replied
    Originally posted by 2car View Post

    Sorry if I was unclear, I am not looking for linear output. I am looking to do some operations in Luma only and the controls for the filmic tonemapper do not allow for that. At least its not exposed in the editor.
    Yes, well, my question was why. What do you want to achieve? From the two comparison pictures above, it appears to me that you are looking for an overcomplicated way to achieve same thing as slightly reducing exposure and tone mapper slope. The process will be very different, but the result will be most likely near identical.

    Leave a comment:


  • replied
    Originally posted by 2car View Post

    Sorry if I was unclear, I am not looking for linear output. I am looking to do some operations in Luma only and the controls for the filmic tonemapper do not allow for that. At least its not exposed in the editor.
    Hmm, if you need Luma only, you should be able to just do a dot product of your tonemapped image with 0.2126, 0.751, 0.0722 in a Post-Process Material set to "After Tonemapping." If you need Luminance, do it "Before Tonemapping," unless I'm also not understanding what you want to do correctly

    Leave a comment:


  • replied
    Originally posted by Rawalanche View Post
    Why would you do that though? Linear output was never meant for human eye in the first place. And if the purpose is to replace unreal's tone mapper with more neutral one, then why wouldn't you just adjust the filmic settings to match yours closer? Unreal's default tone mapper is not hardcoded at defaults, so if you don't like the results it produces, just don't stick to defaults, instead of going this full workaround circle with so many limitations.
    Sorry if I was unclear, I am not looking for linear output. I am looking to do some operations in Luma only and the controls for the filmic tonemapper do not allow for that. At least its not exposed in the editor.

    Leave a comment:


  • replied
    Why would you do that though? Linear output was never meant for human eye in the first place. And if the purpose is to replace unreal's tone mapper with more neutral one, then why wouldn't you just adjust the filmic settings to match yours closer? Unreal's default tone mapper is not hardcoded at defaults, so if you don't like the results it produces, just don't stick to defaults, instead of going this full workaround circle with so many limitations.

    Leave a comment:

Working...
X