Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
psenough authored Oct 13, 2024
1 parent 3d4eb7d commit d3d6f6b
Show file tree
Hide file tree
Showing 2 changed files with 316 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
#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 texInercia;
uniform sampler2D texInerciaBW;
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 r2d(p,a) p=cos(a)*p+sin(a)*vec2(-p.y, p.x);
#define time fGlobalTime * 2.

float cat(vec2 p) {
p.x = abs(p.x);
vec2 q=p;
q.x = abs(q.x-.2);
q.y += q.x - .2;
float r = abs(q.y)<.05 && q.x<.15 ? 1. : 0.;
p.x -= .6;
p.y = abs(p.y) - .08;
r += abs(p.y)<0.03 && abs(p.x)<.15 ? 1. : 0.;
return r;
}

float iPlane(vec3 p, vec3 d){
return p.y / -d.y;
}

float smin(float a, float b, float k) {
float h = clamp(.5 + .5 * (b-a) / k, 0., 1.);
return mix(b, a, h) - k * h * (1. - h);
}

float ldist(vec3 p, vec3 a, vec3 b, float r) {
vec3 pa = p-a, ba = b-a;
float h = clamp(dot(pa,ba) / dot(ba,ba), 0., 1.);
return length(pa - ba*h) - r;
}
float df(vec3 p) {
p.y -= 3.;
float sx = sign(p.x);
p.x = abs(p.x);

vec3 a = vec3(0, -abs(sin(time))*.5, 1),
b = vec3(0,-1.5,0);
r2d(b.yz, sin(time));
float d = smin(
length(p + a) - 1.,
length(p - vec3(0, -abs(sin(time-.3))*.5, 1)) - 1.,
1.5) * .7;
a.x += 1.;
b = a+b;
d = smin(
d,
ldist(p, a, b, .2),
.5
);
a = b;
b = vec3(0, -1.5, 0);
r2d(b.yz, sin(time+.5));

b = a+b;
d = smin(
d,
ldist(p, a, b, .2),
.3
);
// back
a = vec3(0, abs(sin(time-.3))*.5, -1),
b = vec3(0,-1.5,0);
r2d(b.yz, sin(time + 1.5));
a.x += 1.;
b = a+b;
d = smin(
d,
ldist(p, a, b, .2),
.5
);
a = b;
b = vec3(0, -1.5, 0);
r2d(b.yz, sin(time+.5));

b = a+b;
d = smin(
d,
ldist(p, a, b, .2),
.5
);
a = vec3(0, abs(sin(time-.3))*.5, -2);
b = vec3(0, -1, -.5);
r2d(b.yz, sin(time)*.25);
b += a;

d = smin(
d,
ldist(p, a, b, 0.1),
0.5);


a = vec3(0, abs(sin(time))*.5, 2);
b = vec3(0, .4, .5);
r2d(b.yz, sin(time)*.25);

b += a;

d = smin(
d,
ldist(p, a, b, 0.4),
0.5);
a=b;
b=vec3(0, 0, .5);
b += a;
d = smin(
d,
ldist(p, a, b, 0.2),
0.3);
a.x += .3;
a.y += .3;
b = a + vec3(.1, .3, 0);

d = smin(
d,
ldist(p, a, b, 0.1),
0.1);

return d;
}

vec3 norm(vec3 p) {
vec2 e = vec2(1e-3, 0);
return normalize(vec3(
df(p+e.xyy)-df(p-e.xyy),
df(p+e.yxy)-df(p-e.yxy),
df(p+e.yyx)-df(p-e.yyx)
));
}

vec3 rm(inout vec3 p, inout vec3 dir, float mDist) {
float tdist = 0.;

for (int i=0; i<70; i++) {
float d = df(p);
if (d<1e-3) {
vec3 n = norm(p);
dir = reflect(dir, n);
p += n * 3e-3;
//return vec3(n);
}
p += dir * d;
tdist += d;
if (tdist > mDist){
p -= dir * (tdist - mDist);
break;
}
}
return vec3(0.);
}

void main(void) {
vec2 uv = vec2(gl_FragCoord.xy * 2. - v2Resolution.xy) /v2Resolution.y;

vec3 p = vec3(0,4,-4),
d = normalize(vec3(uv, 1.));
r2d(d.yz,.5);
r2d(p.xz, time/8.);
r2d(d.xz, time/8.);

vec4 catC = vec4(0);

float pd = iPlane(p, d);

catC.xyz += rm(p, d, pd <= 0. ? 8. : pd);
if (p.y < 1e-2) {
p.z += time;
p = floor(p * .2);
catC += step(0.5, mod(p.x + p.z, 2.));
} else {
catC.rgb += mix(vec3(.5,.5,1), vec3(1), d.y);
}
/*
for (float i=0.;i<9.;i++) {
vec2 o = vec2(sin(i / 10.+texture(texFFTIntegrated, 0.01).x * .4284), cos(i/10.+texture(texFFTIntegrated, 0.01).x * .325));
o = pow(abs(o), vec2(7.)) * sign(o);
vec2 u = uv;
r2d(u, sin(i / 10.+texture(texFFTIntegrated, 0.01).x * .4284) * .3);
catC[int(i)/3] += cat((u + o / 4.) * .5) / 3.;
}*/
out_color = catC;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#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;

layout(location = 0) out vec4 out_color; // out_color must be written in order to see anything

float gtt=fGlobalTime;
float gt=texture(texFFTIntegrated,0.002).r*.12+gtt*.2;
float gttf=texture(texFFT,0.002).r*4;
float sttf=texture(texFFTSmoothed,0.002).r*4;

float cir(vec2 uv, float r) {
return length(uv)-r;
}

void rot(inout vec2 p, float a){
p = cos(a)*p + sin(a)*vec2(-p.y,p.x);
}

vec4 plas( vec2 v, float time )
{
float c = 0.5 + sin( v.x * 10.0 ) + cos( sin( time + v.y ) * 20.0 );
return vec4( sin(c * 0.2 + cos(time)), c * 0.15, cos( c * 0.1 + time / .4 ) * .25, 1.0 );
}
void main(void)
{
vec2 uv = vec2(gl_FragCoord.x / v2Resolution.x, gl_FragCoord.y / v2Resolution.y);
float po=4000;
float bm=texture(texFFTSmoothed,0.002).r*po;

vec2 zom=uv;
uv -= 0.5;
uv=floor(uv*bm)/bm;
uv /= vec2(v2Resolution.y / v2Resolution.x, 1);
vec2 zm=uv;


zom-=.5;
zom*=1.01-(bm/po)*.15;
zom+=.5;

vec2 m;
m.x = atan(uv.y / uv.x) / 3.14;
m.y = 1 / length(uv) * .2;
float d = abs(m.x);

float f = texture( texFFTSmoothed, d ).r * 100;
m.x += sin( fGlobalTime ) * 0.1;
m.y += fGlobalTime * 0.25;

vec4 t = plas( m * 3.14, fGlobalTime ) / d;
t = clamp( t, 0.0, 1.0 );

for(int i=0;i<9;i++){
zm=abs(zm)+vec2(0,.0);
zm-=.5;
rot(zm,.1-gt*.2);
zm+=.5;
zm=abs(zm)-vec2(0.5,0);
zm-=.5;
rot(zm,-.1+gt*.11);
zm+=.5;
}

float ftx=texture(texFFT,abs(zm.x*10)).r*20;
vec3 prv=texture(texPreviousFrame,mod(zm,.8)).rgb;
vec3 prev=texture(texPreviousFrame,zom).rgb;
//rot(prv.xy,.5);
rot(prv.xz,.3);
rot(prev.xy,-.5);
//rot(prev.xz,-.3);

vec3 col = vec3(1-prv.g*100);
float cr = cir(uv,.2);
float cr2 = cir(uv*vec2(2.8,.9),.2);
float cr3 = cir(uv*vec2(8,1.1),.2);

col*=step(cr,f/10);
col+=abs(prv)*.8;

col+=ftx*gttf*10;

if(prv.r+prv.g+prv.b<0.01){
col=vec3(1);
}
col=prv*col+step(cr-0.05,f/10)*vec3(10,12,8);
//col*=clamp(prev,0.5,.8)*step(cr-.2,1-sttf*.5);

col*=1-step(cr2,0);

if(col.r+col.g+col.b<0.01){
col=vec3(prev);
}
float uv2=zom.y*40+abs(zom.x-.5*pow(length(zom-vec2(.5,.8))*5,4))+gt*10;

if(mod(uv2,4)<2){
col*=prev;
}
col+=step(cr3,0)*vec3(1,1,0);

out_color = vec4(col,1);
}

0 comments on commit d3d6f6b

Please sign in to comment.