URP HDR alpha blending problem

Hello, in my project I’m using URP with HDR enabled. The Problem is that when HDR is enabled and many textures overlap they become yellowish, when HDR is disabled it renders as it should. You can see an example in the picture above, particles systems spawns a lot of smoke textures with alpha blending shader and pixels with the smallest alpha becomes yellowish.

Can’t find any solution to that.

I think URP HDR mode uses R11G11B10 framebuffer format by default. In that format the blue channel uses 10-bit floating point values while the red and green channels use 11-bit values. This means the blue channel will accumulate rounding errors faster than the green and red channel. In your case, it seems the blue channel is accumulating to a lower value than the green and red channel, causing the result to become yellow-ish.

Ultimately, there isn’t much you can do. You should at least try to reduce the amount of overlapping alpha transparencies, since that can become very expensive on mid and low end hardware.

2 Likes

Hey,

Thanks for the reply, you are absolutely right about that. Actually, even opaque materials which uses blue channel becomes a bit yellowish.
It’s a sad thing that you cannot do anything about it. I saw that HDRP has ability to change buffer to R16G16B16A16, maybe this feature will come to URP later also?

We had the same problem in our game and I ended up solving it like this:

  • register your own callback for RenderPipelineManager.beginFrameRendering
  • In the callback, put your own render texture into camera that is about to render
  • add a fullscreen quad with that texture (you can use RawImage UI component placed on canvas)
  • add one more camera that renders this UI only to primary display

This worked ok for forward rendering, but our current game is using deferred shading so I have to do research again.

When researching this topic a while back, I found that older versions of Unity allowed choosing texture format, but the option is no longer available in URP.

Good news guys - there’s still a way to force proper HDR render targets in URP.

You can’t do it in Unity Editor, but you can open your URP rendering pipeline asset in notepad.
These asset files are typically in your /Assets/Settings folder and you will have multiple assets for different quality levels.

If you can’t find it - simply search your Assets folder for any file named *.asset containing string “m_HDRColorBufferPrecision”.

By default this value is set to 0, meaning 32-bit HDR. Change this setting to 1 in your file - it will change HDR render targets to 64-bit precision and therefore give you equal bits per color component. This will make all your smoke and particles look good again.

Cheers!

3 Likes

@KSzczech In Unity 2022.3, URP 14, they added the option to change this in the editor. It’s in the URP Asset settings under Quality → HDR → HDR Precision. I just tested it and it does change the value of m_HDRColorBufferPrecision.

If you want to change it through scripting, you can use something like this:

universalRenderPipelineAsset.hdrColorBufferPrecision = HDRColorBufferPrecision._64Bits;```
It's great to see an example of where 64-bit precision helps.
2 Likes

I’m on 2022.3.11f1 with URP version 14.0.9 and I don’t have it in asset settings. So I guss I’m close and when we update again we will have it in GUI.

For those using older versions, our info about changing it in files or via scripting will still be useful.

Thanks for the additional info.

Thank you so much! I’ve spent a whole hour investigating this issue.
The funny thing is that in scene view it renders properly, the problem is only with GameView. Designer almost went insane trying to find the mysterious post-processing volume responsible for that yellow-ish color.

1 Like

Thanks for the tip! Have you encountered any performance hit due to this change?