Speed up Simplex Noise

I want to make a Java program, in which moving sky is generated out of Simplex Noise, but I have performance issues (framerate is too low). I’m using https://github.com/KdotJPG/OpenSimplex2/blob/master/java/OpenSimplex2F.java noise class.
My function which generates the sky, generates it entirely again each frame:

private void generate() {
        float y = offset;
        for (int i = 0; i < frame.getHeight(); i++) {
            float x = offset;
            for (int j = 0; j < frame.getWidth(); j++) {
                double a = noise.noise2(x, y) + 0.25f * noise.noise2(2 * x, 2 * y) + 0.125f * noise.noise2(4 * x, 4 * y);
                a = a / (1 + 0.25 + 0.125);
                a = (a + 1) / 2;
                a *= 100;
                Color color = Color.getHSBColor(220f / 360f, a / 100f, 1f);
                background.setRGB(j, i, color.getRGB());
                x += noiseResolution;
            }
            y += noiseResolution;
        }
    }

Where background is BufferedImage I’m drawing on and offset says how much noise is moved. I have tried to save an array of pixels of background each frame and translate it by the number of pixels it should be moved, and then I generated only pixels that are new. Unfortunately, because it was rendered too fast then, the number of pixels it should be moved was e.g. 0.2, so I couldn’t translate array indices by a fraction.
So I guess the only way is to somehow generate it in another way, but I totally have no idea how.

Thanks!

Answer

Not sure about Java, but in C++ with DirectX, OpenGL or any low level interface like that, this should be easily done on the GPU in either HLSL (DirectX), or GLSL (OpenGL). I implemented 5D Simplex noise and even zoomed in so it fills my large screen, and on my 9 year old computer with my old ho-hum graphics card it still does a couple hundred frames per second. Here’s what it looks like.

https://www.youtube.com/watch?v=oRO1IGcWIwg

If you can run a fragment shader from Java, I would think that would be the way to go. I think there is some OpenGL interface in Java so you might want to look int that.

Source: stackoverflow
The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .