Tilemap Blur

Works with overlapping textures.

Customizable.

Shader code
shader_type canvas_item;

uniform vec2 size;
uniform int samples = 0;

vec4 getPixel(sampler2D tex, vec2 uv, vec2 offset) {
	return texture(tex, uv + offset);
}

void fragment() {
	vec4 color = vec4(0.0);
	for (int x = -samples; x < 100; x++) {
		for (int y = -samples; y < 100; y++) {
			color += getPixel(TEXTURE, UV, vec2(float(x) * size.x, float(y) * size.y));

			if (y > samples) {
				break;
			}
		}
		if (x > samples) {
			break;
		}
	}
	if (samples == 0) {
		COLOR = getPixel(TEXTURE, UV, vec2(0.0, 0.0));
	} else {
		COLOR = color / float((samples * 2 + 1) * (samples * 2 + 1) - 1) + getPixel(TEXTURE, UV, vec2(0.0, 0.0));
	}
}
Tags
blur, tilemap
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from Haizlbliek

2D Fire Effect with colour banding

Motion Lines

Related shaders

Hexagon TileMap Fog of War

2D Top-Down Shadows (Tilemap Ready)

Tilemap Wind shader

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments