Add 2018-02-07

This commit is contained in:
Jonathan Giroux
2018-06-02 21:29:26 +02:00
parent 779fb65edc
commit 83ee2b5c82
12 changed files with 764 additions and 0 deletions

80
2018-02-07/01-xt95.frag Normal file
View File

@ -0,0 +1,80 @@
/*
"pixelRatio" : 1
*/
precision mediump float;
uniform float time;
uniform vec2 resolution;
float smin( float a, float b)
{
float k = 2.;
return -log( exp(-k*a) + exp(-k*b) )/k;
}
vec4 obj[4];
float map( vec3 p)
{
float t = time + floor(p.x/5.-2.5)*.5 + floor(p.z/10.-5.);
obj[0] = vec4( cos(t*1.5),cos(t),cos(t*1.4),.25);
obj[2] = vec4( cos(t*2.),cos(t),cos(t*.5),.125);
obj[1] = vec4( cos(t),cos(t*.4),cos(t),.25);
obj[3] = vec4( cos(t*1.),sin(t),cos(t),1.);
p.xz = mod(p.xz, vec2(10.))-vec2(5.);
float d = p.y+2.;
d = smin(d, length(p-obj[0].xyz) - obj[0].w);
d = smin(d, length(p-obj[1].xyz) - obj[1].w);
d = smin(d, length(p-obj[2].xyz) - obj[2].w);
d = smin(d, length(p-obj[3].xyz) - obj[3].w);
return d;
}
vec3 normal(vec3 p)
{
vec2 eps = vec2(0.01,0.);
float d = map(p);
vec3 n;
n.x = d - map(p-eps.xyy);
n.y = d - map(p-eps.yxy);
n.z = d - map(p-eps.yyx);
return normalize(n);
}
vec3 rm(vec3 ro, vec3 rd)
{
vec3 p = ro;
for(int i=0; i<128; i++)
{
float d = map(p);
p += rd *d;
}
return p;
}
void main(void) {
vec2 uv = gl_FragCoord.xy / resolution -.5;
uv.x *= resolution.x / resolution.y;
vec3 ro = vec3(0.,1.,-10.);
vec3 rd = normalize(vec3(uv, 1.));
vec3 p = rm(ro,rd);
vec3 n = normal(p);
vec3 ld = normalize(vec3(-1.,.5,.1));
float shadow = 1.;
vec3 pp = rm(p+ld*.1, ld);
vec3 col = vec3(1.) * max(0., dot(ld,n));
if(length(p-pp)<10.)
shadow = 0.;
//col *= sign(cos(p.y*10.);
col *= shadow;
col = clamp(col,vec3(0.),vec3(1.)) + vec3(1.,.7,.5)*min(1.,length(p-ro)*.03);
gl_FragColor = vec4(col, 1);
}

View File

@ -0,0 +1,90 @@
/*{
"pixelRatio" : 3
}*/
precision mediump float;
uniform float time;
uniform vec2 resolution;
float rep(float p, float d) {
return mod(p-d*.5, d)-d*.5;
}
vec3 rep(vec3 p, float d) {
return mod(p-d*.5, d)-d*.5;
}
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=p.yx;
}
void amod(inout vec2 p, float m) {
float a = rep(atan(p.x, p.y), m);
p = vec2(cos(a), sin(a)) * length(p);
}
vec2 path(float t) {
float a =sin(t*.2+1.5), b=cos(t*.2);
return vec2(a*2., a*b);
}
vec3 g;
float sc(vec3 p) {
p = abs(p);
p = max(p, p.yzx);
return min(p.x, min(p.y, p.z)) - .02;
}
float de(vec3 p){
p.xy -= path(p.z);
amod(p.xy, 3.14);
mo(p.xy, vec2(.3, 3.));
mo(p.xy, vec2(.9, .3));
float d = length(p.xy) - .03;
d = min(d, length(rep(p, 4.)) - .1);
amod(p.xy, .785);
mo(p.zy, vec2(1., 1.2));
p.z = rep(p.z, 1.);
d = min(d, sc(p));
vec3 q = p;
mo(q.xy, vec2(3., 2.));
q = rep(q, 10.);
d = min(d, sc(q));
g += vec3(.5, .6, .5) * .025 / (.01+d*d);
return d;
}
void main(void) {
vec2 uv = gl_FragCoord.xy / resolution -.5;
uv.x *= resolution.x / resolution.y;
float dt = time*6.;
vec3 ro = vec3(0, 0, -4. + dt);
vec3 ta = vec3(0, 0, dt);
ro.xy += path(ro.z);
ta.xy += path(ta.z);
vec3 fwd = normalize(ta - ro);
vec3 left = cross(vec3(0, 1, 0), fwd);
vec3 up = cross(fwd, left);
vec3 rd = normalize(fwd+uv.x*left+uv.y*up);
float ri, t = 0.;
for(float i=0.;i<1.;i+=.01){
ri=i;vec3 p = ro+rd*t;
float d = de(p);
if(d<.001||t>100.) break;
t+=d*.2;
}
vec3 c = mix(vec3(.9, .2, .4), vec3(.3, cos(time)*.1, .2), uv.x+ri);
c.r *= sin(time);
c += g*.02;
gl_FragColor = vec4(c, 1);
}

View File

@ -0,0 +1,20 @@
/*{
"pixelRatio" : 3,
"PASSES" : [{"TARGET": "buf", "fs": "theotime.frag"}, {}]
}*/
precision mediump float;
uniform float time;
uniform vec2 resolution;
uniform sampler2D buf;
void main(void) {
vec2 uv = gl_FragCoord.xy / resolution;
//gl_FragColor = texture2D(buf, uv);
float c = cos(time*10.)*.009;
float t = tan(time)*.002;
gl_FragColor.r = texture2D(buf, uv+vec2(-c, c)).r;
gl_FragColor.g = texture2D(buf, uv+vec2(-t, t)).g;
gl_FragColor.b = texture2D(buf, uv+vec2(c, -c)).b;
}

View File

View File

@ -0,0 +1,90 @@
/*{
"pixelRatio" : 3
}*/
precision mediump float;
uniform float time;
uniform vec2 resolution;
float rep(float p, float d) {
return mod(p-d*.5, d)-d*.5;
}
vec3 rep(vec3 p, float d) {
return mod(p-d*.5, d)-d*.5;
}
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=p.yx;
}
void amod(inout vec2 p, float m) {
float a = rep(atan(p.x, p.y), m);
p = vec2(cos(a), sin(a)) * length(p);
}
vec2 path(float t) {
float a =sin(t*.2+1.5), b=cos(t*.2);
return vec2(a*2., a*b);
}
vec3 g;
float sc(vec3 p) {
p = abs(p);
p = max(p, p.yzx);
return min(p.x, min(p.y, p.z)) - .02;
}
float de(vec3 p){
p.xy -= path(p.z);
amod(p.xy, 3.14);
mo(p.xy, vec2(.3, 3.));
mo(p.xy, vec2(.9, .3));
float d = length(p.xy) - .03;
d = min(d, length(rep(p, 4.)) - .1);
amod(p.xy, .785);
mo(p.zy, vec2(1., 1.2));
p.z = rep(p.z, 1.);
d = min(d, sc(p));
vec3 q = p;
mo(q.xy, vec2(3., 2.));
q = rep(q, 10.);
d = min(d, sc(q));
g += vec3(.5, .6, .5) * .025 / (.01+d*d);
return d;
}
void main(void) {
vec2 uv = gl_FragCoord.xy / resolution -.5;
uv.x *= resolution.x / resolution.y;
float dt = time*6.;
vec3 ro = vec3(0, 0, -4. + dt);
vec3 ta = vec3(0, 0, dt);
ro.xy += path(ro.z);
ta.xy += path(ta.z);
vec3 fwd = normalize(ta - ro);
vec3 left = cross(vec3(0, 1, 0), fwd);
vec3 up = cross(fwd, left);
vec3 rd = normalize(fwd+uv.x*left+uv.y*up);
float ri, t = 0.;
for(float i=0.;i<1.;i+=.01){
ri=i;vec3 p = ro+rd*t;
float d = de(p);
if(d<.001||t>100.) break;
t+=d*.2;
}
vec3 c = mix(vec3(.9, .2, .4), vec3(.3, cos(time)*.1, .2), uv.x+ri);
c.r *= sin(time);
c += g*.02;
gl_FragColor = vec4(c, 1);
}

101
2018-02-07/03-anton.glsl Normal file
View File

@ -0,0 +1,101 @@
#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 PI 3.14159
float beate(float f)
{
return f + sin(mod(f,1.) * PI);
}
float rep(float f, float r)
{
return mod(f + r/2. ,r) - r/2.;
}
mat2 rot(float a)
{
float c = cos(a); float s = sin(a);
return mat2(c,-s,s,c);
}
float map(vec3 pos)
{
pos.z += beate(fGlobalTime * 1.75) * 2.;
pos.xy *= rot(pos.z * .1);
pos.x += 2.;
pos.x = rep(pos.x, 4.);
pos.y = rep(pos.y, 2.);
pos.z = rep(pos.z, 2.);
return length(pos) - 1.;
}
vec3 norm(vec3 p)
{
vec2 e = vec2(.01,0.);
return 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)
);
}
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);
uv *= rot(fGlobalTime);
float f = uv.x;
vec3 ro = vec3(0.,0.,-5.);
vec3 rd = normalize(vec3(uv,1.));
vec3 cp = ro;
float s = 0.;
for(;s < 1.; s += 1. / 128.)
{
float cd = map(cp);
if(cd < .01)
{
break;
}
cp += rd * cd * .5;
}
f = 1. - s;
float li = dot(normalize( cp - ro),norm(cp));
li = clamp(li,0.,1.);
//f = distance(f,uv.y);
//f = step(f, .005);
out_color = mix(vec4(0.), vec4(sin(cp.z),cos(.0 * cp.z),.5,1.),f);
}

101
2018-02-07/04-ponk.frag Normal file
View File

@ -0,0 +1,101 @@
precision mediump float;
uniform vec2 resolution;
uniform float time;
vec3 lookat(vec3 eye, vec3 at, vec2 uv) {
vec3 front = normalize(at-eye);
vec3 right = normalize(cross(vec3(0,1,0), front));
vec3 up = normalize(cross(front, right));
return normalize(front + right * uv.x + up * uv.y);
}
mat2 rot (float a) {
float c = cos(a);
float s = sin(a);
return mat2(c,-s,s,c);
}
#define PI 3.14159
#define TAU (PI*2.)
void amod(inout vec2 p, float c) {
float an = TAU/c;
float a = mod(atan(p.y, p.x),an)-an/2.;
p = vec2(cos(a),sin(a)) * length(p);
}
float siso(vec3 p, float s) {
return dot(p, normalize(sign(p)))-s;
}
#define sdist(p,r) (length(p)-r)
#define repeat(p,c) (mod(p+c/2.,c)-c/2.)
float map (vec3 pos) {
float scene = 1000.;
vec3 p = pos;
p.xz *= rot(time*.3);
amod(p.xz, 5.);
p.x -= .2;
p = abs(p);
p = repeat(p-time, 3.);
p.xz *= rot(time*.9);
p.yz *= rot(time*.6);
p.xy *= rot(time*.3);
// scene = min(scene, sdist(p.xz, .02));
// scene = min(scene, sdist(p.xy, .02));
// scene = min(scene, sdist(p.zy, .02));
p = repeat(p, .8);
// scene = min(scene, sdist(p, .03));
p = pos;
p.xz *= rot(p.y+time+sin(p.y-time));
amod(p.xz, 5.);
p.x -= .6+.2*sin(time*2.+p.y);
// p.xz *= rot(p.y*20.+time);
amod(p.xz, 3.);
p.x -= .2;//+.05*sin(p.y*3.+time*2.);
amod(p.xz, 3.);
p.x -= .06;
scene = min(scene, sdist(p.xz ,.01));
p = pos;
p.xz *= rot(time*.8);
amod(p.xz, 8.);
p.x -= 2.;
p.x = repeat(p.x-time, 1.);
// scene = min(scene, siso(p, .1));
// scene = min(scene, sdist(p.xy, .02));
// scene = min(scene, sdist(p.xz, .02));
p = pos;
p.xz *= rot(p.y-time);
p.y = repeat(p.y+time, 1.);
p.x -= 2.;
// scene = min(scene, siso(p, .23));
return scene;
}
vec3 raymarch () {
vec3 pos = vec3(0,1,3);
vec2 uv = (gl_FragCoord.xy-.5*resolution)/resolution.y;
vec3 eye = pos;
vec3 ray = lookat(eye, vec3(0), uv);
float shade = 0.;
vec3 color = vec3(1);
for (float i = 0.; i < 1.; i += 1./60.) {
float dist = map(pos);
if (dist < 0.001) {
shade = 1.-i;
break;
}
pos += ray * dist;
}
// color.r = sin(pos.z*10.);
color.gb *= sin(pos.y*3.)*.5+.5;
color *= shade;
color = pow(color, vec3(1./2.2));
return color;
}
void main () {
gl_FragColor = vec4(raymarch(), 1);
}

48
2018-02-07/05-elie.frag Normal file
View File

@ -0,0 +1,48 @@
/*
"pixelRatio" : 1
*/
precision mediump float;
uniform float time;
uniform vec2 resolution;
vec2 scene(vec4 p) {
return vec2(length(p.xyz) - 1.5, 1.0);
}
vec4 shade(vec3 p, float mat) {
return vec4(mat);
}
vec4 march(vec3 o, vec3 d) {
vec2 s;
int i = 0;
for ( ; i < 100 ; ++i) {
s = scene(vec4(o, time));
if (s.x < 0.01) {
break;
}
o += s.x * 0.9 * d;
s.y = 0.0;
}
return vec4(1.0);
}
void main(void) {
vec2 uv = gl_FragCoord.xy / resolution -.5;
uv.x *= resolution.x / resolution.y;
vec3 d = normalize(vec3(uv, -1.0));
vec3 o = vec3(0.0, -1., 0.);
uv.x = mod(uv.x + uv.y * pow(cos(time) * cos(time), 4.), (0.2+ 0.3 * pow(sin(time), 4.)))-0.5*(0.2+0.3*pow(sin(time), 4.));
uv.xy += sin(uv.x * 10. + pow(cos(time * 2.), 4.0)) + (pow(cos(time*.1), 5.) + sin(time*.1)) * 1.0;
uv.x += exp(uv.y*0.1);
vec4 c = vec4(sin(uv.x * 10. + time) * pow(sin(uv.y * 10. + time), 4.));
c = c + vec4(1.0, 2.0, 0.5, 1.0) * cos(time) * exp(cos(time * 2.0));
//c += marsch(o, d);
// c += vec4(1.0, 0.5, 0.0)
gl_FragColor = c;
}

79
2018-02-07/07-anton.glsl Normal file
View File

@ -0,0 +1,79 @@
#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
mat2 rot(float a)
{
float c = cos(a); float s = sin(a);
return mat2(c,-s,s,c);
}
float map(vec3 pos)
{
float sph = length(pos) - 1.;
float pla = pos.y + 1. + sin(pos.z - fGlobalTime)*.1;
pos.x = abs(pos.x);
pos.z += fGlobalTime * 2. + (sin(fGlobalTime * 3.14159 ) * .5 + .5) * .1;
pos.z = mod(pos.z + 2., 4.) - 2.;
pos.x -= 3.;
pos.xy *= rot(-.65);
float cy = length(pos.xz) - .25;
return min(min(sph, pla),cy);
}
float rayCast(vec3 ro,vec3 rd)
{
vec3 cp = ro;
float s = 0.;
for(;s < 1.; s += 1. / 64.)
{
float cd = map(cp);
if(cd < .01)
break;
cp += cd * rd * .75;
}
return s;
}
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.,-10.);
vec3 rd = vec3(uv,1.);
rd.yz *= rot(.1);
float beat = exp(-mod(fGlobalTime * 10., 10.));
beat *= .05;
float r = rayCast(ro, rd + vec3(1.) * beat);
float g = rayCast(ro, rd + vec3(1.,-1.,1.) * beat);
float b = rayCast(ro, rd + vec3(1.,1.,-1.) * beat);
float f = 1. - rayCast(ro, rd);
out_color = vec4(r,g,b,1.);
out_color = out_color * sin(fGlobalTime) * .5 + .5;
}

89
2018-02-07/08-xt95.glsl Normal file
View File

@ -0,0 +1,89 @@
#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 smin(float a, float b)
{
float k = 32.;
return -log( exp( -k/a) + exp( -k / b ) ) / k;
}
float obj( vec3 p )
{
return cos(p.x)*cos(p.y)*cos(p.z) ;
}
float map(vec3 p)
{
p.x += cos(p.z*2.)*.6;
p.y += sin(p.z)*.3;
float d = abs(p.y)-1.;
d = min(d, abs(p.x)-1.);
d += texture2D( texNoise, p.xy*.3).x*.8;
d += texture2D( texNoise, p.xz*.3).x*.4;
d += texture2D( texNoise, p.yz*.3).x*.2;
return d*.5;
}
vec3 rm(vec3 ro, vec3 rd)
{
vec3 p = ro;
for(int i=0; i<64; i++)
{
float d = map(p);
p += rd * d;
}
return p;
}
vec3 normal( vec3 p )
{
vec2 eps = vec2(0.001, 0.);
vec3 n;
float d = map(p);
n.x = d - map(p - eps.xyy);
n.y = d - map(p - eps.yxy);
n.z = d - map(p - eps.yyx);
return normalize(n);
}
float ao(vec3 p, vec3 n)
{
float ao = 1.;
for(int i=0; i<10; i++)
{
float h = float(i)*.1;
ao -= abs( h - map(p+n*h)/10. );
}
return clamp( ao, 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);
float t = fGlobalTime;
vec3 ro = vec3(0.,0., t*2.);
vec3 rd = normalize(vec3(uv, 1.) );
vec3 p = rm(ro,rd);
vec3 n = normal(p);
vec3 col = vec3(ao(p,n));
col = mix(col, vec3(1.), min(length(p-ro)*.05, 1.));
out_color = vec4(col,1.);
}

63
2018-02-07/09-wsmind.glsl Normal file
View File

@ -0,0 +1,63 @@
#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 rotate(vec2 uv, float a)
{
float c = cos(a);
float s = sin(a);
return mat2(c, s, -s, c) * uv;
}
float circle(vec2 uv, float r, float w, float m, float t)
{
float l = length(uv);
float a = atan(uv.x, uv.y);
return smoothstep(r, r + 0.01, l) * smoothstep(r + w, r + w - 0.01, l) * step(mod(a + t, m), m * 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);
float pulse = exp(-fract(fGlobalTime * 0.4));
uv = rotate(uv, fGlobalTime * length(uv) * sin(fGlobalTime) * 0.01);
uv *= 0.5 / pulse;
uv.y += sin(uv.x * 20.0 + fGlobalTime * 5.0) * 0.02;
vec3 color = uv.xyx * circle(uv, 0.3, 0.02, 0.9, fGlobalTime);
color += sin(uv.x * 200.0) * circle(uv, 0.2, 0.01, 0.9, fGlobalTime);
color += mix(vec3(0.6, 0.2, 0.7), vec3(1.0, 0.4, 0.7), (dot(uv, vec2(cos(fGlobalTime), sin(fGlobalTime))))) * vec3(0.7, 0.2, 0.1);
color *= fract(uv.y * 3.0 + fGlobalTime) * 0.1;
color += -0.2 - exp(-fract(fGlobalTime * 0.8) * 10.0) * sin(uv.y * 800.0 + fGlobalTime * 400.0) * 4.0;
for (int i = 0; i < 16; i++)
color += fract(uv.y * 50) * vec3(float(i), 0.6, 0.2) * circle(uv, sin(float(i) * 0.7) * 0.4, sin(float(i) * exp(-fract(fGlobalTime * 1.0))) * 0.1, sin(float(i)), fGlobalTime * sin(float(i) * 30.0) * 2.0);
color += length(uv) * vec3(0.1, 0.4, 0.7) * 3.0;
color *= 2.0;
color /= color + 1.0;
color = sqrt(color);
out_color = vec4(color, 1.0);
}

3
2018-02-07/Readme.md Normal file
View File

@ -0,0 +1,3 @@
# Shader Showdown Paris #5
On Februar 7th, 2018 at [Le Jardin d'Alice](https://www.lejardindalice.org/).