Search Unity

How to do custom tone mapping instead of neutral/aces in URP?

Discussion in 'Universal Render Pipeline' started by colin299, Mar 18, 2020.

  1. colin299

    colin299

    Joined:
    Sep 2, 2013
    Posts:
    181
    IgorAherne and DevFrog like this.
  2. BattleAngelAlita

    BattleAngelAlita

    Joined:
    Nov 20, 2016
    Posts:
    400
    Copy URP to asset folder, and modify "ApplyTonemap" function in "Common.hlsl" file.
     
    colin299 likes this.
  3. YoshYoshKo

    YoshYoshKo

    Joined:
    Apr 13, 2020
    Posts:
    15
    Could you please explain the steps in more detail? Sorry I'm new to this. Thank you!
     
  4. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    I think he means to modify in the shader in the URP package.
     
  5. SuperLemonBits

    SuperLemonBits

    Joined:
    Feb 28, 2016
    Posts:
    7
    Just a bit longer explanation. Yes, you can do it BUT not in a simple way.

    Thanks to the new Unity packages approach now you have access to the source code of some relevant parts of the engine like new input or rendering systems.

    In order to modify the tone mapping you have to copy the URP package to your packages folder. Then search where the tone mapping is done and replace the code for your custom formula. I had to do something similar to have a better quality Bloom effect.

    The main drawback of this approach is that you will have to merge your custom code every time the package is updated, meaning every time you change the Unity version, which could be annoying.
     
    IgorAherne and Bordeaux_Fox like this.
  6. YoshYoshKo

    YoshYoshKo

    Joined:
    Apr 13, 2020
    Posts:
    15
    Thanks Lemon!
    I think I found the file which is ACES.hlsl .
    Unfortunately I don't even know where to start if I wanted to use OP's formula ( https://www.desmos.com/calculator/gslcdxvipg ).
    Does anyone have advice how to replace the ACES formula, it's all gibberish to me. Unless it's possible for me to create the tonemapping in HDRP first then copy that information over.
     
  7. IgorAherne

    IgorAherne

    Joined:
    May 15, 2013
    Posts:
    393
    Unfortunately, anything that I add into source code of packages becomes undone when I refresh Assets inside unity or recompile stuff.

    Not a perfect solution, but if float precision won't affect you, you can:

    1) use Neutral Tonemapper from the post processing stack.
    2) and add to it the Color Curves. Tweak the Master curve until it more-or-less matches the wanted formula.

    Neutral Tonemapper squashes all of the HDR stuff into zero-to-one range (usual RGB) using an asymptotic function. It's not linear nor straight, but kinda looks like log. And then the Color Curves will allow us to accentuate things further, inside this zero-to-one range.
     
    Last edited: Jul 8, 2023