Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CharStiles/c08fec80e5a5c625b20900946d19299d to your computer and use it in GitHub Desktop.
Save CharStiles/c08fec80e5a5c625b20900946d19299d to your computer and use it in GitHub Desktop.
float circ( vec2 p){
return length(p) - 0.3;
}
void pR(inout vec2 p, float a) {
p = cos(a)*p + sin(a)*vec2(p.y, -p.x);
}
// Repeat in two dimensions
vec2 pMod2(inout vec2 p, vec2 size) {
vec2 c = floor((p + size*0.5)/size);
p = mod(p + size*0.5,size) - size*0.5;
return c;
}
// http://www.iquilezles.org/www/articles/palettes/palettes.htm
// As t runs from 0 to 1 (our normalized palette index or domain),
//the cosine oscilates c times with a phase of d.
//The result is scaled and biased by a and b to meet the desired constrast and brightness.
vec3 cosPalette( float t, vec3 a, vec3 b, vec3 c, vec3 d )
{
return a + b*cos( 6.28318*(c*t+d) );
}
void main () {
vec2 pos = uv();
pR(pos,time);
pMod2(pos, vec2(2.0,2.0));
pos = pos + vec2(0.4,0.);
float shape = circ(pos);
vec3 brightness = vec3(0.3);
vec3 contrast = bands.xyz;
vec3 osc = vec3(0.5,1.0,0.0);
vec3 phase = vec3(0.4,0.9,0.2);
vec4 web = texture2D(channel0,uvN());
vec3 col = cosPalette((time/4.0) + shape, brightness, contrast, osc, phase );
col = col * shape;
vec4 prev = texture2D(backbuffer, uvN() + .002);
col = mix(web,prev, col.x ).rgb;
if (web.x < 0.4){
col = prev.rbg;
}
gl_FragColor = vec4(col,1.) ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment