Search Unity

Bloom is creating saturated squares

Discussion in 'Image Effects' started by Ewanuk, Dec 6, 2017.

  1. Ewanuk

    Ewanuk

    Joined:
    Jul 9, 2011
    Posts:
    257
    I'm trying to apply bloom to an HDR rendered scene that has extreme light highlights (intensities over 10 in some cases). This is necessary given the nature of the application.

    I'm finding that areas of extreme highlight are blowing out to saturated squares:

    Bloom Artifacts.PNG


    Is there a way to fix this? Is this a limitation of traditional bloom techniques hitting an extreme case that is my scene?

    If we step farther back, we can see this artifacting beginning in the blur iterations:
    Blur Iteration.PNG

    Is this a byproduct of putting my bloom passes before my tonemapping pass?


    Edit: After some more digging, I'm finding that the output of the bloom shader is producing fragments that are infinitely bright.

    I have an image effect right after bloom that writes a white pixel if the input value is over a certain value:

    Code (CSharp):
    1.         maxChannelValue *= 0.000001;
    2.         if (maxChannelValue > _BlowoutThresholdMin)
    3.         {
    4.             return float4(1, 1, 1, 1);
    5.         }
    6.         else
    7.         {
    8.             return float4(0, 0, 0, 0);
    9.         }
    Even if I set _BlowoutThresholdMin to some crazy high value like 99999999999999, the fragment output is still white.

    If a fragment goes beyond the limits of a half4 (which could be happening in the bloom shader), does it get treated like an infinite value or something?
     
    Last edited: Dec 6, 2017
  2. Ewanuk

    Ewanuk

    Joined:
    Jul 9, 2011
    Posts:
    257
    Solved it,

    The material I'm rendering there wasn't normalizing a normal I interpolated in a shader. This caused the specular to get powered to an insanely high number when added with 10 or more lights, which caused the rendered fragment to be infinitely bright. Since it's one isolated fragment in most cases, you'd never notice without the bloom issue.

    When doing the blur sampling for the bloom, it was multiplying an infinite value by the sample weight, which is infinite. So the blur sample area got rendered out as infinitely bright.

    Ensuring that my material shader was correctly normalizing any generated normals fixed it.
     
    astracat111 and BrandyStarbrite like this.
  3. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,076
    Wow! This was some interestingly informative info.
    I'm bookmarking this topic, in case I one day, run into this same problem.
     
  4. astracat111

    astracat111

    Joined:
    Sep 21, 2016
    Posts:
    725
    This has been happening to me on my 1050 Ti and yet it's not happening on my intel integrated graphics. Very odd, I'm not exactly sure how to implement the fixes you've stated.