Scratch pixelate effect

Acts just like the pixelate effect from Scratch

NOTICE: This shader uses edited code from another source (under CC0 license)
Credit to: https://godotshaders.com/author/pabby/
Source: https://godotshaders.com/shader/pixelate-3/

Shader code
shader_type canvas_item;

uniform float amount = 0.0;

void fragment() {
	if (amount != 0.0) {
		float newAmount = amount/3.338;
		vec2 pixelSize = vec2(newAmount);
		
		vec2 correction = TEXTURE_PIXEL_SIZE * vec2(float(pixelSize.x), float(pixelSize.y)) / vec2(2.0);
		vec2 texture_uv = floor(UV / TEXTURE_PIXEL_SIZE);
		vec2 offset = vec2(mod(texture_uv.x, pixelSize.x), mod(texture_uv.y, pixelSize.y));
		vec2 target = (texture_uv - offset) * TEXTURE_PIXEL_SIZE;
		COLOR = textureLod(TEXTURE, target + correction, 0.0);
	}
}
Tags
Scratch
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.

More from The2AndOnly

Scratch fisheye effect

Scratch color effect

Fnaf / Clickteam perspective (displacement) – Godot 4.2

Related shaders

Scratch mosaic effect

Scratch color effect

Scratch whirl effect

Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
ggg
ggg
8 days ago

Works great!