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

I want my HDR color run though a function like this to transform HDR->LDR, instead of using neutral / aces

is it even possible in URP?

2 Likes

Copy URP to asset folder, and modify “ApplyTonemap” function in “Common.hlsl” file.

1 Like

Could you please explain the steps in more detail? Sorry I’m new to this. Thank you!

I think he means to modify in the shader in the URP package.

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.

2 Likes

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.

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.