Add 2019-12-19

This commit is contained in:
Jonathan Giroux 2019-12-20 17:29:38 +01:00
parent fe96ce4317
commit 13d62e8684
4 changed files with 528 additions and 0 deletions

211
2019-12-19/Flopine.glsl Normal file
View File

@ -0,0 +1,211 @@
#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 karl;
uniform sampler2D lionel;
uniform sampler2D texChecker;
uniform sampler2D texNoise;
layout(location = 0) out vec4 out_color; // out_color must be written in order to see anything
float time = fGlobalTime;
float PI = 3.141592;
float TAU = 2.*PI;
float ITER = 100.;
void moda (inout vec2 p, float rep)
{
float per = TAU/rep;
float a = atan(p.y,p.x);
float l = length(p);
a = mod(a,per)-per*0.5;
p = vec2(cos(a),sin(a))*l;
}
void mo (inout vec2 p, vec2 d)
{
p = abs(p)-d;
if (p.y>p.x) p = p.yx;
}
float stmin (float a, float b, float k, float n)
{
float st = k/n;
float u = b-k;
return min(min(a,b), 0.5*(u+a+abs(mod(u-a+st,2.*st)-st)));
}
float smin( float a, float b, float k )
{
float h = clamp( 0.5+0.5*(b-a)/k, 0.0, 1.0 );
return mix( b, a, h ) - k*h*(1.0-h);
}
mat2 rot (float a)
{return mat2(cos(a),sin(a),-sin(a),cos(a));}
float heart (vec2 uv)
{
uv.x = abs(uv.x)-0.02;
uv *= rot(-PI/6.);
return step(length(uv*vec2(1.,0.5)),0.05);
}
vec3 texturing (vec2 uv, sampler2D text, float detail)
{
uv *= detail;
float ux = (sin(time*2.*PI)>0.)? uv.x : 1.-uv.x;
float uy = 1.-uv.y;
vec2 uu = vec2(ux,uy);
uv = fract(uv)-.5;
uv *= rot(time);
moda(uv, 5.);
uv.x -= 0.15+sin(time)*0.1+0.1;
float h = heart(uv);
return clamp(texture(text, uu).rgb + vec3(0.8,0.,0.2)*h,0.,1.);
}
float box (vec3 p, vec3 c)
{
vec3 q = abs(p)-c;
return min(0.,max(q.x,max(q.y,q.z)))+length(max(q,0.));
}
float cyl (vec3 p, float r, float h)
{return max(length(p.xy)-r,abs(p.z)-h);}
float od (vec3 p , float d)
{return dot(p,normalize(sign(p)))-d;}
float width = 2.;
float cadre (vec3 p)
{
float b1 = box(p,vec3(width,width,0.1));
b1 = max(b1, -box(p,vec3(width*.8,width*.8,10.)));
return b1-0.05;
}
float frame (vec3 p)
{return box(p,vec3(width,width,0.01));}
float room (vec3 p)
{
return -box(p,vec3(8.,3.,1e10));
}
float columns (vec3 p)
{
float per = 8.;
p.z = mod(p.z,per)-per*0.5;
p.x = abs(p.x)-7.5;
return cyl(p.xzy, 0.5, 8.);
}
float g1 = 0.;
vec3 lionel_p;
float lionel_od(vec3 p)
{
p.z -= time;
p.z -=3.;
p.xz *= rot(time);
p.yz *= rot(time);
lionel_p = p;
float d = od(p, 2.);
g1 += 0.1/(0.1+d*d);
return d;
}
int mat_id;
vec3 sdf_p;
// sign distance function
float SDF (vec3 p)
{
p.z += time;
//p.xy *=rot(p.z*0.02);
float r = room(p);
float colu = columns(p);
float ld = lionel_od(p);
float per = 8.;
p.z = mod(p.z-per*0.5,per)-per*0.5;
p.x = abs(p.x)-7.5;
p.xz *= rot(PI/2.);
float fr = frame(p);
float ca = cadre(p);
float d = min(ld,min(stmin(r,colu,0.5,3.),min(ca,fr)));
if (d == fr) mat_id = 1;
if (d == ca || d == r || d == colu || d == ld) mat_id = 2;
sdf_p = p;
return d;
}
vec3 getcam (vec3 ro, vec3 tar, vec2 uv)
{
vec3 f = normalize(tar-ro);
vec3 l = normalize(cross(vec3(0.,1.,0.),f));
vec3 u = normalize(cross(f,l));
return normalize(f+l*uv.x+u*uv.y);
}
vec3 getnorm (vec3 p)
{
vec2 eps = vec2(0.1,0.);
return normalize(SDF(p)-vec3(SDF(p-eps.xyy),SDF(p-eps.yxy),SDF(p-eps.yyx)));
}
float lite (vec3 n, vec3 l)
{return dot(n,l)*0.5+0.5;}
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 ro = vec3(0.001,0.001,-8.),
p = ro,
tar = vec3(0.),
rd = getcam(ro,tar,uv),
l = normalize(vec3(0.,2.,-3.)),
col = vec3(0.);
float shad = 0.;
bool hit = false;
for (float i = 0.; i<ITER; i++)
{
float d = SDF(p);
if (d<0.001)
{
hit = true;
shad = i/ITER;
break;
}
p += d*rd;
}
float t =length(ro-p);
if (hit)
{
if (mat_id == 1) col = texturing(sdf_p.xy-vec2(1.6), karl, 0.3);
if (mat_id == 2) col = mix(vec3(0.5,0.01,0.), vec3(0.8,0.8,0.6),lite(getnorm(p),l));
col *= vec3(1.-shad);
}
col = mix(col,vec3(0.5,0.1,0.1), 1.-exp(-0.001*t*t));
col += g1* texturing(lionel_p.xy, lionel, 0.15);
out_color = vec4(col,1.);
}

29
2019-12-19/Koltes.frag Normal file
View File

@ -0,0 +1,29 @@
precision mediump float;
uniform float time;
uniform vec2 resolution;
mat2 rot(float a) {
float c=cos(a), s=sin(a);
return mat2(c, s, -s, c);
}
float xor(float a, float b) {
return (min(a + b, 1.) - a * b);
}
#define palette(a,b,c,d,t) (a+b*cos(6.283*(c*t+d)))
void main() {
vec2 uv = gl_FragCoord.xy / resolution.xy;
uv -= .5;
uv.x *= resolution.x / resolution.y;
float t = mod(time, 64.) / 8.;
uv *= rot((floor(t) + smoothstep(.95, 1., fract(t))) * 6.283 / 8.);
float mask = step(1., mod(uv.x*8. + time, 2.));
mask = xor(mask, step(1., mod(uv.y*8. + sin(time) * .2, 2.)));
vec3 color = palette(vec3(.5), vec3(.5), vec3(1.), vec3(0,1,2)/3., time + uv.x*2. + sin(uv.y*4.));
gl_FragColor = vec4(mask*color, 1.0);
}

270
2019-12-19/Nusan.glsl Normal file
View File

@ -0,0 +1,270 @@
#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
float time=0;
#define rot(a) mat2(cos(a),sin(a),-sin(a),cos(a))
#define rep(v,s) (fract((v)/s-0.5)-0.5)*s
float box(vec2 p, vec2 s) {
p=abs(p)-s;
return length(max(vec2(0),p)) + min(0.0,max(p.x, p.y));
}
float box(vec3 p, vec3 s) {
p=abs(p)-s;
return length(max(vec3(0),p)) + min(0.0,max(p.x, max(p.y,p.z)));
}
float sph(vec3 p, float r) {
return length(p)-r;
}
float cyl(vec2 p, float r) {
return length(p)-r;
}
float prog=0;
float voiture(vec3 p) {
vec3 p2=p;
vec3 p3=p;
float d = box(p, vec3(1.5,2.5,4));
p.y += 2.5;
d = min(d, max(cyl(p.xy, 1.5), abs(p.z)-4));
p.y = abs(p.y-1.5)-1.5;
d = min(d, box(p, vec3(1.6,0.1,4.1)));
p2.x = abs(p.x)-1.6;
p2.z = rep(p.z, 1.6);
p2.y += 1.4;
d = max(d, -box(p2, vec3(0.2,0.7,0.7)));
p3.z = abs(p3.z)-4;
p3.y += 1;
d = max(d, -box(p3, vec3(0.6,1.2,0.2)));
return d;
}
float roues(vec3 p) {
p.y -= 3;
p.x = abs(p.x)-1.8;
p.z = min(3+p.z,max(p.z-3,rep(p.z, 1.5)));
float d = abs(cyl(p.yz, 0.65))-0.1;
d = max(d, abs(p.x)-0.2);
p.yz *= rot(time * 4);
p.y=abs(p.y);
p.z=-abs(p.z);
p.yz *= rot(0.7);
p.y=abs(p.y);
p.z=-abs(p.z);
p.yz *= rot(0.4);
d = min(d, box(p, vec3(0.05,0.05,0.7)));
return d;
}
float rails(vec3 p) {
p.y += 0.2;
p.x=abs(p.x)-1.6;
float d=box(p.xy, vec2(0.1,0.2));
p.z = rep(p.z, 1.5);
d=min(d, box(p, vec3(2.0,0.1, 0.3)));
return d;
}
vec3 chemin(vec3 p) {
vec3 off=vec3(0);
off.x += sin(p.z * 0.04)*10;
off.x += sin(p.z * 0.023)*22;
off.y += sin(p.z * 0.03)*10;
return off;
}
// distance fonction
float voit = 0;
float sol=0;
float wat=0;
float map(vec3 p) {
vec3 p3=p;
p += chemin(p);
float h = texture(texNoise, p.xz * 0.01).x;
h *= 10 * clamp(abs(p.x)/20,0,1);;
vec3 p2 = p;
p.y += 4.2;
float tt=time*0.5;
float t2 = fract(tt);
t2 = smoothstep(0,1,t2);
t2 = smoothstep(0,1,t2);
t2 = pow(t2, 10);
p.z += (floor(tt) + t2) * 30 + time*3;
prog = p.z;
p.z = rep(p.z, 9.5);
voit=voiture(p);
float d = voit;
d=min(d, roues(p));
d=min(d, rails(p2));
sol=-p2.y - h + 0.3;
d=min(d, sol);
wat=-p3.y+5;
d=min(d, wat);
return d;
}
vec3 camera(vec2 uv, vec3 s, vec3 t, float fov) {
vec3 cz=normalize(t-s);
vec3 cx=normalize(cross(cz, vec3(0,1,0)));
vec3 cy=normalize(cross(cx, cz));
return normalize(uv.x*cx - uv.y*cy + fov*cz);
}
vec3 norm(vec3 p) {
vec2 off = vec2(0.01,0.0);
return normalize(map(p)-vec3(map(p-off.xyy), map(p-off.yxy), map(p-off.yyx)));
}
float shadow(vec3 p, vec3 r) {
float shad=1;
for(int i=0; i<30; ++i) {
float d=map(p);
shad=min(shad, d*10.0);
p+=d*r;
}
return clamp(shad,0,1);
}
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);
time=mod(fGlobalTime,300);
// camera position
vec3 s=vec3(0,0,-30);
s.yz *= rot(0.5);
s.xz *= rot(0.7+time*0.2);
// camera target
vec3 t=vec3(0,-7,10);
t.xz *= rot(time*0.3);
s.z += time * 8;
t.z += time * 8;
s -= chemin(s);
t -= chemin(t);
float fov = 0.5 + pow(smoothstep(-1,1,sin(time*10.0)),10)*0.2;
vec3 r = camera(uv, s, t, fov);
vec3 p=s;
float at=0;
float dd=0;
for(int i=0; i<100; ++i) {
float d=map(p) * 0.7;
if(d<0.001) {
if(wat>0.01) {
break;
}
d = 0.1;
r.y = -r.y;
r.x += (texture(texNoise, p.xz*0.03 + time*0.3).x-0.4)*0.5;
r=normalize(r);
}
if(dd>200) {
break;
}
p+=r*d;
dd+=d;
at += 0.1/(0.1+abs(d));
}
float issol=step(sol,0.01);
float isvoit=step(voit,0.01);
float iswat=step(wat,0.01);
float pp=floor(prog/9.5-0.5);
vec3 n=norm(p);
float fog = 1-clamp(dd/200,0,1);
vec3 col=vec3(0);
//col += at * 0.03 * vec3(1,0.5,0.3);
vec3 l=normalize(-vec3(1,2,3));
float shad=shadow(p + n * 0.2, l);
float ao = clamp(map(p+n*0.2)/0.2,0,1) * (clamp(map(p+n*2.0)/2.0,0,1)*0.5+0.5);
vec3 diff=vec3(0.7);
diff=mix(diff, vec3(0.5,1.0,0.5), issol);
vec3 cc=vec3(1,0.5,0.2);
float g=floor(pp);
cc.xy *= rot(g);
cc.xz *= rot(g*0.7);
cc=abs(cc);
diff=mix(diff, cc, isvoit);
col += max(0, dot(n,l)) * diff * shad * ao;
vec3 sky = mix(vec3(0.5,0.6,1)*0.8, vec3(1.0,0.5,0.2)*10.0 , pow(max(0,dot(l,r)), 3));
col += (-n.y*0.5+0.5) * diff * 1.2 * ao;
col *= fog;
col += pow(1-fog,3) * 1.1 * sky;
col *= 1.2-length(uv);
col = smoothstep(0,1,col*1.2);
col = pow(col, vec3(0.4545));
col *= 1;
out_color = vec4(col, 1);
}

18
2019-12-19/Readme.md Normal file
View File

@ -0,0 +1,18 @@
# Performances
On December 19th, 2019 on [Stream Reconductible](https://recondu.stream/).
## Slots
1. Shader: Flopine
Music: Psych Out
2. Shader: NuSan
Music: Koltes
3. Shader: Koltes
Music: Cyanide Dansen
## Software
- [Bonzomatic](https://github.com/Gargaj/Bonzomatic)
- [TidalCycles](https://tidalcycles.org/)
- [VEDA](https://veda.gl/)