简体   繁体   中英

How can I draw the background with gaussian blur in Graphics2D in Java

I tried several things but they were all too slow, and I tried to use LWJGL and LibGdx but that's too advanced for me because the shaders must be created in the shader language. The last I tried has failed due to be too slow, and being glitchy. This is the last method I tried: (I used Graphics2D composite, and JHLabs FilterComposite with GaussianBlurFilter)

    public void render(BubbleBlaster game, Graphics2D gg) {
        LoadedGame loadedGame = BubbleBlaster.getInstance().getLoadedGame();
        if (loadedGame == null) {
            return;
        }

        Composite oldCompositeCo = gg.getComposite();
        FilterComposite filterComposite = new FilterComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f), new GaussianBlurFilter(10));

        gg.setComposite(filterComposite);
    }

There is a live web demo of Gaussian Blur for LibGDX (7th option down on the left) here https://crashinvaders.github.io/gdx-vfx/

To include in your app details of GDX-VFX are here https://github.com/crashinvaders/gdx-vfx .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM