"Blooming hells, has it really been 4 weeks since you heard from your friendly ghost falling sand dev?"
Well, err, yes, it has - sorry about that.
But I was actually talking about the other kind of blooming, that thing that makes lighting look cool.
Bloom
"Bloom" is a real-world visual effect that makes light appear to "spread out" past where the light is actually emitted from. 1
Now, normally, when you use a premade game engine, turning bloom on is about as difficult as ticking a checkbox.
But, since this game uses a custom engine, I gotta do things the hard way. 2
Understanding Bloom
The core intuition behind bloom is that you can approximate it by blurring only the light-emitting pixels in an image:
Blooming
Actually applying this technique to a game poses two problems:
- How can you separate out light-emitting pixels?
- How can you do a blur quickly, so that it doesn't kill performance?
The answer to problem one is boring: I already had the results of my lighting calculations in a separate image, so I used that as the starting point of the bloom calculation:
Doing a blur quickly is more complicated: to blur, you take the average value of each of the pixels in a certain radius around a pixel, for all pixels in the image.
That's a lot of work for your graphics card, but fortunately some smart cookies worked out you can approximate a larger blur by repeating many smaller blurs then merging them together: 3
Once you've got that sorted, you're basically done! 4
Blooming Hells
Finally, we can make a little hell scene, and apply our bloom effect to it.
Playable web build
You can fiddle with the bloom slider yourself down below, assuming that your graphics card is capable of handling the lighting!
Aside: you might notice a few other new things too, but we haven't got words to discuss those right now. The Word Police are very strict, you know.
I mean, there's probably more to it if you're a legit physics guy or gal, but here we just do hacky approximations of real physics.
And by "the hard way", I mean following a great bloom tutorial that Discord-legend Xzil recommended, as well as cribbing off some shader code he shared - thanks!
Again, check out this great bloom tutorial for the gory details.
Unless your rendering library (like mine) doesn't support High Definition Rendering. In that case, congratulations, you get to patch your library and rework half your rendering pipeline to operate in HDR - otherwise your bloom effect will hardly be noticeable.
On the bright side, that also forced me to pick from one of many tone mapping approaches, and as a happy side effect now the game's colours are much more vivid.

