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 Rotation deform

Tiled texture inside of mask

Related shaders

Grayscale

Blur with Clearing Over a Node

color splash (show only one color)

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments