Skip to content

Instantly share code, notes, and snippets.

@lunasorcery
Created August 22, 2018 21:43
Show Gist options
  • Select an option

  • Save lunasorcery/dcad2f53b0ce381c30513f707786dbb4 to your computer and use it in GitHub Desktop.

Select an option

Save lunasorcery/dcad2f53b0ce381c30513f707786dbb4 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 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 texChecker;
uniform sampler2D texNoise;
uniform sampler2D texTex1;
uniform sampler2D texTex2;
uniform sampler2D texTex3;
uniform sampler2D texTex4;
layout(location = 0) out vec4 out_color; // out_color must be written in order to see anything
#define iTime fGlobalTime
#define pi acos(-1.)
vec2 modang(vec2 p, float rep)
{
float r = length(p);
float ang = atan(p.x,p.y) / (2 * pi);
ang = (fract(ang*rep)+1)/rep;
ang *= 2*pi;
return vec2(sin(ang),cos(ang))*r;
}
float sdBox( vec2 p, vec2 b )
{
vec2 d = abs(p) - b;
return min(max(d.x,d.y),0.0) + length(max(d,0.0));
}
vec3 color(vec2 uv)
{
uv = fract(uv);
uv = uv * 1.04 - .02;
if(any(greaterThan(abs(uv-.5),vec2(.5))))
return vec3(0);
vec2 originalUv = uv;
uv = fract(uv * 8);
uv = uv * 1.1 - .05;
if(any(greaterThan(abs(uv-.5),vec2(.5))))
return vec3(0);
float d = sdBox(fract(uv*4)-.5, vec2(.2));
float threshold = .04;
//threshold = max(length(dFdx(uv)),length(dFdy(uv)));
float mask = smoothstep(threshold,-threshold,d);
//mix(vec3(66, 244, 226), vec3(65, 68, 244), sin(uv.x+iTime*4.)*.5+.5) / 255;
uv = fract(originalUv);
uv *= 8 * 4;
uv = floor(uv);
uv /= 8 * 4;
vec3 col = vec3(.03);
col += smoothstep(.6,1.,sin(uv.x*20.-iTime*1.5));
col += smoothstep(.9,1.,sin(3.*atan(uv.x-.5,uv.y-.5)-iTime*1.5+.5)) * vec3(.2,.6,1);
col += smoothstep(.9,1.,sin(3.*atan(uv.x-.5,uv.y-.5)+iTime*1.5+.5)) * vec3(1,.5,.2);
//mask=1;
return vec3(mask) * col;
}
vec3 pal(vec3 a, vec3 b, vec3 c, vec3 d, float t)
{
return a+b*cos(2*pi*(c*t+d));
}
vec3 logichroma(float t)
{
return pal(
vec3(.5),
vec3(.5),
vec3(1.),
vec3(0,1,2)/3,
t
);
}
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);
uv.y += .07;
out_color.rgb = color(gl_FragCoord.xy / v2Resolution.xy);
float chromaStrength = sin(iTime*.5);
out_color.rgb = vec3(0);
for(int i=0;i<100;++i)
{
uv *= mix(1.,.996,chromaStrength);
vec2 u = modang(uv, 3);
u = vec2(
u.x/u.y,
1./u.y
) / sqrt(3)*.5 + .5;
vec3 col = color(u+vec2(0,-iTime*.1));
float depthfog = pow(smoothstep(3.,-1.,-u.y),2.);
out_color.rgb += col * depthfog * logichroma(i/100.0);
}
out_color.rgb /= 4;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment