Sprite progress bar

Convert any sprite into a progress bar with the help of color overlay.

Shader code
shader_type canvas_item;

uniform vec4 overlay_color : hint_color = vec4(1.0, 1.0, 1.0, 1.0);
uniform float progress : hint_range(0.0,1.0) = 0.0;
uniform float strength : hint_range(0.0,1.0) = 0.0;

void fragment() {
	if (1f - UV.y <= progress) {
	  vec4 custom_color = texture(TEXTURE, UV);
	  custom_color.rgb = mix(custom_color.rgb, overlay_color.rgb, strength);
	  COLOR = custom_color;
	} else {
	  COLOR = texture(TEXTURE, UV);
	}
}
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.

Related shaders

Radial Progress Shader

Squish Sprite

Sub-Pixel Accurate Pixel-Sprite Filtering

guest
0 Comments
Inline Feedbacks
View all comments