Skip to content

Instantly share code, notes, and snippets.

@yearofthewhopper
Created January 20, 2021 03:02
Show Gist options
  • Save yearofthewhopper/86bcd4a3be3e987381895a512ceb9842 to your computer and use it in GitHub Desktop.
Save yearofthewhopper/86bcd4a3be3e987381895a512ceb9842 to your computer and use it in GitHub Desktop.
using namespace std;
// @param[default=#00EFFFF0] progressColor
// @param[default=#FF2FFFF0] timeSpentColor
// @param[default=5.0,min=0.0,max=60.0] Duration
void mainImage(vec4 progressColor, vec4 timeSpentColor,float Duration,out vec4 fragColor )
{
float Time = getTime();
vec2 Resolution = getRenderTargetSize();
vec2 fragCoord = fragment(getVertexTexCoord()) * Resolution;
float dur = Duration;
float progress = fract(Time / dur);
float innerRadius = 80.0;
float outerRadius = 120.0;
float middleRadius = 0.5 * (innerRadius + outerRadius);
float halfWidth = 0.5 * (outerRadius - innerRadius);
vec2 pos = fragCoord.xy - 0.5 * Resolution.xy;
float radius = length(pos.xy);
float fr = halfWidth - abs(radius - middleRadius) + 1.0;
if(fr < 0.0) discard;
fr = clamp(fr, 0.0, 1.0);
float angle = degrees(atan(-pos.x, pos.y)) + 180.0;
float fa = radians(angle - progress * 360.0) * radius + 1.0;
fa = clamp(fa, 0.0, 1.0);
vec4 color = vec4(0.8,0.9,1,1);
vec4 col = mix(progressColor, timeSpentColor, fa);
col.a *= fr;
vec4 bgColor = progressColor;
col = mix(bgColor, col, col.a);
fragColor = col;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment