Skip to content

GLSL Shaders

Almas Baim edited this page Dec 26, 2024 · 1 revision

From 25, FXGL provides some level of support for fragment shaders written in GLSL, see early version YouTube tutorial.

TODO: below, if still not written, please remind me.

Example Shader

    public static final String SIMPLE_SHADER = """
            #version 460
            
            void main() {
                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
            }
            """;

Default (built-in) Uniform Variables

#version 460

// these uniform vars are automatically updated by FXGL

// set to width,height of the GLImageView
uniform vec2 resolution;

// set to time in seconds that this GLImageView spent in running (not paused) game scene
uniform float time;
            
void main() {
    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
Clone this wiki locally