diff --git a/2019-10-26/01-anat.glsl b/2019-10-26/01-anat.glsl new file mode 100644 index 0000000..31f0fd8 --- /dev/null +++ b/2019-10-26/01-anat.glsl @@ -0,0 +1,128 @@ +#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 saturate(x) clamp(x, 0., 1.) + +float box(vec3 p) { + vec3 q = abs(p) - .3; + return length(max(q,0.)) + min( max(q.x, max(q.y,q.z)), 0.); +} +float map(vec3 p) { + vec3 pp = p; + p = mod(p,1.)-.5; + float d = box(p); + d = max(d, pp.y+1.); + return d; +} + +float rand(float s) { + return fract(sin(s)*42358.); +} + +vec3 albedo(vec3 p) { + vec2 id = floor(p.xz); + + vec3 c = vec3(0.); + c += vec3(.5,.4,1.) * saturate( cos(length(id)+fGlobalTime*3.) *2.-1.); + + if ( mod(fGlobalTime,10.) > 5.) + c = vec3(.2,.7,1.) * saturate(rand(id.x+rand(id.y)+floor(fGlobalTime*6.))*9.-8.); + + c *= rand(id.x + rand(id.y))*5.; + c *= step(0.3, 1.-abs(p.y+1.)); + return c; + + +} + + +vec3 normal(vec3 p) { + vec2 eps = vec2(0.01, 0.); + float d = map(p); + return normalize(vec3(d-map(p-eps.xyy),d-map(p-eps.yxy),d-map(p-eps.yyx))); +} + + +mat2 rot(float v) { + float a = cos(v); + float b = sin(v); + return mat2(a,b,-b,a); +} + +void camPath(inout vec3 ro, inout vec3 rd) { + float t = mod(fGlobalTime, 50.); + if(t < 10. ) { + ro = vec3(t*6.-50.,10., -20.); + rd.yz = rot(.6) * rd.yz; + } else if (t < 20.) { + ro = vec3(0.,4.+cos(t*.5)*4., t*10.); + rd.xy = rot(t*.1) * rd.xy; + rd.xz = rot(t*.01) * rd.xz; + rd.yz = rot(.3) * rd.yz; + } else if(t<40.) { + + ro = vec3(0.,1., t*1.); + rd.xy = rot(+t*.1) * rd.xy; + rd = -abs(rd); + rd.xz = rot(-t*.1) * rd.xz; + rd = -abs(rd); + rd.yz = rot(-t*.1) * rd.yz; + rd = -abs(rd); + rd.xz = rot(t*.05) * rd.xz; + rd = -abs(rd); + } else { + + ro = vec3(1.,-2., -t*1.); + rd.yz = rot(-.25) * rd.yz; + rd = -abs(rd); + rd.xy = rot(t*.5) * rd.xy; + } +} + +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.,2., -15.); + vec3 rd = normalize(vec3(uv, 2.-length(uv)*.3)); + camPath(ro,rd); + + vec3 p = ro; + for(int i=0; i<256; i++) { + p += rd * map(p); + } + vec3 n = normal(p); + vec3 col = vec3(0.); + col += vec3(1.) * abs(n.y)*.01; + col += albedo(p)*5.; + col += albedo(p+n) * 10. *exp( -length(fract(p)*2.-1.)*4.); + + col = mix(col, vec3(0.), saturate(length(p-ro)*0.03)); + + vec2 q = uv *.5+.5; + col *= pow( q.x*q.y*(1.-q.x)*(1.-q.y)*10., 0.25)*1.5; + col = pow(col, vec3(.4545)); + out_color = vec4(col,1.); +} \ No newline at end of file diff --git a/2019-10-26/01-flopine.glsl b/2019-10-26/01-flopine.glsl new file mode 100644 index 0000000..663c698 --- /dev/null +++ b/2019-10-26/01-flopine.glsl @@ -0,0 +1,129 @@ +#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 = fGlobalTime; +float PI = 3.141592; + +float BPM = 70./60.; + +float hash21(vec2 x) +{return fract(sin(dot(x,vec2(12.4,13.4)))*12124.4);} + +void moda(inout vec2 p, float rep) +{ + float per = 2.*PI/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; + + } + + mat2 rot(float a) + {return mat2(cos(a),sin(a),-sin(a),cos(a));} + + 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 cyl (vec2 p, float r) +{return length(p)-r;} + +float od (vec3 p, float d) +{ + p.xz *= rot(time); + return dot(p,normalize(sign(p)))-d; + } + +float tunnel (vec3 p) +{ + p.x += texture(texNoise, p.yz*0.15+vec2(0.,time)).r*0.9; + p.y += texture(texNoise, p.xz*0.1+vec2(0.,time)).r; + + return -cyl(p.xy, 6.); + } + + float g1 =0.; + float jelly (vec3 p) + { + + p.x += mix(0.,-0.5+hash21(p.yz),exp(-fract(time*BPM)*8.)*6.); + p.y += mix(0.,-0.5+hash21(p.xz),exp(-fract(time*BPM)*8.)*6.)*0.5; + + p.y += sin(p.z*0.5+time); + + moda(p.xy, 3.); + p.x -= 2.5; + + p.xy *=rot(p.z*0.5+time); + moda(p.xy, 3.); + p.x -= 1.3; + + p.z -= 5.; + p.yz *= rot(PI/2.); + + float o = od(p, .5); + p.y += 2.; + p.xz *= rot(sin(p.y+time)); + moda(p.xz, 8.); + p.x -=.4; + float d = stmin(o,max(cyl(p.xz, 0.04+p.y*0.1),abs(p.y)-1.5),0.4, 4.); + g1 += 0.1/(0.1+d*d); + return d; + } + + float SDF (vec3 p) + { + return min(jelly(p),tunnel(p)); + } + +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); + +float dither = hash21(uv); + +vec3 ro = vec3(0.001,0.001,-5.), + p = ro, + rd = normalize(vec3(uv,1.)), + col = vec3(0.); + + float shad = 0.; + + for (float i=0.; i<64.; i++) + { + float d = SDF(p); + if (d<0.001) + { + shad = i/64.; + break; + } + d *= 0.8+dither*0.1; + p+=d*rd; + } + + float t= length(ro-p); + col = vec3(shad); + col += g1*vec3(0.5,0.4,0.)*0.3; + col = mix(col, vec3(0.,0.4,0.6)*0.3, 1.-exp(-0.005*t*t)); + out_color = vec4(sqrt(col),1.); +} \ No newline at end of file diff --git a/2019-10-26/02-LJ.glsl b/2019-10-26/02-LJ.glsl new file mode 100644 index 0000000..74c585c --- /dev/null +++ b/2019-10-26/02-LJ.glsl @@ -0,0 +1,48 @@ +#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 +#define time fGlobalTime +mat2 r2d(float a){float sa=sin(a),ca=cos(a);return mat2(ca,sa,-sa,ca);} +vec2 amod(vec2 p,float a){a=mod(atan(p.x,p.y),a)-a*.5;return vec2(cos(a),sin(a))*length(p);} +float so(vec3 p){return dot(p,normalize(sign(p+1e-6)));} +float map( vec3 p) { + vec3 o=p; + + p.z=mod(p.z,4.)-2.; + p.xy*=r2d(time*sign(mod(o.z,8.)-4.)); + //p.x=max(abs(p.x)-.5,0.)-1.; + p.yx=amod(p.xy,.5); + p.y=max(abs(p.y)-1.,0.); + p.z=max(abs(p.z)-.5,0.)-.5; + for(int i=0;i<5;i++) + p=max(abs(p)-vec3(.0,.1-sin(o.z*.1)*.2,-.1),0.)-vec3(.2,.2,.5),p.xy*=r2d(.4),p.xz*=r2d(.7); + return max(so(p)-.15-texture(texFFTSmoothed,.05).r*10.,-so(max(abs(o.xyy)-sin(32.+o.z*.07)*.1,0.))+1.);-max(-o.y-1.,0.); + +} +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); + if(fract(time*.2)<.5)uv=abs(amod(uv,2.09)),uv.x=abs(uv.x)-texture(texFFTSmoothed,.02).r*10.; + uv.x+=texture(texTex2,uv.yy*100.).r*texture(texFFT,.5).r; + vec2 p=uv; + vec3 ro=vec3(0,.0,-time*2.-texture(texFFTIntegrated,.22).r*25.),rd=normalize(vec3(2*p*r2d(texture(texFFTIntegrated,.1).r*5.),-1.-texture(texFFT,.01).r*2.)),mp; + float md;mp=ro;int ri; + for(int i=0;i<100;i++)if(ri=i,mp+=rd*(md=map(mp)),md<.001)break; + + out_color = vec4(float(ri)/100.)*mix(vec4(.4,.5,.7,1),vec4(.7,.5,.3,1),length(uv)+texture(texNoise,uv+time).r)*2.; +} \ No newline at end of file diff --git a/2019-10-26/02-evvvvil.glsl b/2019-10-26/02-evvvvil.glsl new file mode 100644 index 0000000..f9de8a2 --- /dev/null +++ b/2019-10-26/02-evvvvil.glsl @@ -0,0 +1,115 @@ +#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; +//evvvvil +layout(location = 0) out vec4 out_color; // out_color must be written in order to see anything +vec2 s,v,e=vec2(.00035,-.00035);float t,tt,g,bb,mm,noi;vec3 po,no,al,ld; +vec4 np,c=vec4(0,0,14,0.2); +float bo(vec3 p,vec3 r){p=abs(p)-r;return max(max(p.x,p.y),p.z);} +mat2 r2(float r){ return mat2(cos(r),sin(r),-sin(r),cos(r));} +float smin(float a,float b,float h){ + float k=clamp((a-b)/h*.5+.5,0.,1.); + return mix(a,b,k)-k*(1-k)*h; + + } + vec2 smin2(vec2 a,vec2 b,float h){ + float k=clamp((a.x-b.x)/h*.5+.5,0.,1.); + return mix(a,b,k)-k*(1-k)*h; +} + vec2 syn( vec3 p) +{ + p.x-=sin(p.y*15+tt*10)*0.03; + noi=texture(texNoise,vec2(.1,.2)*vec2(p.y,dot(p.xz,vec2(.7)))).r; + bb=cos(p.y*.25+tt*2)*.5+.5; + float h,t=length(p.xz-(sin(p.xz*1.5-tt)*.5+cos(p.y*2+noi*5-tt)*.3))-(1+bb*2); + p=abs(p)-(1+bb*2); + p.xy*=r2(-.5); + p.yz*=r2(.5); + p+=cos(p.y)*.2; + h=length(p.xz)-(.4+.3*sin(p.y*.5+noi*3)+.3*(.5+.5*sin(p.y*2-tt*3))); + t=smin(t,h,.5); + return vec2(t*.5,bb); +} +vec2 mp( vec3 p) +{ + np=vec4(p,1); + mm=sin(tt-p.y*.5)*2; + vec2 h,t=syn(p); + for(int i=0;i<2;i++){ + np*=2; + np.xyz=abs(np.xyz)-vec3(8.5+mm,8.5,8.5+mm); + np.xy*=r2(-.4); + np.yz*=r2(.2); + h=syn(np.xyz); + h.x/=np.w; + t=smin2(t,h,0.5); + } + np.xz*=r2(.785); + h=vec2(bo(abs(np.xyz)-3.*mm,vec3(0,100,0)),1.); + g+=0.1/(0.1+h.x*h.x*.2); + h.x=h.x*0.7/np.w; + t=t.x30) break; + t.x+=h.x;t.y=h.y; + } + if(t.x>30) t.x=0; + return t; + +} +#define a(d) clamp(mp(po+no*d).x/d,0.,1.) +#define s(d) smoothstep(0.,1.,mp(po+ld*d).x/d) +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); + tt=mod(fGlobalTime,62.83); + vec3 ro=vec3(cos(tt*c.w+c.x)*c.z,-5+cos(tt*.2)*5,sin(tt*c.w+c.x)*c.z), + cw=normalize(vec3(0,sin(tt*.4)*10,0)-ro), + cu=normalize(cross(cw,vec3(0,1,0))), + cv=normalize(cross(cu,cw)), + rd=mat3(cu,cv,cw)*normalize(vec3(uv,.5)),co,fo; + ld=normalize(vec3(.1,.3,0)); + v=vec2(abs(atan(rd.x,rd.z)),rd.y); + co=fo=vec3(.2)+texture(texNoise,v*.4).r*.5;; + + s=tr(ro,rd);t=s.x; + + if(t>0){ + po=ro+rd*t; + no=normalize(e.xyy*mp(po+e.xyy).x+ + e.yyx*mp(po+e.yyx).x+ + e.xxx*mp(po+e.xxx).x+ + e.yxy*mp(po+e.yxy).x); + al=mix(vec3(.3,.6,.9),vec3(.6,.3,.2),bb*3); + float dif=max(0,dot(no,ld)), + fr=pow(1+dot(no,rd),4), + sp=pow(max(dot(reflect(-ld,no),-rd),0),30); + co=mix(sp+al*(a(.2)*a(.4)+.2)*(dif+s(.4)+s(2)),fo,min(fr,.5)); + co=mix(fo,co,exp(-.0002*t*t*t));//fog + } + + out_color = vec4(pow(co+g*0.1,vec3(.45)),1); +} \ No newline at end of file diff --git a/2019-10-26/03-LJ.glsl b/2019-10-26/03-LJ.glsl new file mode 100644 index 0000000..866919a --- /dev/null +++ b/2019-10-26/03-LJ.glsl @@ -0,0 +1,60 @@ +#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 +#define time fGlobalTime +mat2 r2d(float a){float sa=sin(a),ca=cos(a);return mat2(ca,sa,-sa,ca);} +float sc(vec3 p){ + vec3 a=abs(p);return min(min(max(a.x,a.y),max(a.y,a.z)),max(a.x,a.z)); +} +vec2 amod(vec2 p,float a){a=mod(atan(p.x,p.y),a)-a*.5;return vec2(cos(a),sin(a))*length(p);} +float rand(float a){return fract(sin(a)*32163.52131);} +float map(vec3 p){ +/* vec3 o=p; + p.xy=p.xy=amod(p.xy,radians(120)*sin(o.z*.1)),p.x+=.2; + p=mod(p,1)-.5; + return sc(p)-.01; + */ + vec3 o=p; + vec3 w=p; + w.x=abs(w.x)-3.-rand(floor(w.z*.25)); + w.z=mod(w.z,4.)-2.; + w.xy*=r2d(o.z*.1); + w=abs(w); + float h=0; + if(p.y<1) + h=+texture(texNoise,p.xz*.1+texture(texNoise,p.xz*.5+time*.02).g*.1).r+texture(texNoise,p.xz*.02).g*5.; + return min(min(p.y+h,length(p.xy+vec2(0,-1))-.1-sin(time+p.z*3.)*cos(p.z*.2)*.05),(max(w.x,w.z)-.1)*.5); + +} +vec2 p; +float render(float o){ + float g=time*2.,a=floor(g)+pow(fract(g),5.); + vec3 ro=vec3(p*r2d(-length(p))+o+vec2(0,.2),-time*7.-a*5.),rd=normalize(vec3(p*r2d(time*.1),-1)),mp; + float md;mp=ro;int ri; + for(int i=0;i<70;i++)if(ri=i,mp+=rd*(md=map(mp)),md<.01)break; + return float(ri)/70.; +} +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); + + p=uv; + + float a=.02; + out_color = vec4(vec3(1,0,0)*render(a)+vec3(0,1,1)*render(-a),1); +} \ No newline at end of file diff --git a/2019-10-26/03-anat.glsl b/2019-10-26/03-anat.glsl new file mode 100644 index 0000000..7d3fbd9 --- /dev/null +++ b/2019-10-26/03-anat.glsl @@ -0,0 +1,126 @@ +#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 saturate(x) clamp(x, 0., 1.) + +float fbm(vec2 p) { + float d = texture(texNoise,p).r * .5; + d += texture(texNoise,p*2.).r * .25; + return d; + } + + float water(vec3 p) { + return p.y + texture(texNoise, p.xz*.1+vec2(0.,fGlobalTime*.1)).r*.2+ texture(texNoise, p.xz*.1+vec2(0.,-fGlobalTime*.01)).r*.125 +1.5; + } +float map(vec3 p) { + float d = -(length(p.xy)-2.); + d = max(d, p.y-1.); + p.z = mod(p.z, 20.)-10.; + d = min(d, length(p.yz+vec2(-1.5+sin(p.x*.5+5.),0.))-2.); + d += fbm(p.xz*.1)*3.; + d = min(d, water(p)); + return d; +} + + +vec3 raymarch(vec3 ro, vec3 rd) { + vec3 p = ro; + for(int i=0; i<32; i++ ) { + p += rd * map(p)*1.3; + } + + return p; +} + + vec3 ld = normalize(vec3(cos(fGlobalTime),.4,1.)); + +vec3 sky(vec3 rd) { + vec3 c = pow( vec3(.3,.5,1.), vec3(rd.y*2.)); + c += vec3(1.,.7,.3) / (1.+length(rd-ld)*200.)*20.; + return c; +} + +vec3 normal(vec3 p) { + float d = map(p); + vec2 eps = vec2(0.01, 0.); + return normalize(vec3(d-map(p-eps.xyy),d-map(p-eps.yxy),d-map(p-eps.yyx))); +} +float shadow(vec3 ro, vec3 ld) { + vec3 p = ro; + for(int i=0; i<8; i++) { + p += map(p) * ld; + } + return step(.5, length(p-ro)); +} + +mat2 rot(float v) { + float a = cos(v); + float b = sin(v); + return mat2(a,b,-b,a); +} + +float rand(float v) { + return fract(sin(v)*42358.); +} + +vec3 shade(vec3 ro, vec3 rd, vec3 p, vec3 n) { + + vec3 col = vec3(0); + float shad = shadow(p, ld); + col += vec3(1.,.7,.3) * max(dot(n,ld), 0.)*.2 * shad; + + col += vec3(.7,.3,1.) *3.* saturate(rand(floor(p.z)+floor(fGlobalTime*3.))*9.-8.); + col = mix(col, sky(rd), saturate( length(p-ro) * .01)); + + return col; +} + +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.,-1.,fGlobalTime*3.); + vec3 rd = normalize(vec3(uv, 1.)); + + vec3 rdd = rd; + rd.xy = rot(fGlobalTime*.1) * rd.xy; + rd.yz = rot(fGlobalTime*.05) * rd.yz; + rd = -abs(rd); + rd.xy = rot(fGlobalTime*.05) * rd.xy; + rd = -abs(rd); + rd = mix(rd, rdd, cos(fGlobalTime*.21)*.3+.7); + vec3 p = raymarch(ro,rd); + vec3 n = normal(p); + vec3 col = shade(ro,rd, p, n); + + if(water(p)- map(p) < 0.01) { + rd = reflect(rd,n); + p = raymarch(p+rd*.1,rd); + col = vec3(.1,.7,1.) * shade(ro,rd,p,n); + } + + col = pow(col, vec3(.4545)); + out_color = vec4(col, 1.); +} \ No newline at end of file diff --git a/2019-10-26/04-evvvvil.glsl b/2019-10-26/04-evvvvil.glsl new file mode 100644 index 0000000..507c83d --- /dev/null +++ b/2019-10-26/04-evvvvil.glsl @@ -0,0 +1,105 @@ +#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 +vec2 s,v,e=vec2(.00035,-.00035);float t,tt,g,d01;vec3 np,pp,bp,al,po,no,ld; +vec4 c=vec4(0,5,10,0.2); +float bo(vec3 p,vec3 r){p=abs(p)-r;return max(max(p.x,p.y),p.z);} +mat2 r2(float r){return mat2(cos(r),sin(r),-sin(r),cos(r));} +vec2 ball( vec3 p,float d,float mm,float mul,float bro) +{ + p.z=mod(p.z+tt*10,30)-15; + bp=p*.28;p*=bro; + d01=d*.5+.5; + vec2 h,t=vec2(length(p)-5,3); + t.x=max(t.x,-bo(p,vec3(2.8*mul))); + t.x=min(t.x,length(p)-2*mul); + t.x=abs(t.x)-.3; + pp=p;pp.xy*=r2(sin(p.z*.2)+tt*(2-d01)*d)*(mul*.5+.5); + t.x=max(t.x,bo(abs(abs(p)-vec3(0,0,2))-vec3(0,0,1),vec3(10,3,.6))); + np=p; + np.xy*=r2(mix(tt,1.59+sin(tt*.5),d01)*d); + t.x=max(t.x,np.x); + + h=vec2(length(p)-5,mm); + h.x=max(h.x,-bo(p,vec3(2.8*mul))); + h.x=min(h.x,length(p)-2*mul); + h.x=abs(abs(h.x)-.1)-.05; + h.x=max(h.x,bo(abs(abs(p)-vec3(0,0,2))-vec3(0,0,1),vec3(10,4,.7))); + h.x=max(h.x,np.x); + t=mix(t,h,step(h.x,t.x)); + t/=bro*1.5; + return t; +} +vec2 mp( vec3 p) +{ + vec2 h,t=ball(p,-1,6,1,1); + h=ball(p,1,5,1,.28); + t=mix(t,h,step(h.x,t.x)); + h=ball(p,-1,6,-1,.19); + t=mix(t,h,step(h.x,t.x)); + h=vec2(length(p.xy)-.5,3); + t=mix(t,h,step(h.x,t.x)); + pp=bp;pp.xy*=r2(-tt+sin(pp.z)); + h=vec2(bo(pp,vec3(30,0.001,0.01)),6); + g+=0.1/(0.1+h.x*h.x*40); + t=mix(t,h,step(h.x,t.x)); + return t; +} +vec2 tr( vec3 ro,vec3 rd ) +{ + vec2 h,t=vec2(.1); + for(int i=0;i<128;i++){ + h=mp(ro+rd*t.x); + if(h.x<.0001||t.x>120) break; + t.x+=h.x;t.y=h.y; + } +if(t.x>120) t.x=0; + return t; +} +float a(float d){return clamp(mp(po+no*d).x/d,0.,1.);} +float ss(float d){return smoothstep(0.,1.,mp(po+ld*d).x/d);} +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); +tt=mod(fGlobalTime,62.83); + vec3 ro=vec3(cos(tt*.5)*3,16+sin(tt)*3,-10), + cw=normalize(vec3(0)-ro), + cu=normalize(cross(cw,vec3(0,1,0))), + cv=normalize(cross(cu,cw)), + rd=mat3(cu,cv,cw)*normalize(vec3(uv,.5)),co,fo; + ld=normalize(vec3(.4,.7,-.2)); + co=fo=vec3(.3); + s=tr(ro,rd);t=s.x; + if(t>0){ + po=ro+rd*t; + no=normalize(e.xyy*mp(po+e.xyy).x+ + e.yyx*mp(po+e.yyx).x+ + e.yxy*mp(po+e.yxy).x+ + e.xxx*mp(po+e.xxx).x); + al=mix(vec3(.25,.5,.0),vec3(0,.2,.3),min(length(bp)-2.5,1)); + + float dif=max(0,dot(no,ld)), + spo=20, + fr=pow(1+dot(no,rd),4), + sp=pow(max(dot(reflect(-ld,no),-rd),0),spo); + co=mix(sp+al*(a(.2)*a(.4)+.2)*(dif+ss(.4)+ss(2)),fo,min(fr,.2)); + co=mix(fo,co,exp(-.00001*t*t*t)); + } + + out_color = vec4(pow(co+g*.3,vec3(.45)),1); +} \ No newline at end of file diff --git a/2019-10-26/04-flopine.glsl b/2019-10-26/04-flopine.glsl new file mode 100644 index 0000000..5ddd781 --- /dev/null +++ b/2019-10-26/04-flopine.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 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 hr vec2(1., sqrt(3.)) +#define hdetail 5. +#define vdetail 15. +#define time fGlobalTime +#define PI 3.141592 + + +vec2 hash22 (vec2 x) +{return fract(sin(vec2(dot(x,vec2(23.4,15.1)),dot(x,vec2(12.4,56.4))))*124.5);} + +float hash21 (vec2 x) +{return fract(sin(dot(x,vec2(12.4,15.65)))*1245.21);} + +vec3 voro (vec2 uv) +{ + uv *= vdetail; + vec2 uv_id = floor(uv); + vec2 uu = fract(uv); + + vec2 m_point, m_nei,m_diff; + float m_dist = 10.; + + for (int i=-1; i<=1;i++) + { + for (int j=-1; j<=1;j++) + { + vec2 nei = vec2(float(i),float(j)); + vec2 point = hash22(nei + uv_id); + point = 0.5+0.5*sin(2.*PI*point+time); + vec2 diff = nei + point - uu; + float dist = length(diff); + if (dist < m_dist) + { + m_point = point; + m_nei = nei; + m_dist = dist; + m_diff = diff; + } + + } + } + return vec3(m_point, m_dist); + } + +float hdist (vec2 uv) +{ + uv = abs(uv); + return max(uv.x, dot(uv, normalize(hr))); + } + + vec4 hgrid (vec2 uv) +{ + uv *= hdetail; + vec2 ga = mod(uv, hr)-hr*0.5; + vec2 gb = mod(uv-hr*0.5, hr)-hr*0.5; + + vec2 guv = (dot(ga,ga) < dot(gb,gb))? ga : gb; + + vec2 id = uv-guv; + + guv.y = 0.5-hdist(guv); + + return vec4 (guv,id); + } + + vec3 blue_grid(vec2 uv) + { + vec3 v = voro(uv); + return clamp(vec3(hash22(v.xy).r,hash22(v.xy).y, 1.),0.,1.); + } + + vec3 frame(vec2 uv) + { + vec4 hg = hgrid(uv); + return blue_grid(uv)*step(0.05, hg.y); + } + + mat2 rot(float a) + {return mat2(cos(a),sin(a),-sin(a),cos(a));} + + float od (vec3 p, float d) + {return dot(p,normalize(sign(p)))-d;} + + float g1 = 0.; + float SDF (vec3 p) + { + p.xz *= rot(time); + p.yz *= rot(time); + p.x -= sin(time); + float d = od (p, 1.); + g1 += 0.1/(0.1+d*d); + return d; + } + + +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,-7.), + p = ro, + rd = normalize(vec3(uv,1.)), + col = vec3(0.01); + + float shad = 0.; + + for (float i=0.; i<64.; i++) +{ + float d = SDF(p); + if (d<0.001) + { + shad = i/64.; + break; + } + + p += d*rd; + } + + col = vec3(1.-shad); + col *= g1; + col *= frame(uv); + + + out_color = vec4(col,1.); +} \ No newline at end of file diff --git a/2019-10-26/Readme.md b/2019-10-26/Readme.md new file mode 100644 index 0000000..d503f1d --- /dev/null +++ b/2019-10-26/Readme.md @@ -0,0 +1,41 @@ +# Shader Showdown @ Cookie Party 2019 + +On October 26th, 2019 during the [Cookie Party](http://cookie.paris/) at [Au Landi Sauvage](https://www.facebook.com/clossauvage/). + +Evvvvvil is selected to participate to the Grand Final at Revision 2020! + +Thanks to Havoc for judging the Shader Showdown. + +## Rounds + +1. Anat vs Flopine +2. Evvvvil vs LJ +3. Anat vs LJ (Third place playoff) +4. Evvvvil vs Flopine (Final) + +## Tournament view + +``` +Main Tournament: + +Anat ---- + } Flopine -- +Flopine - \ + } Evvvvil +Evvvvil - / + } Evvvvvil - +LJ ------ + +``` +``` +Third place playoff: + +Anat ---- + } LJ +LJ ------ + +``` + +## Software + +[Bonzomatic](https://github.com/Gargaj/Bonzomatic)