Skip to content

Instantly share code, notes, and snippets.

@totetmatt
Created February 19, 2020 12:07
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 totetmatt/5d4e92406637ab8b2ec683c7e738a26f to your computer and use it in GitHub Desktop.
Save totetmatt/5d4e92406637ab8b2ec683c7e738a26f to your computer and use it in GitHub Desktop.
#version 150
in VertexData
{
vec4 v_position;
vec3 v_normal;
vec2 v_texcoord;
} inData;
out vec4 fragColor;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
uniform vec2 iResolution;
uniform float iTime;
uniform float iTimeDelta;
uniform int iFrame;
uniform vec4 iMouse;
uniform sampler2D iChannel0;
uniform sampler2D iChannel1;
uniform sampler2D iChannel2;
uniform sampler2D iChannel3;
uniform vec4 iDate;
uniform float iSampleRate;
void mainImage(out vec4, in vec2);
void main(void) { mainImage(fragColor,inData.v_texcoord * iResolution.xy); }
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
#define PI 3.141592
#define PI2 (PI*2.)
float fig(vec2 uv,float offset) {
uv +=sin(iTime*(2.) +offset)*.1;
return step(0.01,0.02-min(0.02,abs(uv.y)));
}
mat2 r(float a){return mat2(cos(a),sin(a),-sin(a),cos(a));}
vec3 ball(vec2 uv,float offset) {
vec2 uuv = uv;
uv.x+=sin(iTime+offset*sin(iTime))*.7;
uv.y+=cos(iTime*4.+offset)*.1;
uv*=15;
uv *= r(floor(-iTime*4.));
uv*=r(offset*cos(iTime*.6)+abs(atan(uuv.x,uuv.y)/PI)*2);
vec2 b = vec2(1.09,1.09);
vec2 d = abs(uv)-b;
float di = length(max(d,0.0)) + min(max(d.x,d.y),0.0) -.001;
di = abs(di-cos(floor(-iTime*1.))*.5);
di = 1.-smoothstep(0.10,0.11,di);
return vec3(di,di*.5*(1.-sin(floor(iTime)+uuv.y*10.)),di*.5*(1.-cos(floor(iTime)+uuv.x*10.)));
}
vec3 master(vec2 uv,float r) {
float d = fig(uv,0);
float e = fig(uv,r*PI2*(1.6/6.));
float f = fig(uv,r*PI2*(2.5/6.));
float g = fig(uv,r*PI2*(3.4/6.));
float h = fig(uv,r*PI2*(4.3/6.));
float i = fig(uv,r*PI2*(5.2/6.));
vec3 col = vec3(0.1);
col.r = (d*.25+e*.5+f*.25);
col.g = (f*.25+g*.5+h*.25);
col.b = (h*.25+i*.5+d*25);
return col;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord)
{
vec2 uv = (fragCoord.xy-.5*iResolution) / iResolution.y;
//uv +=cos(iTime+uv.x*2.)*.3+.3;
vec3 bb = vec3(0.);
float l = 20.;
for(int i=0;i <l;i++){
bb += ball(uv,PI*i/l);
}
vec3 col = (master(uv-.35,1.) + master(uv+.35,-1.))+ bb;
fragColor = vec4(col,1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment