Shaders, Part 6 – HDR Bloom

Last week I covered Blurring, and specifically, Gaussian Blur. I said in the end of that blog entry that Gaussian Blur is something that plays a part on doing the effect called HDR Bloom, and here I am, talking about this matter now.

Before we start, I’ll do something here:

Just getting ready...
Just getting ready…

While I’m applying the options, I’ll continue.

Real Life Bloom

The HDR here stands for High Dynamic Range, and is somewhat new to the scene. While this concept is new, the concept of bloom isn’t. Bloom is a very old concept built on the basis that no lens would be perfect enough to be focusing completely under a strong light source. (I must add, our eyes are not that perfect either, please refrain from staring into the sun even though you’ll get an example of bloom right there.) Thus, the lights, when passing through a grid or an encased area, will looks as if the light has been “pouring out” from the area.

HDR, on the other hand,  is the rendering of scenes by using graphic calculations in a way larger graphics range. In layman’s terms as coined by Nvidia:

  • Bright things are seen really Bright.
  • Dark things are seen really Dark.
  • However, Details is preserved in both.

Now, let’s look at the above example with all quality to maximum and with Blurring and Bloom to the highest quality.

The light, the dark, and the details.
The light, the dark, and the details.

In this screenshot, the sun is shining brightly and it directly creates several lighting effects include the bloom effect on the sun itself, the darkening of the backside of the signs and the brightening of the blurred background and the front-side of the signs. However despite all these lighting, one can still easily make out the contents on the sign because all of those are rendered at a longer distance as usual. HDR Bloom is usually used for rendering environmental lights for this exact reason.

To archive this effect, the effort here is simple. We took the normal scene, render it normally, then marks the highlight on the scenes, rendering the highlights and store them in an FBO. Finally, we blur the contents of the FBO and directly master the effect onto the normal scene.

Like this.

We do this via 1 Vertex shader and 2 Fragment shaders:

  • The vertex shader does the usual transformations.
  • The first fragment shader should blur the bright texture (highlights) and store it in the next map level.
  • The second fragment shader then color the result based on the map and draw color onto the original scene.

The end result would be something that’s very bright and realistic while not breaking the scenery or the rendered scene. This would be incorporated into our game project as well.

That’s all for today then, until next time.

 

Post a Comment