Created
April 5, 2023 14:25
-
-
Save AndreyKopylov/f3e8298e6759de951a9c5c19873f1363 to your computer and use it in GitHub Desktop.
Circle Progress Bar Godot 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shader_type canvas_item; | |
uniform float value: hint_range(0, 100); // % | |
uniform float thickness: hint_range(0, 100) = 30.; // % thickness | |
uniform sampler2D fg: source_color; | |
uniform sampler2D bg: hint_default_black; | |
uniform float offset: hint_range(0, 100); // % | |
uniform float smoothing: hint_range(0, 100) = 5.; | |
void fragment() { | |
vec2 point = UV - vec2(0.5); | |
float ang = (1. - atan(point.x, point.y) / PI) * 50. - offset; | |
if (ang < 0.) | |
ang += 100.; | |
float s = smoothing / 1000.; | |
float k = PI / 2. / s; | |
float r1 = .5 - thickness / 200.; | |
float r2 = .5; | |
float r = length(point); | |
float uy = (r2 - r) / (r2 - r1); | |
if (r > r2 || r < r1) | |
COLOR.a = 0.; | |
else { | |
if (ang <= value) | |
COLOR = texture(fg, vec2(ang / 100., uy)); | |
else | |
COLOR = texture(bg, vec2(ang / 100., uy)); | |
if ((r2 - r) < s) | |
COLOR.a = sin((r2 - r) * k); | |
if ((r - r1) < s) | |
COLOR.a = sin((r - r1) * k); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment