I'm currently stuck on trying to write a shader for Godot 4.x. and get it to look right.
I'd like to take an image, pixelate a bit so that particles are a bit chunky, and then explode it into component chunky pixels. So it looks like the sprite has broken apart.
This is simple 3d animation which I mocked up in Blender to show what I want. It's basically a grid of 16 squares that shrink and fade as they move away from the centre. However they are all mapped so that together at the start they represent a whole image.
and being very new to shaders, this is what I've got so far in Godot:
shader_type canvas_item;
uniform sampler2D tex_diffuse; // explosion image
uniform sampler2D tex_explode; // grayscale circle
uniform float progress : hint_range(0.0, 1.0);
void fragment() {
vec2 direction = texture(tex_diffuse, UV).xy;
direction = direction * progress;
// Get UV and step them up by 4
vec2 tex_size = 1.0 / TEXTURE_PIXEL_SIZE; // texture size
vec2 uv = floor(UV * tex_size/4.0) / (tex_size/4.0 - 1.0); // snap to step
// Texture with exploded UV
vec4 tex = texture(TEXTURE, uv);
// Dissolve with alpha
float dissolve = texture(tex_explode, uv).x;
dissolve = step(progress, dissolve);
tex.a *= dissolve;
// set tex
COLOR = tex;
}
tex_explode texture:
As you can see from the two animations, I'm not quite there. This is where I need help. I need to divide the image up into pixelated chunks - let's call them pixel particles. "Move" those pixel particles apart from one another radiating from centre. scale down and fade out the pixel particles.
Just to be clear, I'm using a scale animation on the sprite (not yet included in shader)


