Files
tbd-station-14/Resources/Textures/Shaders/cooldown.swsl
2020-08-29 19:55:16 +01:00

30 lines
801 B
Plaintext

light_mode unshaded;
const highp float PI = 3.14159265;
uniform highp float progress;
void fragment() {
highp vec4 col = zTexture(UV);
highp vec2 center = vec2(0.5,0.5);
highp vec2 delta = UV.xy - center;
highp float angle = atan(delta.x, -delta.y) + PI;
highp float dist = length(delta);
#ifdef HAS_DFDX
highp float dist_fwidth = fwidth(dist) * 0.67;
#else
highp float dist_fwidth = 0.05;
#endif
highp float dist_alpha = smoothstep(0.1-dist_fwidth, 0.1, abs(dist-0.35));
highp float angle_delta = (progress * PI * 2.0) - angle;
highp float arc_length = angle_delta * dist;
highp float angle_alpha = (progress > 0.0) ? smoothstep(dist_fwidth, 0.0, arc_length) : 0.0;
COLOR = vec4(col.xyz, 1.0 - max(dist_alpha, angle_alpha));
}