Bottle

by musk for SESSIONS 2024 Code Graphics

variation: geekest (300 es) [[valid compo edition]]
265 chars with LF or 267 chars with CRLF chars
https://twigl.app?ol=true&ss=-OB7eCKCUjLO8AfvJ2_S 

variation: geekest [[original]]
278 chars with LF 280 with CRLF
https://twigl.app?ol=true&ss=-OAXiKzdSdOHQhY_wMTg 

Let me explain the LF/CRLF situation:

When running twigl.app with firefox on a linux machine 
the line breaks are counted as 1 character due to 
how internally  are represented in JavaScript. 
Running same on windows you get 2 characters for 
each break.

I use a linux machine, so my linefeeds use 1 char
instead of using 2 chars. But I made sure that my
shader fits into the 280 limit on windows.

The newlines are required for the #define macros
to work which is the only way I found I could do
some code reuse.

The following is the final optmized version which 
fits into the compo regulation geekest (300 es):

#define D(P)length(abs(P*rotate3D(t,b+d)+cos(t+P.yxz))+cos(t)-1.)-2.
#define L for(int i=0;i<9;i++)
vec3 d=vec3((FC.xy*2.-r)/r.y,.4),p=vec3(0,0,-4),q,b=p.zzx*-.1;float O,C,E;L{q=p+=d;E=.0;L O=D(q),E=max(E,(D((q+b))-O)/O/O),q+=b*O;C+=E*.02;}o=vec4(C,C*C,C,1)/(1.+C);


But if you are interested in the evolution of this 
shader from start to finish, you can paste these into
twigl when seleting the "geekest" regulation:

// 419 chars
vec2 u=(FC.xy*2.-r)/min(r.x,r.y);
vec3 p=vec3(0,0,-4),d=vec3(u,.8),C,q,b=vec3(6,6,1)*.1,E;
float A=1.,o;
mat3 Q=rotate3D(t,b)*rotate3D(t,d);
#define D(P) (length(abs(P*Q+sin(t+P.yxz*5.2)*.1)-sin(t)-1.)-1.1)
#define L(I) for (int L=0;L<10;L++)
L(i){p+=d*.5,q=p+b*.1,E=p*.0;
L(j)o=D(q),E=max(E,vec3(max(0.,(D((q+b*.1))-o)*1.))/(o*o*o)*o*1.4e-3),q+=b*min(o,.1);
C+=E*16.;}
gl_FragColor=vec4(pow(C/(1.+C),vec3(.7,9,.4)),1);

// 369 chars
vec2 u=(FC.xy*2.-r)/r.y;
vec3 p=vec3(0,0,-4),d=vec3(u,.4),C,q,b=vec3(3,3,0)*.2,E;
float o;
#define D(P) (length(abs(P*rotate3D(t,b)*rotate3D(t,d)+sin(t+P.yxz*5.2)*.1)-sin(t)-1.)-1.1)
#define L for(int i=0;i<9;i++)
L{q=p+=d,E=p*.0;
L o=D(q),E=max(E,vec3(max(0.,(D((q+b*.1))-o)*1.))/(o*o*o)*o),q+=b*min(0.1,o);
C+=E*.1;}
gl_FragColor=vec4(pow(C/(1.+C),vec3(.7,9,.4)),1);

// 346 chars
#define D(P) (length(abs(P*rotate3D(t,b)*rotate3D(t,d)+sin(t+P.yxz*5.)*.1)-sin(t)-1.)-1.1)
#define L for(int i=0;i<9;i++)
vec3 p=vec3(0,0,-4),d=vec3((FC.xy*2.-r)/r.y,.4),C,q,b=vec3(3,3,0)*.05,E;float o;
L{q=p+=d,E=p*.0;
L o=D(q),E=max(E,vec3(max(0.,(D((q+b))-o)*1.))/(o*o*o)*o),q+=b*o;
C+=E*.1;}
gl_FragColor=vec4(pow(C/(1.+C),vec3(.7,9,.4)),1);

// 315 chars
#define D(P) (length(abs(P*rotate3D(t,b)*rotate3D(t,d)+sin(t+P.yxz*5.)*.1)-sin(t)-1.)-1.1)
#define L for(int i=0;i<9;i++)
vec3 p=vec3(0,0,-4),d=vec3((FC.xy*2.-r)/r.y,.4),q,b=vec3(3,3,0)*.05;float o,C,E;
L{q=p+=d,E=.0;L o=D(q),E=max(E,max(0.,(D((q+b))-o)*1.)/(o*o*o)*o),q+=b*o;C+=E*.1;}
gl_FragColor=vec4(C/(1.+C));

// 297 chars
#define D(P) (length(abs(P*rotate3D(t,b)*rotate3D(t,d)+sin(t+P.yxz*5.)*.1)-sin(t)-1.)-1.)
#define L for(int i=0;i<9;i++)
vec3 p=vec3(0,0,-4),d=vec3((FC.xy*2.-r)/r.y,.4),q,b=vec3(3,3,0)*.05;float o,C,E;
L{q=p+=d,E=.0;L o=D(q),E=max(E,(D((q+b))-o)/o/o),q+=b*o;C+=E*.1;}
gl_FragColor=vec4(C/(1.+C));

// 293 chars
#define D(P) (length(abs(P*rotate3D(t,b)+cos(t+P.yxz*5.)*.1)-cos(t)-1.)-1.)
#define L for(int i=0;i<9;i++)
vec3 p=vec3(0,0,-4),d=vec3((FC.xy*2.-r)/r.y,.4),q,b=p.zzx*-.1;float o,C,E;
L{q=p+=d;E=.0;L o=D(q),E=max(E,(D((q+b))-o)/o/o),q+=b*o;C+=E*1e-4;}
gl_FragColor=pow(vec4(C),vec4(1,.5,.2,1));

// 280 chars
#define D(P) (length(abs(P*rotate3D(t,b)+cos(t+P.yxz*5.)*.1)-cos(t)-1.)-1.)
#define L for(int i=0;i<9;i++)
vec3 d=vec3((FC.xy*2.-r)/r.y,.4),p=vec3(0,0,-4),q,b=p.zzx*-.1;float o,C,E;
L{q=p+=d;E=.0;L o=D(q),E=max(E,(D((q+b))-o)/o/o),q+=b*o;C+=E*.01;};
gl_FragColor=vec4(C,C*C,C,1);


After switching to geekest (300 es) I realized 
that I have 13 chars left. I would have used it
for better colors. But now I will leave it as I 
originally intended for without using (300 es)

That's it from my side. Enjoy! Have fun and
stay safe out there, it's a crazy world we 
live in!



