From 84b825f173074616102ef59f33247fc06c83cdb1 Mon Sep 17 00:00:00 2001 From: Jonathan Giroux Date: Sat, 2 Jun 2018 21:45:50 +0200 Subject: [PATCH] Add 2018-05-25 --- 2018-05-25/01-anton.frag | 0 2018-05-25/01-leon.frag | 96 +++++++++++++++++++++++++ 2018-05-25/02-antoine.glsl | 144 +++++++++++++++++++++++++++++++++++++ 2018-05-25/02-lamogui.glsl | 114 +++++++++++++++++++++++++++++ 2018-05-25/03-lsdlive.glsl | 112 +++++++++++++++++++++++++++++ 2018-05-25/04-gwi.frag | 49 +++++++++++++ 2018-05-25/Readme.md | 3 + 7 files changed, 518 insertions(+) create mode 100644 2018-05-25/01-anton.frag create mode 100644 2018-05-25/01-leon.frag create mode 100644 2018-05-25/02-antoine.glsl create mode 100644 2018-05-25/02-lamogui.glsl create mode 100644 2018-05-25/03-lsdlive.glsl create mode 100644 2018-05-25/04-gwi.frag create mode 100644 2018-05-25/Readme.md diff --git a/2018-05-25/01-anton.frag b/2018-05-25/01-anton.frag new file mode 100644 index 0000000..e69de29 diff --git a/2018-05-25/01-leon.frag b/2018-05-25/01-leon.frag new file mode 100644 index 0000000..efe185c --- /dev/null +++ b/2018-05-25/01-leon.frag @@ -0,0 +1,96 @@ + +precision mediump float; + +uniform float time; +uniform vec2 resolution; + +#define repeat(p,r) (mod(p+r/2.,r)-r/2.) + +float sdSphere (vec3 p, float r) { return length(p) - r; } + +mat2 rot (float a) { float c = cos(a), s = sin(a); return mat2(c,-s,s,c); } + +float smin (float a, float b, float r) { + float h = clamp(.5+.5*(b-a)/r, 0., 1.); + return mix(b, a, h)-r*h*(1.-h); +} + +void amod (inout vec2 p, float c) { + float an = (3.1459*2.)/c; + float a = atan(p.y,p.x)+an/2.; + a = mod(a, an) - an/2.; + p = vec2(cos(a), sin(a)) * length(p); +} + +float map (vec3 pos) { + float scene = 1000.; +vec3 pp = pos; + pos.xz *= rot(time*.09554); + // pos.xz *= rot(pos.y * .5 + time); + pos.yz *= rot(time*.62468); + float smoo = .01; + const float count = 5.; + for (float i = count; i > 0.; --i) { + float r = i / count; + r = r * r; + pos = abs(pos) - 1.5 * r; + pos.xz *= rot(time*.94645); + pos.yz *= rot(time*.56546); + pos.xy *= rot(time*.31546); + vec3 p = pos; + // p.y = repeat(p.y + time, .4); + scene = smin(scene, sdSphere(p, .1), smoo); + // scene = smin(scene, max(abs(p.y)-.01, length(p.xz) - .1), smoo); + scene = min(scene, length(p.yz) - .02); + // scene = min(scene, length(p.yx) - .1); +} +scene = max(scene, -sdSphere(pp, 3.)); +float d = length(pp); +vec3 p = pp; +pp.xz *= rot(-time*1.798+d); +pp.yz *= rot(-time*1.698+d); +pp.yx *= rot(-time*1.398+d); +scene = min(scene, length(pp.xz)-.1*d); +scene = min(scene, length(pp.yz)-.1*d); +scene = min(scene, length(pp.yx)-.1*d); +pp = p; +pp.xz *= rot(pp.y + time / 4.); +pp.y = repeat(pp.y + time, .5); +amod(pp.xz, 5.); +pp.x -= 1. + .5 * sin(p.y + time / 2.); +scene = min(scene, sdSphere(pp, .1)); +scene = min(scene, length(pp.zy)- .02); + + + return scene; +} + +vec3 lookAt (vec3 eye, vec3 at, vec2 uv) { + vec3 forward = normalize(at - eye); + vec3 right = normalize(cross(forward, vec3(0,1,0))); + vec3 up = normalize(cross(right, forward)); + return normalize(forward * .3 + right * uv.x + up * uv.y); +} + +void main () { + vec2 uv = (gl_FragCoord.xy-.5*resolution.xy)/resolution.y; + vec3 eye = vec3(0,0,-2.+.5*sin(time*4.)); + vec3 ray = lookAt(eye, vec3(0), uv); + vec3 pos = eye; + float shade = 0.; + for (float i = 0.; i <= 1.; i += 1./100.) { + float dist = map(pos); + if (dist < .001) { + shade = 1.-i; + break; + } + // if (shade >= 1.) break; + // dist = max(.05, dist); + pos += dist * ray; + } + vec3 color = vec3(1.); + vec3 t = vec3(.1,.2,.3) * time + length(pos) / 2. + shade * 8.; + color = vec3(.5)+vec3(.5)*cos(t); + color *= shade; + gl_FragColor = vec4(color, 1); +} diff --git a/2018-05-25/02-antoine.glsl b/2018-05-25/02-antoine.glsl new file mode 100644 index 0000000..5218ed6 --- /dev/null +++ b/2018-05-25/02-antoine.glsl @@ -0,0 +1,144 @@ +#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 texKC; +uniform sampler2D texNoise; +uniform sampler2D texPegasus; +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 + +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 ); +} + +#define time fGlobalTime + +float sph(vec3 p, float r) { + + return length(p)-r; +} + +float cyl(vec2 p, float r) { + return length(p)-r; +} + +mat2 rot(float a) { + float co=cos(a); + float so = sin(a); + return mat2(co,so,-so,co); +} + +vec3 rep(vec3 p, vec3 s) { + + return (fract(p/s+.5)-0.5)*s; + +} + +float map(vec3 p, inout float v) { + + vec3 r1 = rep(p, vec3(10.0)); + + + + float d = sph(r1, 0.5); + + d = max(d, -cyl(p.xy,0.3)); + + for(int i=0; i<13; ++i) { + + float a = i * sin(time + cos(time)*0.3); + float j = sin( time*0.1)*1.0; + vec3 l =p + vec3(cos(a)*j,sin(a)*j, 0.2); + vec3 k =l; + k.xz *= rot(time*0.1); + + d = min(d, sph(k,0.0)); + + } + + v = 0.0; + + for(int i=0; i<13; ++i) { + + vec3 r2 = rep(p, vec3(5.0)); + vec3 sp = r2 + vec3(sin(time),0,0); + sp.xy *= rot(0.3 * sin(time*i + i *1243.5467)); + sp.yz *= rot(0.3 * sin(time*0.3*i + i *1243.5467)); + d = min(d, cyl(sp.xz,0.1)); + + + + } + + + return d; + +} + +vec3 norm(vec3 p) { + + + float v=0.0; + float base = map(p,v); + vec2 off = vec2(0.0,0.01); + + return normalize(vec3(base-map(p-off.yxx,v),base-map(p-off.xyx,v),base-map(p-off.xxy,v))); + +} + +vec3 march(vec3 ro, vec3 rd) { + + vec3 col = vec3(0.0); + + float e=0.0; + vec3 p = ro; + for(int i=0;i<200; ++i) { + + float v = 0.0; + float d = map(p,v); + + if(d<0.0001) { + + vec3 n = norm(p); + float lum = dot(n, normalize(-vec3(0.7)))*0.8+0.2; + float depth = length(p-ro); + col = vec3(10.0/(depth)); + + break; + } + + e += 0.0001/d; + + p+=d*rd; + } + + col += e * vec3(0.0,0.2,1.0);; + + return col; +} + +void main(void) +{ + vec2 uv = vec2(2.0*gl_FragCoord.x / v2Resolution.x - 1.0, 1.0-2.0*gl_FragCoord.y / v2Resolution.y); + uv.y *= v2Resolution.y / v2Resolution.x; + + vec3 ro = vec3(0,0,-3); + vec3 rd = normalize(vec3(uv, 1.0)); + vec3 col = march(ro,rd); + + + + out_color = vec4(col, 1.0); +} \ No newline at end of file diff --git a/2018-05-25/02-lamogui.glsl b/2018-05-25/02-lamogui.glsl new file mode 100644 index 0000000..0082160 --- /dev/null +++ b/2018-05-25/02-lamogui.glsl @@ -0,0 +1,114 @@ +#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 bass; + +float megabass() +{ + float b = 0.0; + for (int i = 0; i < 16; i++) + b = max(texelFetch(texFFTIntegrated, i, 0).x, b); + return b; +} + +float cyl(vec3 p, float r, float h) +{ + return max(length(p.xz) - r, abs(p.y) - h); +} + +float bou(vec3 p) +{ + float d = cyl(p, 0.5, 0.5); + return min(d, cyl(p - vec3(0.0, 0.8, 0.0), 0.2, 0.3)); +} + +mat2 rot(float a) +{ + float c = cos(a); + float s = sin(a); + return mat2(c, s, -s, c); +} + +int prout; + +float map(vec3 p) +{ + vec3 per = vec3(3.0); + ivec3 id = ivec3(p/per); + vec3 q = mod(p, per) - 0.5 * per; + q .y += 0.5 * sin(float(p.z)); + q.xy *= rot(float(id.x * 0.2561 + id.y + id.z) + bass); + q.yz *= rot(float(id.x * 0.2561 + id.y + id.z) + bass); + + prout = id.x + id.y +id.z; + float d = bou(q); + + return d; +} + +vec3 grad(vec3 p) +{ + vec2 e = vec2(0.001, 0.0); + return normalize(vec3(map(p+e.xyy) - map(p-e.xyy), map(p+e.yxy) - map(p-e.yxy), map(p+e.yyx) - map(p-e.yyx))); +} + +vec3 rm(vec3 ro, vec3 rd) +{ + vec3 p = ro; + for (int i = 0; i < 364; ++i) + { + float d = map(p); + if (abs(d) < 0.01) + { + break; + } + p += rd * 0.9 * d; + } + return p; +} + +vec3 shade(vec3 p, vec3 ro, vec3 n) +{ + return vec3(exp(-distance(ro, p) * 0.1)) * vec3(cos(float(prout) + bass * 0.1), sin(float(prout) + bass * 0.1), 1.0); //* (n * 0.5 + 0.5); +} + +void main(void) +{ + bass = megabass(); + 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.0, 0.0, bass * 5.0); + vec3 rd = normalize(vec3(uv, normalize(length(uv)) - 0.6)); + + rd.xz *= rot(0.1 * bass); + + vec3 p = rm(ro, rd); + vec3 n = grad(p); + vec3 color = shade(p, ro, n); + + vec3 rd2 = reflect(rd, n); + vec3 ro2 = p + rd * 0.01; + + vec3 p2 = rm(ro2, rd2); + vec3 n2 = grad(p2); + + color = mix(color, shade(p2, ro, n2), 0.9); + color = pow(color, vec3(1.0 / 2.2)); + out_color = vec4(color, 1.0); +} \ No newline at end of file diff --git a/2018-05-25/03-lsdlive.glsl b/2018-05-25/03-lsdlive.glsl new file mode 100644 index 0000000..a2f1b72 --- /dev/null +++ b/2018-05-25/03-lsdlive.glsl @@ -0,0 +1,112 @@ +#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 + +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 ); +} + + +#define time fGlobalTime + +mat2 r2d(float a){float c=cos(a),s=sin(a);return mat2(c,s,-s,c);} + +float re(float p,float d){return mod(p-d*.5,d)-d*.5;} + +void amod(inout vec2 p,float d){float a=re(atan(p.x,p.y),d);p=vec2(cos(a),sin(a))*length(p);} + +float sc(vec3 p,float d){ +p=abs(p); +p=max(p,p.yzx); +return min(p.x,min(p.y,p.z))-d; +} + +void mo(inout vec2 p,vec2 d){ +p.x=abs(p.x)-d.x; +p.y=abs(p.y)-d.y; +if(p.y>p.x)p.yx=p; +} + +float g=0.; +float de(vec3 p){ +float t=time*4.; +//p.y+=.5; +float s=t*.1+sin(t)*.1; + + +p.xy*=r2d(time);//.77+s*2.5); + +//p.xz*=r2d(.77+s*2.5); +//p.xy*=r2d(.77+s*2.5); + +p.xy*=r2d(p.z*.1); + +p.z=re(p.z,2); + +amod(p.xy,6.28/5.); + +mo(p.xz,vec2(.3, 1.3)); +mo(p.xy,vec2(2.2, 1.5+sin(.77+t*.5)*.2)); + +float sc2 =sc(p,1.3); + +amod(p.xy,6.28/3.4); + + + +mo(p.xy,vec2(1.3, .2)); + +//p.x=abs(p.x)-1; +//p.y=abs(p.y)-1; + +float d= sc(p,.4); + +d=max(d,-sc2); + +g+=.01/(.02+d*d); +return d; +return dot(p,normalize(sign(p)))-.6; +} + + +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,0,-3+time*4); +vec3 rd=normalize(vec3(uv,1)); + +float t=0,i=0; +vec3 p; +for(;i<1;i+=.01){ +p=ro+rd*t; +float d=de(p); +//if(d<.001)break; +d=max(abs(d),.02); +t+=d*.4; +} + +vec3 c =mix(vec3(.7,.3,.4),vec3(.1,.4,.2),uv.x+i); +c+=g*.02; +c.r+=sin(p.z)*.3; +c=mix(c,vec3(.2,.1,.2),1-exp(-.01*t*t)); +c*=1.2; + out_color = vec4(c,1); +} \ No newline at end of file diff --git a/2018-05-25/04-gwi.frag b/2018-05-25/04-gwi.frag new file mode 100644 index 0000000..e39afc0 --- /dev/null +++ b/2018-05-25/04-gwi.frag @@ -0,0 +1,49 @@ + +precision mediump float; + +uniform float time; +uniform vec2 resolution; + +float sdSphere (vec3 p, float r) { return length(p) - r; } + +float sdCube(vec3 p, float r) { return min(abs(p.x - 0.5) * mod(time, 0.2), abs(p.y - 0.5) * mod(time, 0.6)); } + +float map (vec3 pos) { + float scene = 1000.; + scene = min(scene, sdCube(pos, 0.4)); + return scene; +} + +vec3 lookAt (vec3 eye, vec3 at, vec2 uv) { + vec3 forward = normalize(at - eye); + vec3 right = normalize(cross(forward, vec3(0,1,0))); + vec3 up = normalize(cross(right, forward)); + return normalize(forward + right * uv.x + up * uv.y); +} + +void main () { + vec2 uv = (gl_FragCoord.xy-.5*resolution.xy)/resolution.y; + vec3 eye = vec3(0,1,-3); + vec3 ray = lookAt(eye, vec3(0), uv); + vec3 pos = eye; + float shade = 0.; + for (float SpherePos = -0.8; SpherePos < 0.8; SpherePos += 0.2) + { + for (float i = 0.; i <= 1.; i += 1./60.) { + float dist = sdCube(pos, 0.5); + dist = dist * sdSphere(pos, 0.1); + //dist += sdSphere(pos, 0.8); + pos += mod(time, 0.2); + dist += sdSphere(vec3(0.9, 0., 0.) + pos, 0.5); + if (dist < .001) { + shade = 1.-i; + break; + } + pos += dist * ray; + } + } + + vec3 color = vec3(mod(time, 1.), mod(time, 0.1), mod(time, 0.3)); + color *= shade; + gl_FragColor = vec4(color, 1); +} diff --git a/2018-05-25/Readme.md b/2018-05-25/Readme.md new file mode 100644 index 0000000..92b764c --- /dev/null +++ b/2018-05-25/Readme.md @@ -0,0 +1,3 @@ +# Cookie Showdown #8 + +On May 25th, 2018 at [Mains d’Œuvres](https://www.mainsdoeuvres.org/).