Fast Bloom?

BlitzMax Forums/BlitzMax Programming/Fast Bloom?

Ked(Posted 2008) [#1]
Does anyone have a fast bloom example for Max2D?

Thanks!


MGE(Posted 2008) [#2]
Could you define what bloom is? Thanks.


Ked(Posted 2008) [#3]
Seriously?


Perturbatio(Posted 2008) [#4]
Bloom = Blurred glow effect



Prince of Persia used it (the newer 3D one, not the old 2D) extensively


MGE(Posted 2008) [#5]
"Seriously? " yah... I'm totally daff on this subject when it comes to 2d graphics.

"Bloom = Blurred glow effect"

hmm... have no idea how this would be done using normal 2dmax commands. Isn't this something that is done on a complete "scene" rather than individual objects?


ImaginaryHuman(Posted 2008) [#6]
It's usually done on the fly by rendering a small version of the screen, grabbing it into a texture, and then drawing it on top of the large-size scene. Stretching the smalll version to fit the screen causes it to do filtering which generates a cheap blur effect. At least that's what I think it does.

Maybe you can have two version of your game images - the normal large-size and the same images in a small size. Render the large-size normal images and then render the small images with SetScale set higher than 1, like 4 or so, to cover the screen and interpolate - but also using lightblend?


AlexO(Posted 2008) [#7]
typically used as a post-process effect, which is usually implemented with shaders. Doing what ImaginaryHuman suggests won't get you the results you're probably looking for. The general process is this:
1. Extract all the 'light' areas of the final scene render. This is typically done by setting some sort of threshold and anything 'darker' than that will be rendered black in this temporary texture.
2. Blur this texture
3. 'add' this texture back on top of the original scene. This can be done in various ways, I think the approach 'lightblend' uses may be suitable here.

As for the OP's question, sorry don't have anything for ya on hand. If you're sticking with 2D you might be able to get away with making two versions of sprites (a normal one and a threshold-light-area-blurred one) and just render those two together. That way you could stick to normal max2D commands and at least keep it relatively quick.


tonyg(Posted 2008) [#8]
This *might* help (although, on retrospect, it might be considered glow rather than bloom.
P.S. If *only* we had a robust render-to-texture.
P.P.S and this shows the '2 sprites' method.


ImaginaryHuman(Posted 2008) [#9]
So if you only want to bloom light areas then only draw the light-area objects.


Ked(Posted 2008) [#10]
@tonyg: You're first link is the one that doesn't work. I've posted on that entry.

I'll do some experiments or something.


tonyg(Posted 2008) [#11]
It uses the same principle as listed above and 8does* work..just not for you.


Ked(Posted 2008) [#12]
It uses the same principle as listed above and 8does* work..just not for you.

Is that helpful then?

Anyway, I'm going with the separate-blurred-image-for-every-image method. Looks nice. Thanks, everyone.


tonyg(Posted 2008) [#13]
Is that helpful then?

Might have been. It has been 9 months since you said it didn't work so things might have changed.
Also, the principle is still something you could try working with.
I get the feeling your upset with me writing code that doesn't work for you... sorry about that. Maybe, if you were interested in using it, you could see who else it fails for or add some debug statements to see where the problem might be.
Having said it might not be what you're looking for anyway.