Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bloom effect creates lag on android #23

Open
4lfg24 opened this issue Jul 10, 2023 · 2 comments
Open

Bloom effect creates lag on android #23

4lfg24 opened this issue Jul 10, 2023 · 2 comments

Comments

@4lfg24
Copy link

4lfg24 commented Jul 10, 2023

I'm having an issue where applying the bloom effect drops the fps from 60 to 30 on Android, I know that applying bloom is a pretty expensive operation, but I was wondering if there was a solution to this, here's my code:

vfxManager.cleanUpBuffers(Color(0.3f, 0.3f,0.8f, 1f))
        
        vfxManager.beginInputCapture()
        
        SharedObjects.batch.use {
            for (entity in SharedObjects.entities){
                if(entity is Player) {
                    entity.render()
                }
                else {
                    entity.render()
                }
            }
            
            for(effect in SharedObjects.effects){
                effect.draw(SharedObjects.batch, delta)
                if (effect.isComplete){
                    SharedObjects.effects.removeValue(effect, true)
                    effect.free()
                }
            }
        }
        vfxManager.endInputCapture()

        vfxManager.applyEffects()
        vfxManager.renderToScreen()

Thank you in advance

@metaphore
Copy link
Member

Hi, sorry for the late reply.

Not knowing what exactly happens in the rendering methods of your entities and effects, it's hard to judge where's the performance bottleneck.

However, speaking of the VFX, there are a few "not so fast" effects in the library, the bloom effect included. Where there's probably a more optimal implementation of the effect, I honestly don't think you can improve it dramatically with just a few amends (the bloom is a combination of multiple effects).

On many modern phones, a display may have an overwhelmingly huge resolution compared to the device's performance capabilities. That's why you need to be careful when you use heavy full-screen shaders, like the ones that are used in the bloom effect. At this point, if you want to get an instant gain in performance using post effects, I'd recommend you to reduce the size of the VFX buffers. The most performance impact comes from the number of pixels every effect needs to process. E.g. reducing VFX buffer resolution from 4K down to FHD makes every effect work 4 times faster and use 4 times less memory too. Of course, the downside would be the output resolution drop, but IMHO, for most mobile cases, that could be a fair tradeoff.

You can set the desired VFX resolution in the resize method. Here's how you cut it in half:

vfxManager.resize(width * 0.5f, height * 0.5f)

@4lfg24
Copy link
Author

4lfg24 commented Jul 15, 2023

Thank you for your help! I also experimented a bit and found out that reducing the bloom passes to below 7 increases the performance significantly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants