Created
April 12, 2020 19:07
-
-
Save Gargaj/03dd4f559129943dbc13950d8060780b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 | |
// HOW DID I GET HERE TONIGHT | |
// WHAT AM I DOING HERE | |
// HOW DID I REACH THIS STATE | |
// EVERYBODY KNOWS | |
// EVERYONE'S WATCHING | |
float rand(float x) | |
{ | |
return fract(sin(x) * 430147.8193); | |
} | |
float rect( vec2 point, vec2 rectA, vec2 rectB ) | |
{ | |
if (point.x > rectA.x | |
&& point.x < rectB.x | |
&& point.y > rectA.y | |
&& point.y < rectB.y) | |
{ | |
return 1; | |
} | |
return 0; | |
} | |
vec4 fui( vec2 uv, float t ) | |
{ | |
float floatT = t; | |
t = int(t); | |
float start = rand(t) * 0.8 + 0.1; | |
float end = start + 0.1; | |
if (rand(t)<0.5) | |
{ | |
if (uv.x > start && uv.x < end) | |
{ | |
return mod((uv.x+uv.y+floatT/4.0)*8,1) < 0.5 ? vec4(0.1,0.8,1.0,1.0) : vec4(0.0,0.0,0.0,0.0); | |
} | |
} | |
else | |
{ | |
if (uv.y > start && uv.y < end) | |
{ | |
return mod((uv.x+uv.y+floatT/6.0)*8,1) < 0.5 ? vec4(1.0,1.0,1.0,1.0) : vec4(0.0,0.0,0.0,0.0); | |
} | |
} | |
float bass = clamp(texture(texFFTSmoothed, 0.01).r * 100,0,1); | |
for (int i=0; i<6; i++) | |
{ | |
float p1 = rand(t+0.123+i) * 0.2; | |
float p2 = p1 + rand(t+0.124+i) * 0.5; | |
float p3 = p2 + rand(t+0.125+i) * 0.2; | |
float y = rand(t+0.128+i) * 0.8 + 0.2; | |
float thicc = 0.0025; | |
float result = rect(uv, vec2(p1, y - thicc), vec2(p2,y + thicc)); | |
if (result > 0.0) | |
{ | |
return result * vec4(0.9, 0.3, 0.1, 1.0); | |
} | |
if (p2 < uv.x && uv.x < p3 && y - thicc < uv.y - (uv.x - p2) && uv.y - (uv.x - p2) < y + thicc ) | |
{ | |
return vec4(0.9, 0.3, 0.1, 1.0); | |
} | |
} | |
// ALSO BEFORE I FORGET, BIG UP TO FMS_CAT! | |
for (int j = 0; j<4; j++) | |
{ | |
float sx = rand(t+0.345 + j); | |
float sy = rand(t+0.349 + j); | |
float size = 0.1; | |
if (sx<uv.x && uv.x<sx+size && sy<uv.y &&uv.y<sy+size) | |
{ | |
float spx = mod(floor(rand(t+0.3 + j)*8)/8.0,1); | |
float spy = mod(floor(rand(t+0.59 + j)*8)/8.0,1); | |
vec2 spriteUV = (uv - vec2(sx,sy)) / size; | |
vec4 sam = texture( texChecker, vec2(spx,spy) + spriteUV / 8.0 ); | |
return clamp((1-sam.r)+0.2,0,1) * vec4(1,0.1,0.1,1) * bass; | |
} | |
} | |
// CRAP I FORGOT I HAD A BEER OPEN DAMN | |
for (int k=0; k<5; k++) | |
{ | |
float cx = rand(t+0.445+k); | |
float cy = rand(t+0.449+k); | |
float dist = length(vec2(uv.x-cx,uv.y-cy)); | |
float radius = rand(t+0.34+k) * 0.2 + 0.2; | |
float circThicc = 0.0025; | |
if (radius - circThicc < dist && dist < radius + circThicc) | |
{ | |
return vec4(0.8,0.2,1,0.8); | |
} | |
} | |
for (int l=0; l<20; l++) | |
{ | |
float cx = rand(t+0.645+l) * 0.6 + 0.2 + sin(floatT) * 0.1; | |
float cy = rand(t+0.649+l) * 0.6 + 0.2 + cos(floatT) * 0.1; | |
float dist = length(vec2(uv.x-cx,uv.y-cy)); | |
if (dist < 0.005) | |
{ | |
return vec4(0.9,0.7,0,1) * clamp(0.005/dist,0,1); | |
} | |
} | |
return vec4(0.0,0.0,0.0,0.0); | |
//return length(uv) < 0.5 ? vec4(1,1,1,1) : vec4(0,0,0,0); | |
} | |
vec2 rotate2D( vec2 v, float f) | |
{ | |
float sa = sin(f),ca=cos(f); | |
return vec2( v.x * ca - v.y * sa, v.y * ca + v.x * sa ); | |
} | |
// for those watching, i just ported this from hlsl because it kept causing problems | |
// still love hlsl tho, sorry bae | |
vec4 renderPlanes( vec2 uv ) | |
{ | |
vec3 rayDir = vec3( uv * 2 - 1, -1.0 ); | |
rayDir.x *= v2Resolution.x/v2Resolution.y; | |
rayDir.xy = rotate2D( rayDir.xy, fGlobalTime * 0.05 ); | |
//rayDir.xz = rotate2D( rayDir.xz, sin(fGlobalTime ) * 0.05 ); | |
//rayDir.yz = rotate2D( rayDir.yz, cos(fGlobalTime ) * 0.05 ); | |
vec3 rayOrigin = vec3(1,0,0); | |
//rayOrigin.x += sin( fGlobalTime ) * 0.25; | |
//rayOrigin.y += cos( fGlobalTime ) * 0.25; | |
rayOrigin.z = -1 * fGlobalTime; | |
vec4 colour = vec4(0); | |
int steps = 10; | |
float planeDist = 1.0f; | |
for (int i=steps; i>=0; i--) | |
{ | |
float planeZ = (rayOrigin.z - mod(rayOrigin.z, planeDist)) - i * planeDist; | |
float t = (planeZ - rayOrigin.z) / rayDir.z; | |
if (t > 0.0f) | |
{ | |
vec3 hitPos = rayOrigin + t * rayDir; | |
vec4 layer = fui( abs(mod(hitPos.xy, 2.0)-1), fGlobalTime + i * 4.7 ); | |
layer *= (steps-i)/float(steps); | |
colour = mix( colour, layer, layer.a ); | |
} | |
} | |
return colour; | |
} | |
void main(void) | |
{ | |
vec2 uv = vec2(gl_FragCoord.x / v2Resolution.x, gl_FragCoord.y / v2Resolution.y); | |
vec4 colour = renderPlanes(uv); | |
colour += renderPlanes(uv-mod(uv,0.1)) * 0.4; | |
vec4 gradient = mix(vec4(0,0,0.2,0),vec4(0,0,0,0),uv.y); | |
vec4 finalRender = mix(gradient,vec4(colour.xyz,1),colour.a); | |
finalRender.g = pow(finalRender.g, 0.7); | |
out_color = finalRender; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment