2
\$\begingroup\$

Unity3D's reference describes the HDR Bloom as:

Using HDR allows for much more control in post processing. LDR bloom has an unfortunate side effect of blurring many areas of a scene even if their pixel intensity is less than 1.0. By using HDR it is possible to only bloom areas where the intensity is greater than one.

My question is how to achieve it in a surface shader? I have tried to output both the Albedo and Emission greater than 1, but still when I set the Threshold of Bloom equal to or greater than 1, no visible effect can be seen.

The relevant part of shader snippet is:

float rim = saturate(dot(normalize(IN.viewDir), o.Normal));
if (rim >= 0.98) {
    o.Emission = 1.5; // or any large value
}

Which basically outputs a bright white circle when view angle and normal are at almost same angle, and I want to enhance it with HDR. But outputting a value greater than 1 is not being registered and setting the threshold almost equal to 1 (0.98 or above) creates the Bloom on areas other than the bright white spot, which is not what is needed. I have tried to output extremely large values of Emission and have also tried output Albedo > 1.

Please tell what I am doing wrong or missing. I think I have not been able to figure out what is the meaning of pixel intensity > 1 and what settings does this translate to.

\$\endgroup\$
4
  • \$\begingroup\$ What version and licence of Unity3D are you using? \$\endgroup\$ Jul 26, 2013 at 8:13
  • \$\begingroup\$ Unity3D 4.1.2 paid version. \$\endgroup\$ Jul 26, 2013 at 17:21
  • \$\begingroup\$ Any thoughts anyone? \$\endgroup\$ Jul 27, 2013 at 9:54
  • 2
    \$\begingroup\$ Let me google that for you as I'm not sure how to do the shaders part \$\endgroup\$ Jul 29, 2013 at 8:10

1 Answer 1

0
\$\begingroup\$

Ok, after trial and error and reading the Unity3D documentation again, and some help from the link in the comment by Blue, I have been able to figure this out:

In the shader, if emission is greater than 1, then the camera must have HDR switched on (which I missed). Then one can write in shader like this:

float rim = saturate(dot(normalize(IN.viewDir), o.Normal));
if (rim >= 0.98) {
    o.Emission = 1.5; // or any large value
}

And set threshold greater than 1, and only the areas with pixel intensity > 1 are picked by Bloom. Also without using custom shaders, in my experiment, the default specular shader can also have pixel intensity > 1, and is also picked up by the HDR.

One last thing, while using HDR on the camera, if Anti Aliasing is switched on, it gives a little warning:

HDR and Multi-Sampling Anti Aliasing (in Forward Rendering path) is not supported. This camera will render without HDR buffers. Disable Anti Aliasing in Quality settings if you want to use HDR.

And HDR doesn't work. So I switched Anti Aliasing off.

This is what I missed earlier. Now the shader emits > 1 and is easily picked by Gloom. Here is the effect before enabling HDR on the camera: enter image description here Here is the effect after enabling HDR on the camera: enter image description here

In the Bloom (Script), Intensity is 8.96, and Threshold is 1.1 Also to create a slight yellow color in Bloom, Color Threshold is (165, 172, 255). The car's body and windscreens have a custom shader, and the rims have the Unity's default Specular shader. Bloom with HDR works on both.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .