Dark Bit Factory & Gravity

PROGRAMMING => General coding questions => Topic started by: mind on September 24, 2008

Title: bloom/glow
Post by: mind on September 24, 2008
so, i developed this bloom/glow/hdr-filter-kinda-thingy that i think was pretty damn awesome.. now what im wondering is if anyone can tell me how people normally code bloom/glow filters.. point is that im trying to figure out if im the first one to do it the way i do it :D and for that reason i wont tell you how i do it, yet :) i will however post a screenshot ^^

here it is:
(http://www.bahnhof.se/wb181759/glow.jpg)

there, now lemme know how normal people code theirs ^^
Title: Re: bloom/glow
Post by: hellfire on September 24, 2008
You made it *exactly* as everybody else ;D
Except of the saturation-thing which I find very useful, but most people will probably desaturate light-colours instead.
Title: Re: bloom/glow
Post by: mind on September 24, 2008
You made it *exactly* as everybody else ;D
Except of the saturation-thing which I find very useful, but most people will probably desaturate light-colours instead.


well, it may look like i did it exactly like everybody else does it.. im not quite sure though, which is why i wanted to know how others do :)
Title: Re: bloom/glow
Post by: hellfire on September 24, 2008
here (http://www.gamasutra.com/features/20040526/james_01.shtml) is an article.
Title: Re: bloom/glow
Post by: mind on September 24, 2008
yeah i read that one long ago.. and no, thats not how i do it, far from it :)

or well, the blur and add is the same i suppose, but the way i generate my glow maps is not :P
Title: Re: bloom/glow
Post by: hellfire on September 24, 2008
According to your screenshot, you take the source colour (or probably intensity), subtract "threshold" (thus clamping everything below to black), scale the result by "luminance" (to compensate darkening from "threshold" and weighting the end-result), gaussian and add the result to the source-image ?
Title: Re: bloom/glow
Post by: mind on September 24, 2008
According to your screenshot, you take the source colour (or probably intensity), subtract "threshold" (thus clamping everything below to black), scale the result by "luminance" (to compensate darkening from "threshold" and weighting the end-result), gaussian and add the result to the source-image ?


nope, thats not how i do it.. the threshold is used for the binary glow mode only(where you see "warm" i also have a cold and a binary mode. luminance and saturation are something i added just for fun, so i could give the images a feinter glow instead of the default max glow :D luminance and saturation are 2 different buffers with different lighting data.. but good guesses nontheless, keep em coming :P

now iz bed tiemz!
Title: Re: bloom/glow
Post by: relsoft on October 01, 2008
here's mine:

OpenGL:
http://rel.betterwebber.com/junk.php?id=83

Software:
http://games.freebasic.net/forum/index.php?topic=80.0
Title: Re: bloom/glow
Post by: mind on October 01, 2008
here's mine:

OpenGL:
http://rel.betterwebber.com/junk.php?id=83

Software:
http://games.freebasic.net/forum/index.php?topic=80.0


the software one is just a "do stuff on source buffer->copy to other buffer->blur other buffer->add other buffer to source buffer", right? the ogl one is beyond me, i have no idea how opengl works :P
Title: Re: bloom/glow
Post by: relsoft on October 01, 2008
Actually they're the same methods.
I still do the blooming part using software.
Just an RGB blur that sucks.
Yours look way nicer. LOL
Title: Re: bloom/glow
Post by: mind on October 01, 2008
Actually they're the same methods.
I still do the blooming part using software.
Just an RGB blur that sucks.
Yours look way nicer. LOL


thanks :) best part is that it doesnt add any glow to parts that arent supposed to glow, and i dont have to use any exponential curves to darken/brighten any of the image before blurring/combining :D
Title: Re: bloom/glow
Post by: madsravn on November 17, 2008
Looks awesome.. And I especially like the girl ;) I have been wondering whether I shouldn't make something similar... :)
Title: Re: bloom/glow
Post by: relsoft on December 19, 2008
Mind: How do you do your "luminance" pass?  The filter before the blur.


As for the glow, I would assume you are doing a gaussian or box filter on about 3 or 4 rescaled textures at these factors (1/2,14,1/8,1/16...) and paste them above the original pic.
Title: Re: bloom/glow
Post by: mind on December 23, 2008
well, i guess it's time to reveal the awesomeness that is my bloom filter :D

the idea came to me when i was sitting on the tram on my way home from a party, experienceing a pretty sweet LSD afterglow :P Basically i figured that we waste(read; throw away) so much relevant data when we code stuff. And mainly, for this i was refering to light.. for example, when we add colors together we usually saturate them at 255 to avoid an overflow, and damn thats a waste.. so anyways, i thought of the great idea to use that insight to make a bloom filter, and started coding it as soon as i got home..

as cool as it looks, its actually REALLY simple.. you take the 2 images you want to add, be it source1+source1 or source1+source2, you add them as usual BUT instead of saturating, you pop the overflow into a "glow-buffer", you then blur that buffer with an appropriate blur(in my case a standard slow as hell blur, since i was too lazy to code a box blur for this) and add it to your original scene..

something like this:


function makestuffglow;
begin
  for x = 0 to width do
   for y = 0 to height do
    if source1[x,y]+source2[x,y]>255 then glow_buff[x,y]=(source1[x,y]+source2[x,y])-256 else source1[x,y]=saturate(source1[x,y]+source2[x,y]);
   end; 
  end;

  awesome_fast_boxblur(glow_buff);
  source1=saturate(source1+glow_buff);

end;

and thats pretty much it.. the Luminance and Saturation parameters i use are just for controlling the brightness/saturation of the glow map before blurring and adding it all together..

there ya go, now let me see you use it wisely in some realtime productions.. and remember, credit where credit is due, or i'll come to your house!! :P
Title: Re: bloom/glow
Post by: ninogenio on December 23, 2008
cool!!

thats very simple indeed mind i will definitly be giving this a go cheers! k+
Title: Re: bloom/glow
Post by: spitfire on December 24, 2008
Cool, thnx for sharing. I'm sure there could be other interesting uses for an overflow buffer too.
Title: Re: bloom/glow
Post by: nunu on August 24, 2009
I just have to have a say ;)
Your method is still the same as the one using tresholding :p

Because adding source with itself leads to double intensities, right? Now if you take whatever goes over 255 to your overflow buffer you get the same values as you would get when tresholding away everything that is below 255/2.