Added shader for january session from Anton PC

This commit is contained in:
Anton Roy
2019-01-31 21:19:21 +01:00
parent 5098c6781e
commit 1f9dffe4e5
6 changed files with 664 additions and 0 deletions

142
2019-01-30/antoine1.glsl Normal file
View File

@ -0,0 +1,142 @@
#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 cookie;
uniform sampler2D descartes;
uniform sampler2D texNoise;
uniform sampler2D texTex2;
layout(location = 0) out vec4 out_color; // out_color must be written in order to see anything
#define time fGlobalTime
float sph(vec3 p, float r){
return length(p)-r;
}
float box(vec3 p, vec3 s) {
vec3 ap=abs(p)-s;
return length(max(vec3(0),ap)) + min(0, max(ap.x, max(ap.y,ap.z)));
}
float box(vec2 p, float s) {
vec2 ap=abs(p)-s;
return length(max(vec2(0),ap)) + min(0, max(ap.x, ap.y));
}
mat2 rot(float a) {
float ca=cos(a);
float sa=sin(a);
return mat2(ca,sa,-sa,ca);
}
float cyl(vec2 p, float r) {
return length(p)-r;
}
float smin(float a, float b, float h) {
float k=clamp((a-b)/h*0.5+0.5,0,1);
return mix(a,b,k) - k*(1-k)*h;
}
float rnd(float t) {
return fract(sin(t*745.523)*8956.565);
}
float curve(float t, float d) {
float g=t/d;
return mix(rnd(floor(g)), rnd(floor(g)+1), pow(smoothstep(0,1,fract(g)), 10));
}
float mat = 0;
float map(vec3 p) {
for(int i=0;i<4; ++i) {
float t1=time*0.2+i +curve(time, 0.3+i*0.3);
p-=0.1+i*0.1;
p.xy *= rot(t1);
p-=0.2+i*0.1;
p.yz *= rot(t1*1.2);
p=abs(p);
p-=0.3+i*0.1;
}
vec3 p2 = p;
float t2 = time*0.4;
p2.zx *= rot(-t2);
p2.xy *= rot(-t2*1.3);
float b = box(p, vec3(0.5,0.2,0.3));
float c = box(p2.xz, 0.2);
float e = cyl(p2.xz, 0.2);
float f =smin(b,-c, -0.1);
mat = e<f?1:0;
return min(e, f);
}
vec3 norm(vec3 p) {
vec2 off=vec2(0.01,0);
return normalize(map(p)-vec3(map(p-off.xyy), map(p-off.yxy), map(p-off.yyx)));
}
void cam(inout vec3 p) {
float t1 = time*0.3 + curve(time, 1.2);
p.yz *= rot(t1);
p.zx *= rot(t1*0.7);
}
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);
vec3 s=vec3(0,0,-15);
vec3 r=normalize(vec3(-uv, 0.7+curve(time, 0.5)));
cam(r);
cam(s);
vec3 col=vec3(0);
vec3 p=s;
float side=sign(map(p));
float prod=1;
for(int i=0;i<100;++i) {
float d=map(p)*side;
if(d<0.001) {
float curmat=mat;
vec3 l = normalize(vec3(-1));
vec3 n=norm(p)*side;
if(dot(n,l)<0) l=-l;
vec3 h=normalize(l-r);
float f=pow(1-max(0,dot(n,-r)),2);
vec3 spec = mix(vec3(1), vec3(10,6,2), curmat);
col += f*10*prod*max(0,dot(n,l)) * spec * (0.3*pow(max(0, dot(n,h)),50) + 0.3*pow(max(0, dot(n,h)),10));
if(curmat>0.5) break;
prod *=0.9;
side = -side;
d=0.01;
r=refract(r,n, 1+side*0.05);
}
if(d>60) break;
p+=d*r;
}
col = 1- exp(-col*2);
col = pow(col, vec3(1.2));
out_color = vec4(col, vec3(1));
}

158
2019-01-30/anton1.glsl Normal file
View File

@ -0,0 +1,158 @@
#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 cookie;
uniform sampler2D descartes;
uniform sampler2D texNoise;
uniform sampler2D texTex2;
layout(location = 0) out vec4 out_color; // out_color must be written in order to see anything
mat2 rot(float a)
{
float ca = cos(a);
float sa = sin(a);
return mat2(ca,-sa,sa,ca);
}
#define PI 3.14159
float map(vec3 p)
{
vec3 cp = p;
p.z -= 10.;
float time = fGlobalTime;
float acc = 1000.;
float BPM = 100. / 60.;
float bump = sin(fract(time * BPM ) * PI - PI * .5) * .5 + .5;
bump = pow(bump,2.);
bump *= .35;
p *= 1. - bump;
for(float i = 1.; i <= 6.; i++)
{
p.x = abs(p.x);
p.xy *= rot(p.y * i * .15 + time);
p.xz *= rot(p.y * i * .125 + time);
p.y += p.x * .3;
acc = min(acc,length(p) - (1. + i * .1));
}
p = cp;
float flo = p.y +10.;
return min(acc, flo);
}
vec3 normal(vec3 p)
{
vec2 e = vec2(.0,.01);
return normalize(vec3(
map(p + e.xxy) - map(p - e.xxy),
map(p + e.xyx) - map(p - e.xyx),
map(p + e.yxx) - map(p - e.yxx)
));
}
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);
vec3 eye = vec3(0.,0.,-7. + sin(fGlobalTime) * 2.);
vec3 rd = normalize(vec3(uv, 1.));
vec3 cp = eye;
float ti = floor(fGlobalTime ) + pow(fract(fGlobalTime), 2.);
rd.xy *= rot(sin(ti * 2.) * .2);
float st = 0.;
float cd = 0.;
for(;st < 1.; st += 1./128.)
{
cd = map(cp);
if(cd < .01) break;
cp += cd * rd * .75;
}
out_color = texture(cookie, uv * rot(fGlobalTime) + fGlobalTime * .12);
if(cd < .01)
{
vec3 norm = normal(cp);
float li = dot(norm, vec3(-1.,1.,1.));
out_color = vec4(li);
out_color.xy *= rot(fGlobalTime + cp.x);
out_color.xz *= rot(fGlobalTime + cp.z);
}
}

118
2019-01-30/anton2.glsl Normal file
View File

@ -0,0 +1,118 @@
#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 cookie;
uniform sampler2D descartes;
uniform sampler2D texNoise;
uniform sampler2D texTex2;
layout(location = 0) out vec4 out_color; // out_color must be written in order to see anything
#define PI 3.14159
float noise(vec2 p)
{
return fract(dot(p.x * 54523.1235, p.y * 1328.)) ;
}
mat2 rot(float a )
{
float ca = sin(a);
float sa = cos(a);
return mat2(sa,-ca,ca,sa);
}
float ease(float t)
{
return floor(t) + sin(fract(t) * PI - PI * .5) * .5 + .5;
}
float map(vec3 p)
{
float dist = 1000.;
vec3 cp = p;
float time = fGlobalTime;
float bpm = 120 / 60.;
p.z += ease(time * bpm) * 20. ;
p.xy *= rot(p.z * .1);
float st = sin(ease(time * bpm)) * .5 + .5;
p.xy *= rot(time * st + abs(p.y) * .01);
float cy2 = length(p.xz) - .75;
p.xz = mod(p.xz +10, 20) - 10;
//p.xy *= (-time);
dist = min(dist, length(p) - 1.);
float cy = length(p.xy) - .5;
dist = min(dist, cy2);
dist = max(dist,-cy);
cp.xy *= rot(time * .1);
p = cp;
p.x = abs(p.x);
p.x -=8;
p.z -= 10.;
float cd = length(p.xz) - 1.;
dist = min(dist, cd);
p = cp;
p.y = abs(p.y);
p.y -=8;
p.z -= 10.;
cd = length(p.yz) - 1.;
dist = min(dist, cd);
return dist;
}
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);
vec3 eye = vec3(0.,0.,-10.);
vec3 rd = normalize(vec3(uv,1.));
vec3 cp = eye;
float cd = 0.;
float st = 0.;
for(; st < 1.; st += 1. / 64.)
{
float cd = map(cp);
if(cd < .01) break;
cp += rd * .5 * cd;
}
out_color = vec4(1. - st);
float t = fGlobalTime;
out_color.xz *= rot(t + cp.z);
out_color.xy *= rot(t + cp.y);
out_color.yz *= rot(t + cp.x);
}

71
2019-01-30/lamogui3.glsl Normal file
View File

@ -0,0 +1,71 @@
#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 cookie;
uniform sampler2D descartes;
uniform sampler2D texNoise;
uniform sampler2D texTex2;
layout(location = 0) out vec4 out_color; // out_color must be written in order to see anything
mat2 r(float a)
{
float c= cos(a);
float s = sin(a);
return mat2(s, -s , c ,s);
}
float m(vec3 p)
{
p.xy *= r(10.0 *3.1415 * fGlobalTime);
float d = cos(p.x) + cos(p.y) + cos(p.z);
return d;
}
vec3 r(vec3 ro, vec3 rd, out float st)
{
vec3 p = ro;
for (float i = 0.0; i < 64.0; i++)
{
float d = m(p);
if (abs(d)<0.01)
{
st = i /64.0;
break;
}
p+= rd * d;
}
return p;
}
vec3 s(vec3 ro, vec3 p)
{
vec3 c = vec3(exp(-distance(ro, p) * 0.1));
c *= vec3(1.0 ,0.0, 0.0);
return 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);
vec3 rd = normalize(vec3(uv, 1.0));
vec3 ro = vec3(0.0, 0.0, 10.0* texture(texFFTIntegrated, 0.01).x);
float st = 1.0;
vec3 p = r(ro, rd, st);
vec3 c = s(ro, p);
c = mix (c, texture(cookie, p.xz + fGlobalTime).rgb, 0.5);
p.xz = r(fGlobalTime) * uv;
c = mix (c, texture(descartes, p.xy).rgb, 0.3);
c += fract(fGlobalTime * 10.0);
out_color = vec4(c, 1.0);
}

93
2019-01-30/leon2.glsl Normal file
View File

@ -0,0 +1,93 @@
#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 cookie;
uniform sampler2D descartes;
uniform sampler2D texNoise;
uniform sampler2D texTex2;
layout(location = 0) out vec4 out_color; // out_color must be written in order to see anything
#define time fGlobalTime
#define repeat(p,r) (mod(p,r)-r/2.)
mat2 rot(float a) { float c=cos(a), s=sin(a); return mat2(c,s,-s,c); }
vec3 look (vec3 eye, vec3 at, vec2 uv) {
vec3 front = normalize(at-eye);
vec3 right = normalize(cross(front, vec3(0,1,0)));
vec3 up = normalize(cross(front, right));
float fov = (1.+.5*sin(time*8.));
return normalize(front * .3 + right * uv.x + up * uv.y);
}
float map (vec3 pos) {
float scene = 10.;
pos.z -= time * 10.;
pos = repeat(pos, 5.);
const float count = 3.;
vec3 p = pos;
for (float i = count; i > 0.; --i) {
float r = i / count;
p = abs(p)-(.5+.3*sin(time*8.))*r;
p.xz *= rot(time*.2);
p.yz *= rot(time*.1);
float rr = .2+.1*sin(time* 8.);
rr *= r;
if (sin(time)<.0) {
scene = min(scene, length(p)-rr);
} else {
scene = min(scene, length(p.xz)-rr*.2);
scene = min(scene, length(p.yz)-rr*.2);
scene = min(scene, length(p.xy)-rr*.2);
}
}
//scene = min(scene, max(0., (length(pos.xz)-1.)));
pos.xz *= rot(pos.y + time *4.0+ sin(time*4.+pos.y));
pos.x += 1.;
pos.xz *= abs(pos.xz)-.5;
pos.xz *= abs(pos.xz)-.5;
//scene = min(scene, length(pos.xz)-.02);
return scene;
}
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 p = uv;
uv /= 1.-length(uv)*4.;
vec3 eye = vec3(0,0,-3);
eye.xz *= rot(time*.8);
eye.yz *= rot(time * .5);
vec3 ray = look(eye, vec3(0), uv);
vec3 pos = eye;
float shade = 0.;
const float count = 50.;
for (float i = count; i > 0.; --i) {
float dist = map(pos);
if (dist < .001) {
shade = i / count;
break;
}
pos += ray * dist;
}
vec3 color = vec3(.5)+vec3(1.)*cos(vec3(.01,.011,.0123)*time*5.+shade*2.+length(pos)*2.);
float funk = step(.0, sin(-time*4.+length(uv)*4.+atan(uv.y,uv.x)));
color = mix(color, 1.-color, funk);
p.y-=sqrt(abs(p.x))*.5*(1.+.2*sin(time*4.));
float heart = step(.0, length(p)-.2);
out_color = vec4(color*shade, 1.);
out_color.r += 1.-heart;
}

82
2019-01-30/momo1.glsl Normal file
View File

@ -0,0 +1,82 @@
#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 cookie;
uniform sampler2D descartes;
uniform sampler2D texNoise;
uniform sampler2D texTex2;
layout(location = 0) out vec4 out_color; // out_color must be written in order to see anything
vec2 rot(vec2 v, float a)
{
return mat2(cos(a), sin(a), -sin(a), cos(a))*v;
}
float map(vec3 p)
{
p.xy = rot(p.xy, .1*p.z);
vec3 q = mod(p, 12.) -6;
return length(q) - 5.;
}
vec3 gn(vec3 p)
{
vec2 e = vec2(0., 0.001);
return normalize(vec3(map(p-e.yxx)-map(p+e.yxx),
map(p-e.xyx)-map(p+e.xyx),
map(p-e.xxy)-map(p+e.xxy)));
}
void main(void)
{
vec2 uv = vec2(gl_FragCoord.x / v2Resolution.x, gl_FragCoord.y / v2Resolution.y);
uv *= 2.;
uv -= 1.;
uv /= vec2(v2Resolution.y / v2Resolution.x, 1);
uv = rot(uv, -0.5*fGlobalTime);
vec3 o = vec3(0., 0., 10.*fGlobalTime);
vec3 p = o;
vec3 rd = normalize(vec3(uv,1.));
int i = 0;
for(i = 0; i < 64; ++ i)
{
float d = map(p);
p += rd*d;
if(d<0.001)
break;
}
float c1 = float(i)/64.*4.;
vec3 n = gn(p);
vec3 rd2 = reflect(rd, n);
vec3 p2 = p+.1*rd2;
for(i = 0; i < 64; ++ i)
{
float d = map(p2);
p2 += rd2*d;
if(d<0.001)
break;
}
float c2 = float(i)/64.*4.;
vec3 co = mix(vec3(c1*c2), vec3(0., 0.3, 0.4), 1.-exp(-distance(p, o)*.035));
out_color = vec4(co, 1.);;
}