Bug: bloom flickering

slimeslime Join Date: 2010-07-14 Member: 72352Members
edited October 2012 in Technical Support
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>

Comments

  • Dictator93Dictator93 Join Date: 2008-12-21 Member: 65833Members, Reinforced - Shadow
    Max should check this out and add it in engine. Thx for the work done!
  • kikaxakikaxa Join Date: 2012-08-19 Member: 155845Members
    wow, wanted to post this too.
    good work!
  • HughHugh Cameraman San Francisco, CA Join Date: 2010-04-18 Member: 71444NS2 Developer, NS2 Playtester, Reinforced - Silver, Reinforced - Onos, WC 2013 - Shadow, Subnautica Developer, Pistachionauts
    ermgz i love this kind of post.
  • WarmongerWarmonger Join Date: 2003-02-04 Member: 13126Members, Constellation
  • SteveRockSteveRock Join Date: 2012-10-01 Member: 161215Members, NS2 Developer, Subnautica Developer
    Taking a look at this right now. Thanks for posting!
  • SteveRockSteveRock Join Date: 2012-10-01 Member: 161215Members, NS2 Developer, Subnautica Developer
    Alrighty, seems to work well and almost no FPS difference. Thanks a ton! Look for your name (slime) in the next change log :)
  • slimeslime Join Date: 2010-07-14 Member: 72352Members
    edited November 2012
    <!--quoteo(post=2002241:date=Oct 31 2012, 04:07 AM:name=Strayan (NS2HD))--><div class='quotetop'>QUOTE (Strayan (NS2HD) @ Oct 31 2012, 04:07 AM) <a href="index.php?act=findpost&pid=2002241"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->ermgz i love this kind of post.<!--QuoteEnd--></div><!--QuoteEEnd-->
    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!
  • kikaxakikaxa Join Date: 2012-08-19 Member: 155845Members
    well, is there any way to remove flicker completely?
    can we(well, you) add averaging downsampler?
    , if it is, maybe use larger gaussian kernel?
  • slimeslime Join Date: 2010-07-14 Member: 72352Members
    edited November 2012
    <!--quoteo(post=2004878:date=Nov 1 2012, 03:45 PM:name=kikaxa)--><div class='quotetop'>QUOTE (kikaxa @ Nov 1 2012, 03:45 PM) <a href="index.php?act=findpost&pid=2004878"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->well, is there any way to remove flicker completely?
    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.
  • slimeslime Join Date: 2010-07-14 Member: 72352Members
    edited November 2012
    I believe there is more than one issue that causes the current flickering. In my love2d HDR bloom experiment (nearly identical pipeline to NS2's, but in a 2d setting), I got rid of all flickering by, when downsampling, taking the average of the four corners of the texel being sampled, with very minimal (~0.05ms) performance loss on my Intel HD 3000. However applying the same change to NS2 seems to have little or no effect, so there is also something else causing the flickering. It might be partly due to the fact that small or thin (relative to the screen) light sources are fairly heavily aliased, so pixels shift in and out of view when the camera orientation changes slightly.


    --------------------------------------------

    <!--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-->
  • Dictator93Dictator93 Join Date: 2008-12-21 Member: 65833Members, Reinforced - Shadow
    <!--quoteo(post=2013664:date=Nov 7 2012, 05:48 AM:name=slime)--><div class='quotetop'>QUOTE (slime @ Nov 7 2012, 05:48 AM) <a href="index.php?act=findpost&pid=2013664"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->I believe there is more than one issue that causes the current flickering. In my love2d HDR bloom experiment (nearly identical pipeline to NS2's, but in a 2d setting), I got rid of all flickering by, when downsampling, taking the average of the four corners of the texel being sampled, with very minimal (~0.05ms) performance loss on my Intel HD 3000. However applying the same change to NS2 seems to have little or no effect, so there is also something else causing the flickering. It might be partly due to the fact that small or thin (relative to the screen) light sources are fairly heavily aliased, so pixels shift in and out of view when the camera orientation changes slightly.


    --------------------------------------------


    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
Sign In or Register to comment.