Tuesday, January 11, 2011

Bloom Pixel Shader for bsnes

I did some digging around online and came across some bloom filters written in GLSL. The one on this site looked the best to my eyes, so I converted it to work with bsnes and tweaked the settings a bit to achieve the desired effects.

What I found while playing around with it is:
1. Turning on 'Smooth video' seems to amplify the bloom effect.
2. The same amount of bloom looks different on each game, depending on the overall dark/light-ness of the game.
3. Combining excessive bloom with bsnes' scanline filters can make a pretty decent approximation of a CRT. While this is in no way as accurate or as nice looking as cgwg's CRT shaders, it may be an option for the many people whose video cards don't have enough horsepower to handle that complex shader.

First, I made a simple, fairly subtle (as far as bloom is concerned...) shader, which looks like this:
Looks pretty nice, eh? Unfortunately, the exact same shader settings look awful in Super Mario World:
One big flare-out... All I need is some brown and lens flare and I'll have next-gen graphics.

However, if you add in a scanline filter, things can really get evened out. In fact, you can use the different scanline intensity filters on a game-to-game basis to attenuate the inconsistency of the bloom effect. For example, here's a shot of Super Mario World with even more bloom added and 'smooth video' checked, but with 100% scanlines to chill things out a bit:
As you can see, it kinda gives it a plasticy, oversaturated look, but it's sort of charming, if you ask me.

In contrast, those exact same settings in Chrono Trigger--an altogether darker game--produce a really nice CRT-style effect, like this:
As you can see, even the bright parts don't suffer from excessive flare-out and the color bleed into the scanlines from the bloom provides an effect that is reminiscent of the phosphor glow on a CRT display.

One more shot of Chrono Trigger, this time using heavy bloom, 25% scanlines and smooth video:
I have asked WhateverMan if he would release his shader code under a permissive license. If he does, I will post my simplebloom and heavybloom versions here for download.
Update (1/19/11): WhateverMan was nice enough to allow his work to be distributed/modified under the GPL, so you can download the heavybloom shader here and the simplebloom shader here.

Update (2/2/11):
I also made a simple scanline shader that works with or without video smoothing:
For best results, use it along with a scale factor of 4x. Otherwise, the pixels won't line up with the scanlines correctly.

UPDATE (2/28/11): I made a scanline shader that works with a 3x scale factor, as well. You can download it (and the other GLSL shaders) here.


Anonymous said...


very nice work. However, I think there is something wrong with the scanlines. Check how scanlines look, say, in Kega Fusion or even Snes9x, where they are perfectly even, and compare this to the scanlines in the screenshots you have posted. There are distortions that follow a regular pattern, which suggests that the image is squeezed. (I use Simple Smoothing & Blargg's NTSC filter on bsnes, so I never noticed, but when I checked it earlier, it looked the same on my computer. I'm using Richard Bannister's port on OS X.)

-adrenaline (from byuu.org forums)

Hunter K. said...

Hey man! I know the bloom shader I'm using does a sort of squeeze/offset to produce the blur, but you said you saw it on your machine without the bloom, too? Would you be interested in posting a couple of comparison shots depicting the distortion? If it is indeed something that needs fixing, perhaps I could just bring over one of the other emus' scanline filters into bsnes to correct it.

Anonymous said...

I've uploaded a ZIP with screenshots from Kega Fusion, BSnes and Snes9x (.068, Richard Bannister version):

BSnes shows the same distortion as the screenshots in your post. Going back to the post you had on CRT shaders, it seems that there are the same irregularities as some scanlines seem to be thicker than others. (I'm referring to the three detailed screen shots of Mario at the end).

I think the issue is that Bsnes applies the effect before scaling the image, while Kega Fusion and Snes9x do it afterwards. I could only include a windowed screenshot of Snes9x because there doesn't seem to be a way to make a screenshot in fullscreen mode that shows the effect too. However, I stretched the window randomly and no matter how you stretch it, the scanlines always look correct, which implies that Snes9x applies the scanlines after rendering the image.

Hunter K. said...

Ah, yes, I see what you mean and I believe you're correct about it applying the scanlines before scaling. I'm not sure what could be done about that, though...

Obviously, applying the mask after scaling would fix it, but I don't know what that would do to processing requirements for the filter(s).

Anonymous said...

I vaguely remember a debate on the very same scanlines issue many many years ago with ZSnes, and after it was fixed, it did not lead to an outcry on the forums, meaning that it could not have affected performance much. This was only a question of "regular" scanlines without any of the amazing effects your and other people's shaders produce. But in any case, the only way to find out is to try and compare the results. Maybe byuu or someone on his forum knows more about this issue?

Analytics Tracking Footer