Skip to content

Instantly share code, notes, and snippets.

@CharStiles
Created November 13, 2022 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CharStiles/5934425b602b1158761118be67abfd83 to your computer and use it in GitHub Desktop.
Save CharStiles/5934425b602b1158761118be67abfd83 to your computer and use it in GitHub Desktop.
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform float u_time;
uniform float u_vol;
void main() {
vec2 pos = ((gl_FragCoord.xy/u_resolution) - 0.5)*2.0; // origin is in center
// who remembers SOH CAH TOA ?
// tan, given an angle will return the ratio
// so if we only have the ratio of position
// we use atan to get the angle
float angle = atan(pos.y,pos.x);
float r = sin(angle + u_time);
// sin returns a number from -1 to 1, and colors are from 0 to 1, so thats
// why you only see red on the screen half the time. the angle goes around
// the screen, adding time moves it clockwise
float g = cos(length(pos*10.)-u_time);
// the distance (aka length) from the center put in a cos, subtracting
// time moves the circles out.
float b = cos(angle+ cos(length(pos*15.)) + u_time);
// this combines what we learned in the red and green channels
// angle is going through a cos and so is the length, so we see the
// blue channel oscillating in both dimensions the polar coordinates give us
vec4 color = vec4(r,g,b,1);
gl_FragColor = color;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment