Loading effect (color over grayscale)

This is a loading effect shader inspired by the download animation on the Epic Launcher. A value between 0.0 and 1.0 controls the amount of colors revealed on the image. 

Shader code
shader_type canvas_item;

uniform float percentage: hint_range(0.0, 1.0) = 1.0;

void fragment() {
	vec4 main_tx = texture(TEXTURE, UV);
    float avg = (main_tx.r + main_tx.g + main_tx.b) / 3.0;
	COLOR.a = main_tx.a;
	COLOR.rgb = main_tx.rgb * step(UV.x, percentage) + (vec3(avg) * step(percentage, UV.x));
}
Tags
2d, grayscale, image, loading, side by side
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 mreliptik

3D simple animated flag shader

2D simple animated flag shader

Related shaders

color splash (show only one color)

Gradient Color Fog

Hit Flash Shader (Custom Color)

guest
0 Comments
Inline Feedbacks
View all comments