Results 1 to 19 of 19
  1. #1
    Member kitebizelt's Avatar
    Join Date
    Jan 2016
    Location
    Depok, Indonesia
    Posts
    131

    Better Bloom Filter w/ Down Sampling & Lens Flares

    We all know bloom is a filter that makes some area/objects looks more glowy, and BGE already got that, but here comes some problem:
    • The bloom filter on BGE sometimes blooms objects/areas where do we dont want
    • Really FPS consumtive


    So I thought why not make a better bloom filter?
    Pros:
    • Less FPS consumtive
    • Selective Bloom

    Cons:
    • Some artifacts on non-bloom objects
    • I don't know why but its 1 frame behind... bge.logic.NextFrame() doesn't work





    Download v1.0
    BetterBloomFilter.blend
    Download v1.1
    BetterBloomFilter.blend

    Download v2.0 - Added lens flares
    BetterBloomFilter.blend
    Download v2.2 - Invisible objects glitch fix
    BetterBloomFilter.blend

    Would like to hear your thoughts
    Last edited by kitebizelt; 27-Aug-16 at 18:04.
    Game engine doesn't determine the looks of your game, but your usage determines.
    SSDF - POMB - PPMB - Bloom w/ Flares - SSGI (WIP) -



  2. #2
    This is cool!
    The 1 frame behind bug is really bad. We might fix this in UPBGE.
    UPBGE http://upbge.org/ - Know some C/C++ or Can help with the project? Join #upbgecoders @ irc.freenode.net



  3. #3
    Member BluePrintRandom's Avatar
    Join Date
    Jul 2008
    Location
    NoCal Usa
    Posts
    18,327
    can you use a predraw callback?
    Break it and remake it - Wrectified
    If you cut off a head, the hydra grows back two.
    "headless upbge"



  4. #4
    Member kitebizelt's Avatar
    Join Date
    Jan 2016
    Location
    Depok, Indonesia
    Posts
    131
    Originally Posted by BluePrintRandom View Post
    can you use a predraw callback?
    sorry I've never heard of this, can you please explain with examples?
    Game engine doesn't determine the looks of your game, but your usage determines.
    SSDF - POMB - PPMB - Bloom w/ Flares - SSGI (WIP) -



  5. #5
    Member BluePrintRandom's Avatar
    Join Date
    Jul 2008
    Location
    NoCal Usa
    Posts
    18,327
    scene.pre_draw_setup.append(my_callback)

    I use it for weapons on actors using copy rotation constraints, since the constraint step is after the logic step*

    you just define a function, and then stick it in as a callback,
    Break it and remake it - Wrectified
    If you cut off a head, the hydra grows back two.
    "headless upbge"



  6. #6
    Member sdfgeoff's Avatar
    Join Date
    May 2010
    Location
    Kalpana One
    Posts
    5,119
    nextFrame only works from when python is the scene script. There are no examples and is no documentation on this, but if you create a scene property "__main__" and make it's value a python script, the script will be executed upon game start, then nextFrame() will work.

    I recall trying to put renderToTexture into a predraw callback without success. Or maybe that was ImageMirror(). Give it a try:
    Code:
    def funct_to_run():
        print("Running just before drawing, after physics and motion etc.")
    
    some_scene.pre_draw.append(funct_to_run)
    Be aware that accessing objects may do weird things. Interacting with sensors and actuators (Eg trying to set parameters) will fail. There is no bge.logic.getCurrentController() and a few other funny things.




    I would be interested in a direct comparison between a down-sampled render-to-texture bloom and a full resolution 2D filter bloom. I suspect the 2D filter would win by virtue of not needing to render the scene twice. But then I suppose O(n) (number of pixels drawn using RTT) vs O(n^2) (number of pixels processed in 2D filter) says that the render-to-texture may be slightly faster, so long as the overhead isn't too great.
    "Someone applied a roof texture to that wall" - martinsh

    Website: www.sdfgeoff.space



  7. #7
    Member kitebizelt's Avatar
    Join Date
    Jan 2016
    Location
    Depok, Indonesia
    Posts
    131
    Update v2.0 - Added lens flares & some chromatic aberrations
    Game engine doesn't determine the looks of your game, but your usage determines.
    SSDF - POMB - PPMB - Bloom w/ Flares - SSGI (WIP) -



  8. #8
    Member mataii's Avatar
    Join Date
    Jul 2002
    Location
    Mexico
    Posts
    444
    Nice work kitebizelt! and thanks for sharing
    Last edited by mataii; 25-Jun-17 at 12:14.



  9. #9
    Member adriansnetlis's Avatar
    Join Date
    Jun 2014
    Location
    Latvia
    Posts
    4,280
    My suggestion:
    Use 2-step blur. Why? Because it is faster.
    Current blur method is:
    Code:
    for i in samples:
        for j in samples:
            calculate vertical = i;
            calculate horizontal = j;
    This way you end up with i*j calculations per fragment. For case of bloomSIze set to 4 it's 16. That's not a problem. However, if you set the bloomSize to 16, for example, it starts to lag a lot. And it has a reason, for sure. 16x16 = 256 calculations.
    The 2 step method, however, is better for the 16 case.
    It first calculates the blur horizontally and stores the result in new texture. After that it blurs vertically.
    So in case of 2x2 or 3x3 blur it's not as effective as it takes 4(or 6) samples instead of 4(or 9)(which can be a slight improvement), but requires additional texture which will end up being less effecient. In case of 5x5 or more samples, however, the boost can be noticeable. In case of 8x8, for example, it's 16 samples instead of 64(4x better) and the additional texture uses just a little bit of additional resources. Overally in this case the improvement is approximately 3x. But in more sample cases it's growing exponentionally(e.g. in 16x16 case it's 32 instead of 256 and thus 8 times more efficient - such a big improvement). I suggest you to look into this method.
    It'd also be cool if you added bloom strength parameter.

    By the way - the bloom by itself is not working for me in your .blends. Only flares and chromatic aberation, but not bloom.
    Last edited by adriansnetlis; 25-Aug-16 at 16:23.
    My Blogspot my 3d development blog. I am at GTM + 2.00 time belt! Intel® Core™ i5-6300HQ 2.3 GHz(quadcore), NVIDIA GeForce GTX960M, 4GB DDR4 RAM, Linux Ubuntu 16.04.
    Worn Tires, Engine Roar, AstrumNetwork.com, Support me in Patreon



  10. #10
    Member ChaosEmergency's Avatar
    Join Date
    Sep 2011
    Location
    United Kingdom
    Posts
    1,005
    This is amazing just what i need. However, there is a few problems i have come across.
    I will just go with the one that i need to get over, to use it

    Object that have Visibility turned off, now are visible. This is a big problem for me as i
    have my object box for my player and other effects.
    My computer specs:
    Amd 4100 fx 3.6ghz | Radeon R9 280 3gb | 8 gig ram



  11. #11
    Member adriansnetlis's Avatar
    Join Date
    Jun 2014
    Location
    Latvia
    Posts
    4,280
    In script add test for a certain property that you add to objects that you want to be invisible and if the object has the specific property, than don't do obj.visible = True.
    My Blogspot my 3d development blog. I am at GTM + 2.00 time belt! Intel® Core™ i5-6300HQ 2.3 GHz(quadcore), NVIDIA GeForce GTX960M, 4GB DDR4 RAM, Linux Ubuntu 16.04.
    Worn Tires, Engine Roar, AstrumNetwork.com, Support me in Patreon



  12. #12
    Member ChaosEmergency's Avatar
    Join Date
    Sep 2011
    Location
    United Kingdom
    Posts
    1,005
    How do i do that. My scripting skills = 0
    My computer specs:
    Amd 4100 fx 3.6ghz | Radeon R9 280 3gb | 8 gig ram



  13. #13
    Member kitebizelt's Avatar
    Join Date
    Jan 2016
    Location
    Depok, Indonesia
    Posts
    131
    Originally Posted by adriansnetlis View Post
    By the way - the bloom by itself is not working for me in your .blends. Only flares and chromatic aberation, but not bloom.
    that's strange.. Try running in standalone mode and see if it gives you an error
    and also thanks for the suggestion
    Last edited by kitebizelt; 27-Aug-16 at 17:47.
    Game engine doesn't determine the looks of your game, but your usage determines.
    SSDF - POMB - PPMB - Bloom w/ Flares - SSGI (WIP) -



  14. #14
    Member kitebizelt's Avatar
    Join Date
    Jan 2016
    Location
    Depok, Indonesia
    Posts
    131
    Update v2.2 fixed the glitch on invisible object
    Before running besure to add 'invisible' property to invisible objects, and then set the value to 1
    Game engine doesn't determine the looks of your game, but your usage determines.
    SSDF - POMB - PPMB - Bloom w/ Flares - SSGI (WIP) -



  15. #15
    Member adriansnetlis's Avatar
    Join Date
    Jun 2014
    Location
    Latvia
    Posts
    4,280
    Originally Posted by kitebizelt View Post
    that's strange.. Try running in standalone mode and see if it gives you an error
    and also thanks for the suggestion
    It works well in standalone, but doesn't work in embed. Interesting...
    My Blogspot my 3d development blog. I am at GTM + 2.00 time belt! Intel® Core™ i5-6300HQ 2.3 GHz(quadcore), NVIDIA GeForce GTX960M, 4GB DDR4 RAM, Linux Ubuntu 16.04.
    Worn Tires, Engine Roar, AstrumNetwork.com, Support me in Patreon



  16. #16
    Member adriansnetlis's Avatar
    Join Date
    Jun 2014
    Location
    Latvia
    Posts
    4,280
    By the way - try making this a selective bloom of certain range. If we had HDR in BGE, we could make it really high-definition, but... All what we got, we must use
    My Blogspot my 3d development blog. I am at GTM + 2.00 time belt! Intel® Core™ i5-6300HQ 2.3 GHz(quadcore), NVIDIA GeForce GTX960M, 4GB DDR4 RAM, Linux Ubuntu 16.04.
    Worn Tires, Engine Roar, AstrumNetwork.com, Support me in Patreon



  17. #17
    Member Thatimster's Avatar
    Join Date
    Jul 2012
    Location
    New Zealand
    Posts
    1,863
    Originally Posted by adriansnetlis View Post
    By the way - try making this a selective bloom of certain range. If we had HDR in BGE, we could make it really high-definition, but... All what we got, we must use
    TwisterGE posted this a while ago. I guess its close to HDR:
    https://blenderartists.org/forum/sho...loom-2D-Filter

    Regarding the filter: Is there anyway you could draw circles of bloom instead of just up/down + left/right?
    Last edited by Thatimster; 28-Aug-16 at 03:18.
    My BGE Tutorials | 98 free nature Assets | My BGE Sprite Addon | Facebook Page | Contact
    Stay inspired!



  18. #18
    Member adriansnetlis's Avatar
    Join Date
    Jun 2014
    Location
    Latvia
    Posts
    4,280
    Originally Posted by Thatimster View Post
    TwisterGE posted this a while ago. I guess its close to HDR:
    https://blenderartists.org/forum/sho...loom-2D-Filter

    Regarding the filter: Is there anyway you could draw circles of bloom instead of just up/down + left/right?
    Using gaussian blur, I guess Some constant arrays can be used.
    My Blogspot my 3d development blog. I am at GTM + 2.00 time belt! Intel® Core™ i5-6300HQ 2.3 GHz(quadcore), NVIDIA GeForce GTX960M, 4GB DDR4 RAM, Linux Ubuntu 16.04.
    Worn Tires, Engine Roar, AstrumNetwork.com, Support me in Patreon



  19. #19
    Member ChaosEmergency's Avatar
    Join Date
    Sep 2011
    Location
    United Kingdom
    Posts
    1,005
    Thank you kitebizelt for the fix, works amazing.
    In my game i change cameras to aim, what happens then is the Filter don`t work
    properly, because i changed camera. Is there a work around for this ?

    I like this filter, please keep working on it
    My computer specs:
    Amd 4100 fx 3.6ghz | Radeon R9 280 3gb | 8 gig ram



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •