Pixelate

Shader code
shader_type canvas_item;

uniform int x_pixel_size : hint_range(1, 100);
uniform int y_pixel_size : hint_range(1, 100);

void fragment() {
	vec2 correction = TEXTURE_PIXEL_SIZE * vec2(float(x_pixel_size), float(y_pixel_size)) / vec2(2.0);
	vec2 texture_uv = floor(UV / TEXTURE_PIXEL_SIZE);
	vec2 offset = vec2(float(int(texture_uv.x) % x_pixel_size), float(int(texture_uv.y) % y_pixel_size));
	vec2 target = (texture_uv - offset) * TEXTURE_PIXEL_SIZE;
	COLOR = texture(TEXTURE, target + correction );
}
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.

Related shaders

Pixelate

Pixelate

Palette Filter and Pixelate combined

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments