Skip to content
Search

Godot:PixelArt

lastmod 2024-03-30created 2023-05-304 edits

How to make pixel art games in Godot, caveats, etc.

Imported images look blurry

Change the value of Project Settings > Rendering > Textures > Canvas Textures > Default Texture Filter to "Nearest".

Window settings for pixel art games

Pixelation Shader

// References to built-in functions
// https://docs.godotengine.org/en/stable/tutorials/shaders/shader_reference/spatial_shader.html
// Fragment shader affects pixel, it basically manipulate all pixels individually, at the same time
void fragment() {
    // a variaent of nearest neighbour fragment shader
    float x = float(int(FRAGCOORD.x) % pixel_size);
    float y = float(int(FRAGCOORD.y) % pixel_size);

    x = FRAGCOORD.x + floor(float(pixel_size) / 2.0) - x;
    y = FRAGCOORD.y + floor(float(pixel_size) / 2.0) - y;

    // set albedo value on the current coordinate based on vec2(x,y) / viewport_size
    ALBEDO = texture(SCREEN_TEXTURE, vec2(x, y) / VIEWPORT_SIZE).xyz;
}

Smooth Pixel Art Gameplay - Tips for Eliminating Jittering

author Zer0 sitemap