Weird squares when doing post processing or using shaders

Godot Version

v4.1.3.stable.official [f06b6836a]

Question

Hey y’all, I’ve been trying to get into shaders and post processing, however no matter what I try to do, i get these weird square artifacts on my shaders. I’m really not sure whats going on though. I’ve had this issue when implementing cel and blinn phong shading, but I’m attaching an example with a downscaling postprocessing effect I made with the help of godot shaders. I feel pretty confident this is correctly written, but for some reason these unsightly blocky squares appear. If anyone knows this issue, lmk. Thanks!

P.S. Heres a photo, and I’m attaching the shader code at the bottom.

Downscaling.gdshader

shader_type spatial;
render_mode unshaded;

const int pixel_size = 16;

uniform sampler2D DEPTH_TEXTURE : hint_depth_texture;
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture;

void vertex() {
    POSITION = vec4(VERTEX.xy, 1.0, 1.0);
}

void fragment() {
	float depth = texture(DEPTH_TEXTURE, SCREEN_UV).x;
    vec3 ndc = vec3(SCREEN_UV * 2.0 - 1.0, depth);
    vec4 view = INV_PROJECTION_MATRIX * vec4(ndc, 1.0);
    
    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;
}

Do you see the same problem in more recent Godot versions? Have you got up to date graphics drivers? Naively, it looks like tile-based rendering gone bad.

Haven’t tested any other versions, but now that you mention drivers, I’m curious if the fact I’m on a Macbook Air is impacting this. When I have time I’ll try and see if I run into the same issues on my Windows.

Okay yea, porting it to my windows seemed to fix it. Would be interesting to hear the reason why and if there is a solution on Mac. I get there are differences between the air and a traditional windows pc, but knowing if there are settings I can use to still do things on my mac would be nice.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.