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;
}




You could also use:
So that it works with any integer even if its not divisible
hey thanks for that!
not working
Great Shader, however when I apply it I can’t see particle effects. how do I fix it?
you put the render prority to -1
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.
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.
Great shader. But when used in a 3d scene with a Sprite3D, there are some black borders that appear along the side of the sprite. Is there anyway to solve this? I tried changing the Alpha Cut, but I still need “Opaque Pre-pass” and with this option there are these black borders that sometime appear.
Great shader, but for some reason i can’t see anything that has some sort of transparency? If i make a material with some transparency it is fully invisible in game with this, and this also happens with Label3Ds. Anyone having the same problem?
Thanks but it doesn’t work, it says “E 0:00:00:851 SCREEN_TEXTURE has been removed in favor of using hint_screen_texture with a uniform.
To continue with minimal code changes add ‘uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;’ near the top of your shader.
<C++ Source> :13
” and sincei m stupid i can’t fix it myself, replacing screen_texture with hint_screen_texture didn’t work.
shader_type spatial; render_mode unshaded; uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; const int pixel_size = 4; 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).rgb; }