Skip to content

Instantly share code, notes, and snippets.

@anbnyc
Created June 14, 2019 20:52
Show Gist options
  • Save anbnyc/e9444e6e1c079bfb4fe6c3ba35ad4454 to your computer and use it in GitHub Desktop.
Save anbnyc/e9444e6e1c079bfb4fe6c3ba35ad4454 to your computer and use it in GitHub Desktop.
Pride flag!
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform float u_time;
vec3 colorA = vec3(1., 0.01, 0.01);
vec3 colorB = vec3(0.576, 0.161, 0.976);
float twostep(
float lower,
float upper,
float value){
return step(lower, value) - step(upper, value);
}
float cyc = 2.0;
float l6 = 0.166;
float tx(float a, float b){
return a/cyc * b;
}
void main() {
vec2 st = gl_FragCoord.xy/u_resolution.xy;
vec3 color;
float t = 0.5*cyc*sin(u_time) + 0.5*cyc;
vec3 pct = vec3(st.y);
pct.r = (1. - st.y)*(1. - tx(t, 1.))
+ .0*twostep(0.833, 1., st.y)
+ tx(t,0.056)*twostep(4.*l6, 5.*l6, st.y)
+ tx(t,0.2)*twostep(3.*l6, 4.*l6, st.y)
+ tx(t,2.296)*twostep(2.*l6, 3.*l6, st.y)
+ tx(t,1.926)*twostep(l6, 2.*l6, st.y)
+ tx(t,1.)*twostep(0., 0.166, st.y);
pct.g = (1. - st.y)*(1. - tx(t, 1.))
+ .0*twostep(0.833, 1., st.y)
+ tx(t,3.41)*twostep(4.*l6, 5.*l6, st.y)
+ tx(t,5.949)*twostep(3.*l6, 4.*l6, st.y)
+ tx(t,4.462)*twostep(2.*l6, 3.*l6, st.y)
+ tx(t,2.)*twostep(l6, 2.*l6, st.y)
+ tx(t,1.)*twostep(0., l6, st.y);
pct.b = (1. - st.y)*(1. - tx(t, 1.))
+ .0*twostep(0.833, 1., st.y)
+ tx(t,-0.008)*twostep(4.*l6, 5.*l6, st.y)
+ tx(t,0.006)*twostep(3.*l6, 4.*l6, st.y)
+ tx(t,0.194)*twostep(2.*l6, 3.*l6, st.y)
+ tx(t,0.96)*twostep(l6, 2.*l6, st.y)
+ tx(t,1.)*twostep(0., l6, st.y);
color = mix(colorA, colorB, pct);
gl_FragColor = vec4(color,1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment