Scratch mosaic effect

Acts just like the mosaic effect from Scratch

NOTE: In order for it to work, you have to change this setting on the sprite:
Texture > Repeat > Set to “Enabled”

Shader code
shader_type canvas_item;

uniform float amount = 0.0;

void vertex() {
	if (amount != 0.0) {
		float newAmount = trunc(((abs(amount) + 5.0) / 10.0) + 1.0);
		UV = UV * vec2(newAmount);
	}
}
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 pixelate effect

Scratch brightness effect

Scratch whirl effect

Related shaders

Scratch fisheye effect

Scratch color effect

Scratch whirl effect

guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
oLe Studios
1 year ago

Hi, this shader is only for godot 4, but i re-code it:

shader_type canvas_item;

uniform float amount_x : hint_range(1, 500) = 2.0;  // Número de repeticiones en el eje X
uniform float amount_y : hint_range(1, 500) = 2.0;  // Número de repeticiones en el eje Y

void vertex() {
    UV = UV * vec2(amount_x, amount_y);
}

void fragment() {
    vec2 repeated_uv = fract(UV);  // Esto asegura que las coordenadas UV se repitan correctamente
    COLOR = texture(TEXTURE, repeated_uv);
}
This code can add a mosaic effect in the X cord and Y cord

DESIGNED AND TESTED IN/FOR GODOT 3.5

Last edited 1 year ago by oLe Studios