[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - Bloom

Bloom

Discuss programming topics that involve the OpenGL API.

Moderator: InsideQC Admins

Bloom

Postby Vic » Mon Oct 07, 2013 5:37 pm

Hi,

can anyone here provide me examples of _good_ bloom code? By good I mean reasonably optimized, well written C/C++ and modern GLSL code that produces quality picture? There are plenty tutorials on the web but somehow nothing has yet satisfied my taste :P Any clues would be appreciated.
User avatar
Vic
 
Posts: 21
Joined: Sun Nov 07, 2010 12:42 am

Re: Bloom

Postby Barnes » Mon Oct 07, 2013 6:56 pm

with fbo or not?
User avatar
Barnes
 
Posts: 232
Joined: Thu Dec 24, 2009 2:26 pm
Location: Russia, Moscow

Re: Bloom

Postby Vic » Tue Oct 08, 2013 6:13 pm

fbo, of course!
User avatar
Vic
 
Posts: 21
Joined: Sun Nov 07, 2010 12:42 am

Re: Bloom

Postby Spike » Tue Oct 08, 2013 9:17 pm

take screen
filter it so lower levels do not blur.
downsize
smudge it horizontally (yay 2d guassian blur)
smudge it vertically
repeat about 3 times
add each layer over your original scene.

guassian blur can be achieved with 3 samples:
0.3125*sample[x-1.2] + 0.375*sample[x] + 0.3125*sample[x+1.2]
the 1.2 and numbers give you a result equal to 1 with a 5-pixel-wide kernel thanks to GL_LINEAR sampling.
you can smudge it in one pass if you want 9 lookups instead of 6+a write I suppose. separate directions means you can scale up the kernel size a bit more easily without squaring the number of lookups, but hey, your implementation your code.
the downsize part allows your smudging to spread further away.

that's what fte does. only stuff above the threshold gets blured. the downsizing stuff is meant to average each pixel rather than just dropping random ones to avoid random flickering.
the spread is pixel-based, which limits the distance bloom spreads. at higher resolutions, you might need to increase the number of downsize iterations, which is a significant annoyance. As I only use a fixed iteration count, the speed doesn't drop too exponentially with higher resolutions, but stuff doesn't spread so far either.

I'm sure there's other ways to do it.
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Bloom

Postby Vic » Thu Oct 10, 2013 8:49 pm

User avatar
Vic
 
Posts: 21
Joined: Sun Nov 07, 2010 12:42 am

Re: Bloom

Postby Spiney » Fri Nov 01, 2013 2:22 pm

Bad bloom is a pet peeve of mine, though it's gotten a lot better over the last couple of years.
Use multiple iterations like Spike said, it makes a huge difference visually.
Blur during downsampling to avoid pixelation, reduces crawling pixels when moving around.
Bluring with small kernel size during upsampling reduces the 'bilinear-look', incase you can afford it.
Don't use straight addition in LDR, it blows out stuff and creates garish colors, prefer 'screen' blending or something similar.
Subtract unblurred frame from blurred for certain things (eg. sky lighting spilling over edges).
Google for "Kawase" light streak filter for filter with a less uniform look.
You can select brightest pixels in low res buffer and splat pointsprites (inferring color).
Don't overdo it :P
Spiney
 
Posts: 63
Joined: Mon Feb 13, 2012 1:35 pm


Return to OpenGL Programming

Who is online

Users browsing this forum: No registered users and 1 guest