3D Pixelation

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

**Instructions**
Use shader on a quad mesh placed infront of the camera

**Source**
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;
}
Tags
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

256 colour pixelation

3D Pixelation via material

Subscribe
Notify of
guest

7 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
NekotoArts
1 year 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

Jason Kim
Jason Kim
8 months ago
Reply to  NekotoArts

not working

Arcadev
Arcadev
1 year ago

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

CalzarStudios
CalzarStudios
1 year ago
Reply to  Arcadev

you put the render prority to -1

Civilian
Civilian
1 year 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.

Gwynoak
Gwynoak
6 months ago

Dude, I was messing with texture and model level shaders for hours and this looks PERFECT for what I needed. I lose it every time I think about it. It looks SO GOOD and its literally a 3D plane mesh crammed in front of the player camera. They’re wearing pixelated beer goggles and that makes me laugh because you’d never know.