Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How do you write to and read from HDR color values into a render texture?

Discussion in 'Shader Graph' started by bunp, Jun 16, 2023.

  1. bunp

    bunp

    Joined:
    Feb 21, 2019
    Posts:
    66
    Here's what I have and here's what's not working:
    • URP 2022.2.17f1
    • I have a cube with a high intensity HDR color value material on it.
    • I have a camera pointing at it that outputs to a render texture.
    • I have a plane that displays the render texture.
    • I have a global post processing volume with bloom.
    The cube 'glows' from the post process bloom, as intended. The camera sees this and writes it to the texture as the texture is a 32bit RGB color format.

    The problem is the texture itself somehow clamps those values to be 0-1. The intensity of the HDR color is stripped out, and the texture has no 'glow' from the bloom, and every value on it reduces at the exact same rate.

    How can write and read the HDR values?

    Pictured: All the mentioned assets.
    upload_2023-6-16_8-36-39.png
     
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,108
    Not solution, but some tips:
    1. Check if camera rendering to render texture has HDR enabled with all the other stuff you need.
    2. Check the format of that texture - 32bit RGB you mean floating point texture right? signed, unsigned? Double check as there are zillions of formats and it's easy to make mistake there.
    3. Check if this is actually fault of the texture, you could try to use texture API or example to write some bright pixels and see if that works. In case it works, it would mean you are rendering/bliting in wrong way, if not then it would mean the format is wrong. Also make sure you shader is not clamping your texture in any way.
     
  3. bunp

    bunp

    Joined:
    Feb 21, 2019
    Posts:
    66
    How can I tell if the camera is HDR or not? The project itself is HDR for sure since the bloom is working.
    upload_2023-6-16_11-9-9.png

    Here is the render texture's parameters. The color format supports ranges of HDR values as far as I understand.
    upload_2023-6-16_11-9-43.png

    Here is the entire shader atm for testing, do you see anywhere its being clamped or normalized?

    upload_2023-6-16_11-11-5.png
     
  4. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,108
    I think this is controlled by URP asset or renderer asset selected in camera. Also it's not true, bloom can actually work without HDR, but obviously it not gonna look good.
    Never tried to do what you are doing here, but I guess it should work assuming your URP asset is correct. On the other hand, do you have tone mapping? Maybe I am missing something too, but try to disable post processing effects for that camera.
     
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,221
    Here's your problem.
    upload_2023-6-16_14-35-25.png
     
  6. bunp

    bunp

    Joined:
    Feb 21, 2019
    Posts:
    66
    That was indeed the problem, thanks for nothing that!