Bug: bloom flickering
slime
Join Date: 2010-07-14 Member: 72352Members
NS2's current blooming technique introduces a lot of flickering on smaller bloom sources when the player turns or moves even slightly. Here's a video demonstration:
<center><object width="450" height="356"><param name="movie" value="http://www.youtube.com/v/9rza_QSQWaU"></param><embed src="http://www.youtube.com/v/9rza_QSQWaU" type="application/x-shockwave-flash" width="450" height="356"></embed></object></center>
Technical explanation: NS2's implementation of bloom repeatedly downscales the screen-sized bloom framebuffer by 1/2 each time, to get many cheap blurry versions. The downscaling naturally removes some very small details, which is where the flickering originates. However, NS2's implementation compounds the detail removal by successively blurring and adding the small versions of the bloom framebuffer, starting with the smallest. It puts the most weight on the words of the lowest-resolution one, so to speak. When the bloom sources move slightly relative to the screen, the small-sized framebuffers will dim the bloom pixels significantly unless they perfectly line up with a pixel on the framebuffer, causing them to flicker as they alternate between being interpolated between neighbouring pixels and lining up perfectly.
One way to remove most of the flickering is to do the blurring after downscaling rather than before upscaling each framebuffer. Here's what it looks like when that is done:
<center><object width="450" height="356"><param name="movie" value="http://www.youtube.com/v/1HUS7l67yj0"></param><embed src="http://www.youtube.com/v/1HUS7l67yj0" type="application/x-shockwave-flash" width="450" height="356"></embed></object></center>
The flickering isn't gone completely, but it's <i>much</i> less noticeable. Here's the relevant change to the Deferred.render_setup file: <a href="https://dl.dropbox.com/u/4214717/bloom_changes.txt" target="_blank">https://dl.dropbox.com/u/4214717/bloom_changes.txt</a>
<center><object width="450" height="356"><param name="movie" value="http://www.youtube.com/v/9rza_QSQWaU"></param><embed src="http://www.youtube.com/v/9rza_QSQWaU" type="application/x-shockwave-flash" width="450" height="356"></embed></object></center>
Technical explanation: NS2's implementation of bloom repeatedly downscales the screen-sized bloom framebuffer by 1/2 each time, to get many cheap blurry versions. The downscaling naturally removes some very small details, which is where the flickering originates. However, NS2's implementation compounds the detail removal by successively blurring and adding the small versions of the bloom framebuffer, starting with the smallest. It puts the most weight on the words of the lowest-resolution one, so to speak. When the bloom sources move slightly relative to the screen, the small-sized framebuffers will dim the bloom pixels significantly unless they perfectly line up with a pixel on the framebuffer, causing them to flicker as they alternate between being interpolated between neighbouring pixels and lining up perfectly.
One way to remove most of the flickering is to do the blurring after downscaling rather than before upscaling each framebuffer. Here's what it looks like when that is done:
<center><object width="450" height="356"><param name="movie" value="http://www.youtube.com/v/1HUS7l67yj0"></param><embed src="http://www.youtube.com/v/1HUS7l67yj0" type="application/x-shockwave-flash" width="450" height="356"></embed></object></center>
The flickering isn't gone completely, but it's <i>much</i> less noticeable. Here's the relevant change to the Deferred.render_setup file: <a href="https://dl.dropbox.com/u/4214717/bloom_changes.txt" target="_blank">https://dl.dropbox.com/u/4214717/bloom_changes.txt</a>
Comments
good work!
I actually noticed the issue and came up with this solution because I was learning about HDR bloom by creating a pipeline based on NS2's (and a few other resources) in love2d, so NS2's liberal usage of viewable/editable code helped both of us I guess. :)
<!--quoteo(post=2004862:date=Nov 1 2012, 03:36 PM:name=SteveRock)--><div class='quotetop'>QUOTE (SteveRock @ Nov 1 2012, 03:36 PM) <a href="index.php?act=findpost&pid=2004862"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Alrighty, seems to work well and almost no FPS difference. Thanks a ton! Look for your name (slime) in the next change log :)<!--QuoteEnd--></div><!--QuoteEEnd-->
Awesome, glad I could help!
can we(well, you) add averaging downsampler?
, if it is, maybe use larger gaussian kernel?
can we(well, you) add averaging downsampler?
, if it is, maybe use larger gaussian kernel?<!--QuoteEnd--></div><!--QuoteEEnd-->
It would be awesome if a better solution is found, but speaking personally I would rather have a bit of flicker with the same performance than no flicker with worse performance (as doing more texture lookups would likely cause). Of course there could always be a "high quality" option, I suppose.
--------------------------------------------
<!--sizeo:2--><span style="font-size:10pt;line-height:100%"><!--/sizeo--><b>Disregard everything below, it breaks the alien vision post-process effect somehow!</b><!--sizec--></span><!--/sizec-->
<!--sizeo:1--><span style="font-size:8pt;line-height:100%"><!--/sizeo-->
I have also improved the performance of the bloom pipeline by about 1ms on my AMD Radeon 6750m (and reduced VRAM usage a bit), by completely removing the need to use a second full-sized 'ping pong' RGBA16F accumulation buffer. The modified bloom looks basically identical ingame.
Changed parts of Deferred.render_setup, hopefully it's clear what's where: <a href="https://dl.dropbox.com/u/4214717/bloom_changes_2.txt" target="_blank">https://dl.dropbox.com/u/4214717/bloom_changes_2.txt</a>
And changed FinalCompositePS in Bloom.fx:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->float4 FinalCompositePS(PS_DeferredPass_Input input) : COLOR0
{
return tex2D(inputTextureSampler, input.texCoord);
}<!--c2--></div><!--ec2--><!--sizec--></span><!--/sizec-->
--------------------------------------------
I have also improved the performance of the bloom pipeline by about 1ms on my AMD Radeon 6750m (and reduced VRAM usage a bit), by completely removing the need to use a second full-sized 'ping pong' RGBA16F accumulation buffer. The modified bloom looks basically identical ingame.
Changed parts of Deferred.render_setup, hopefully it's clear what's where: <a href="https://dl.dropbox.com/u/4214717/bloom_changes_2.txt" target="_blank">https://dl.dropbox.com/u/4214717/bloom_changes_2.txt</a>
And changed FinalCompositePS in Bloom.fx:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->float4 FinalCompositePS(PS_DeferredPass_Input input) : COLOR0
{
return tex2D(inputTextureSampler, input.texCoord);
}<!--c2--></div><!--ec2--><!--QuoteEnd--></div><!--QuoteEEnd-->
Quoting this so the devs notice it. It is quite awesome. I recommend sending a msg to one of the devs