Bloom post-process filter

Published May 11, 2010
Advertisement
After a bit of work, I finally got my bloom post-process filter to work!

The way I do it is to render the bloom in 4 passes, rendering a screen-sized quad with the texture every pass.

First I render the scene to a texture that I slap on a quad, then I render the quad, sending the generated texture to the first bloom pass shader (extract highlights). This shader has a threshold value which allows me to adjust the passthrough level for colors.

This renders to a new texture that I render to a screenspace quad and pass the texture to the second bloom pass, the horizontal gaussian blur. I used the oZone3D gaussian blur shader (which is a two-pass gaussian blur, one for horizontal and one for vertical). This works well. The shader comes with a value called blurSize, which allows you to adjust how wide the blur should be in texels.

This renders also to a texture that is rendered to a screenspace quad and passed to the last bloom pass, which combines the blurred highlights with the original scene texture.

vec4 adjustSaturation(in vec4 color, in float saturation) { 	float grey = dot(color, vec4(vec3(0.3, 0.59, 0.11), 0.0)); 	vec4 grey_color = vec4(grey, grey, grey, 0.0);	return mix(grey_color, color, saturation); }vec4 bloomCombine(){	float bloomIntensity = 2.0; 	float bloomSaturation = 1.2;     vec4 bloom = texture2D(uni_FullscreenBloomTex, ex_TexCoord.st);    bloom = (adjustSaturation(bloom, bloomSaturation) * bloomIntensity);	float baseIntensity = 1.0; 	float baseSaturation = 1.0;    vec4 base = texture2D(uni_FullscreenTex, ex_TexCoord.st);    base = (adjustSaturation(base, baseSaturation) * baseIntensity); 	    base *= (1.0 - clamp(bloom, 0.0, 1.0));     return (base + bloom); } void main(){    out_Color = bloomCombine();}


I will move the adjustable values into uniforms and have adjustable values on the C++ side later, preferably exposed to an XML doc. But for now it was easiest to just tweak the values in the shader itself.

Thanks to Kenneth Gangsto for giving me most of this code ;)

Previous Entry Misc details
Next Entry Cleaning up a bit
0 likes 2 comments

Comments

sprite_hound
Very nice. Love seeing the progress.

Have to ask: What's the black quad that's in all the screenshots?
May 11, 2010 02:21 PM
Trefall
Thanks man! :)

The black bars are health bars which I haven't properly re-implemented after the OpenGL 3.1 upgrade. Reminds me that I should probably go back and make sure everything is ported before the weekend arrive. Next week is crunch week, last week of development before the school's deadline! The time runs too fast!!!
May 11, 2010 03:44 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement