Pixel Dissolve TextureRect

Dissolve Shader for Texture Rects in Godot 4.0

Shader code
shader_type canvas_item;

uniform float time_offset : hint_range(0.0, 1.0, 0.001) = 1.0;
uniform float dissolve_speed = 1.0;

float random_coord(vec2 co) {
    return fract(sin(dot(co.xy, vec2(12.9898,96.233))) * 43758.5453);
}

void fragment() {
	vec2 texture_resolution = 1.0 / TEXTURE_PIXEL_SIZE;
	vec2 pixel_within_texture = floor(UV * texture_resolution);
	vec4 texture_color = texture(TEXTURE, UV);

	if (sin((TIME * dissolve_speed) + time_offset) < random_coord(pixel_within_texture)) {
		// Set to the original texture color
//		COLOR = texture_color;
		// Set to a new color
		COLOR = vec4(0.0, 0.0, 0.0, 0.0); 
	}
	else {
		// German flag
		if (UV.y < 0.33) {
			COLOR.r = 0.0;
			COLOR.g = 0.0;
			COLOR.b = 0.0;
		} 
		else if (UV.y < 0.66) {
			COLOR.r = 1.0;
		}
		else {
			COLOR.r = 1.0;
			COLOR.g = 1.0;
		}
	}
}
Tags
fade, pixel, pixelate, texture, transition
The shader code and all code snippets in this post are under MIT license and can be used freely. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

Burn/Dissolve

Simple 2D dissolve

Fire dissolve shader

Subscribe
Notify of
guest

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Juho
Juho
9 months ago

nice german flag shader

cak3_lover
8 months ago

very nice & familiar 🙃