Skip to content

Instantly share code, notes, and snippets.

@totetmatt
Created April 15, 2021 10:35
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/86fff414dc639c7fa21d78a831ec9f60 to your computer and use it in GitHub Desktop.
Save totetmatt/86fff414dc639c7fa21d78a831ec9f60 to your computer and use it in GitHub Desktop.
#version 410 core
uniform float fGlobalTime; // in seconds
uniform vec2 v2Resolution; // viewport resolution (in pixels)
uniform float fFrameTime; // duration of the last frame, in seconds
uniform sampler1D texFFT; // towards 0.0 is bass / lower freq, towards 1.0 is higher / treble freq
uniform sampler1D texFFTSmoothed; // this one has longer falloff and less harsh transients
uniform sampler1D texFFTIntegrated; // this is continually increasing
uniform sampler2D texPreviousFrame; // screenshot of the previous frame
uniform sampler2D texChecker;
uniform sampler2D texNoise;
uniform sampler2D texTex1;
uniform sampler2D texTex2;
uniform sampler2D texTex3;
uniform sampler2D texTex4;
#define iTime fGlobalTime
layout(location = 0) out vec4 out_color; // out_color must be written in order to see anything
vec3 pal(float t){
return .5+.5*cos(2.*3.141592*(1.*t+vec3(.0,.3,.7)));
}
mat2 rot(float a){
float c=cos(a),s=sin(a);
return mat2(c,-s,s,c);
}
void main(void)
{
vec2 uv = vec2(gl_FragCoord.x / v2Resolution.x, gl_FragCoord.y / v2Resolution.y);
uv -= 0.5;
uv /= vec2(v2Resolution.y / v2Resolution.x, 1);
vec2 id = (floor(uv*5.))*0.; // biome change, unused if *0.;
// Time varying pixel color
vec3 col = vec3(0.);
vec2 cpos = uv+vec2(sin(iTime),cos(iTime*.33))*.5;
float d = length(cpos)-.10-sin(iTime*.77)*.05+.05;
d= smoothstep(.01,.001,abs(d)-.0004);
col = vec3(d);
vec2 puv = ((uv*v2Resolution.y)+(.5*v2Resolution.xy))/v2Resolution.xy;
vec4 acc = vec4(0.);
for(float x=-1.;x<=1.;x++){
for(float y=-1.;y<=1.;y++){
acc += texture(texPreviousFrame,(puv+vec2(x,y)*.001));
}
}
vec4 pcol = vec4(0.,0.,0.,1.);
for(int i=0;i<5;i++){
if(acc[i] >.3 && acc[i] <1.0 ){
if(acc[int(mod(float(i),3.))] >= 2.0*( acc[int(mod(float(i+1),3.))] + acc[int(mod(float(i+2),3.))]) &&
acc[i] >= .002*acc[int(mod(float(i+1)+mod(length(id),2.0),3.))]
) {
pcol[i] += acc[i]+ acc[int(mod(float(i+1)+mod(length(id),2.0),3.))];
pcol[int(mod(float(i+1),3.))]= acc[int(mod(float(i+1)+mod(length(id),2.0),3.))]/2.*9.201;
} else {
//pcol[i] *= acc[i];
}
} else if(acc[i] >=1.0){ pcol[i]= acc[i]/9.201;}
}
pcol = pcol*1.0;
out_color = vec4(col*pal(iTime*1.33+atan(cpos.x,cpos.y)*2.),1.0)+pcol;
//out_color = fcol;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment