u/Exboom2

▲ 9 r/libgdx

Transitioning shaders between areas

Hello! I've been working on a open world RPG named Seven Stardust. I've recently been trying to improve the visual quality of my game, and part of that is shaders.

I've had an issue where my music and shaders suddenly change when switching areas and it's a bit jarring. Thankfully, I was able to make a system to blend shaders between different areas. My game does not have complex shaders, it's just a hue change.

However, because of these simple shaders, I'm able to blend Vector3 variables and pass them into my GLSL in order to change hues dynamically. Some of the code I used to get this working is below.

I hope this helps some people out with their games, and have a wonderful day!
Open Alpha Here. No download required!

i there    private final Vector3 startColor = new Vector3(1f, 1f, 1f);
    private final Vector3 targetColor = new Vector3(1f, 1f, 1f);
    private final Vector3 activeColor = new Vector3(1f, 1f, 1f);
    private float fadeTimer = 0.0f;
    private final float FADE_DURATION = 1.5f;

    public void update(GameScreen game) {
        String mapArea = game.mapSystem.area != null ? game.mapSystem.area : "";

        if (!mapArea.equals(currentArea)) {
            Gdx.app.log("ShaderSystem", "Area shifted to: " + mapArea);
            currentArea = mapArea;

            startColor.set(activeColor);
            targetColor.set(getColorByAreaName(currentArea));
            fadeTimer = 0.0f;
        }

        if (fadeTimer < FADE_DURATION) {
            fadeTimer += Gdx.graphics.getDeltaTime();
            if (fadeTimer > FADE_DURATION) {
                fadeTimer = FADE_DURATION;
            }

            float alpha = fadeTimer / FADE_DURATION;
            activeColor.x = MathUtils.lerp(startColor.x, targetColor.x, alpha);
            activeColor.y = MathUtils.lerp(startColor.y, targetColor.y, alpha);
            activeColor.z = MathUtils.lerp(startColor.z, targetColor.z, alpha);
        }
    }
    /* After this you can pass ActiveColor into your frag shader, Which would change
    the pixels to this color. The code might not work, I kinda just pulled it out of
    my shader system, but that's the general gist of blending. */
u/Exboom2 — 2 days ago
▲ 9 r/libgdx

Shaders in Seven Stardust

I've been working on my game a lot and I added this rainbow shader to the first area. I'm new to shaders, so while I do like it, I don't know if it would actually be good enough for a game.

u/Exboom2 — 10 days ago
▲ 6 r/libgdx

Seven Stardust open alpha available now!

I've just finished a very basic 7-or-so-minute demo of Seven Stardust. Any feedback is greatly appreciated! Here's the link and some things to keep in mind:

  • Your save file will not be retained.
  • There will be bugs and errors.
  • The Elden School is the only area that is prototyped.
  • Exit the game with Control/Command + E
  • The game is not tested on Mac. It may not work, I'm not sure

https://exboom.itch.io/seven-stardust

u/Exboom2 — 25 days ago