3D Pixelation

-Works in Godot 4 & Godot 3.x-
Pixelates the screen output with custom pixel size

Use shader on a quad mesh placed infront of the camera

Method by David Lettier

Shader code
shader_type spatial;
render_mode unshaded;

const int pixel_size = 4; //resolution must be divisible by pixel_size

void fragment() {
	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;

	ALBEDO = texture(SCREEN_TEXTURE, vec2(x, y) / VIEWPORT_SIZE).xyz;
3d, filter, pixel, pixelate, pixelation, pixelator, psx, retro, screen
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

Square Pixelation


Newest Most Voted
Inline Feedbacks
View all comments
4 months ago

You could also use:

vec2 pixelated_uv = round(SCREEN_UV * float(pixel_size)) / float(pixel_size);
ALBEDO = texture(SCREEN_TEXTURE, pixelated_uv).rgb;

So that it works with any integer even if its not divisible

1 month ago

Great Shader, however when I apply it I can’t see particle effects. how do I fix it?

11 days ago

Made an account just to say thanks, the shader worked like a charm. Would recommend setting the priority of the quad mesh to a lower value so it doesn’t block any other objects in your game, in case someone else runs into the same problems I did.