precision highp float; uniform float time; uniform vec2 resolution; #define MAX_STEPS 80 #define MAX_DIST 80. #define SURF_DIST .0005 #define Rot(a) mat2(cos(a),-sin(a),sin(a),cos(a)) #define antialiasing(n) n/min(resolution.y,resolution.x) #define S(d,b) smoothstep(antialiasing(2.0),b,d) #define B(p,s) max(abs(p).x-s.x,abs(p).y-s.y) #define deg45 .707 #define R45(p) (( p + vec2(p.y,-p.x) ) *deg45) #define Tri(p,s) max(R45(p).x,max(R45(p).y,B(p,s))) #define SUV(p) vec2(atan(p.x,p.z),acos(p.y)) #define ch_0 0 #define ch_1 1 #define ch_2 2 #define ch_3 3 #define ch_4 4 float iTime = time; float random (vec2 p) { return fract(sin(dot(p.xy, vec2(12.9898,78.233)))* 43758.5453123); } float cubicInOut(float t) { return t < 0.5 ? 4.0 * t * t * t : 0.5 * pow(2.0 * t - 2.0, 3.0) + 1.0; } float getTime(float t, float duration){ return clamp(t,0.0,duration)/duration; } float getAnimationValue(){ float easeValue = 0.; float frame = mod(iTime,12.0); float time = frame; float duration = 1.; if(frame>=5. && frame<6.){ time = getTime(time-5.,duration); easeValue = cubicInOut(time); } else if(frame>=6. && frame<11.){ easeValue = 1.; } else if(frame>=11. && frame<12.){ time = getTime(time-11.,duration); easeValue = 1.0-cubicInOut(time); } return easeValue; } float getRotAnimValue(){ float easeValue = 0.; float frame = mod(iTime,24.0); float time = frame; float duration = 1.; if(frame>=17. && frame<18.){ time = getTime(time-17.,duration); easeValue = cubicInOut(time); } else if(frame>=18. && frame<23.){ easeValue = 1.; } else if(frame>=23. && frame<24.){ time = getTime(time-23.,duration); easeValue = 1.0-cubicInOut(time); } return easeValue; } float getSceneAnimValue(){ float easeValue = 0.; float frame = mod(iTime,42.0); float time = frame; float duration = 0.9; if(frame>=11. && frame<12.){ time = getTime(time-11.,duration); easeValue = cubicInOut(time); } else if(frame>=12. && frame<40.){ easeValue = 1.; } else if(frame>=40. && frame<41.){ time = getTime(time-40.,duration); easeValue = 1.0-cubicInOut(time); } return easeValue; } float getBoxAnimation(){ float frame = mod(iTime,11.0); float duration = 0.9; float rotVal = 0.0; float time = frame; if(frame>=1. && frame<3.){ time = getTime(time-1.,duration); rotVal = cubicInOut(time)*90.; } else if(frame>=3. && frame<5.){ time = getTime(time-3.,duration); rotVal = 90.+cubicInOut(time)*90.; } else if(frame>=5. && frame<7.){ time = getTime(time-5.,duration); rotVal = 180.+cubicInOut(time)*90.; } else if(frame>=7. && frame<9.){ time = getTime(time-7.,duration); rotVal = 270.+cubicInOut(time)*90.; } else if(frame>=9.){ time = getTime(time-9.,duration+0.5); rotVal = 360.-cubicInOut(time)*360.; } return rotVal; } // thx iq! https://iquilezles.org/articles/distfunctions/ float sdBox( vec3 p, vec3 b ) { vec3 q = abs(p) - b; return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0); } float grid(vec2 p){ vec2 prevP = p; float thickness = 0.001; float size = 0.1; p+=vec2(size*0.5); p = mod(p,size)-(size*0.5); float d = abs(p.x)-thickness; float d2 = abs(p.y)-thickness; d = min(d,d2); p = prevP; p.x = abs(p.x)-0.15; d2 = B(p,vec2(thickness,100.)); d = min(d,d2); return d; } float iconTri(vec2 p){ vec2 prevP = p; p.y-=0.2; p.y*=0.375; float d = Tri(p,vec2(0.15)); p.y+=0.065; float d2 = Tri(p,vec2(0.06)); d = max(-d2,d); return d; } float iconCircle(vec2 p){ vec2 prevP = p; p.y*=0.75; float d = length(p)-0.15; float d2 = length(p)-0.07; d = max(-d2,d); //d = max( abs(d)-0.02,d); return d; } float iconX(vec2 p){ vec2 prevP = p; p*=Rot(radians(30.)); float d = abs(p.x)-0.04; p = prevP; p*=Rot(radians(-30.)); float d2 = abs(p.x)-0.04; d = min(d,d2); p = prevP; d = max(abs(p.y)-0.2,d); //d = max( abs(d)-0.02,d); return d; } float iconRect(vec2 p){ vec2 prevP = p; float d = B(p,vec2(0.15,0.2)); float d2 = B(p,vec2(0.07,0.12)); d = max(-d2,d); //d = max( abs(d)-0.02,d); return d; } float iconCross(vec2 p){ vec2 prevP = p; float d = abs(p.x)-0.04; float d2 = abs(p.y)-0.04; d = min(d,d2); d = max(abs(p.x)-0.15,d); d = max(abs(p.y)-0.2,d); //d = max( abs(d)-0.02,d); return d; } float S_parts(vec2 p){ vec2 prevP = p; float d = length(p)-0.1; d = max(p.x,d); d = max(-(length(p)-0.04),d); p.y = abs(p.y)-0.07; float d2 = B(p,vec2(0.07,0.03)); d2 = max(-p.x,d2); d = min(d,d2); return d; } float charS(vec2 p, float morph){ vec2 prevP2 = p; p.x*=0.68; p.y*=0.88; vec2 prevP = p; p.y-=0.074; p*=Rot(radians(21.)); float d = S_parts(p); p = prevP; p.x*=-1.; p.y+=0.074; p*=Rot(radians(-21.)); float d2 = S_parts(p); d = min(d,d2); p = prevP2; float d3 = iconTri(p); d = mix(d,d3,morph); return d; } float charE(vec2 p, float morph){ vec2 prevP = p; p.x += 0.11; float d = B(p,vec2(0.04,0.2)); p = prevP; p.x-=0.03; p.y = abs(p.y)-0.16; float d2 = B(p,vec2(0.12,0.04)); d = min(d,d2); p = prevP; p.x-=0.03; d2 = B(p,vec2(0.12,0.04)); d = min(d,d2); p = prevP; float d3 = iconCircle(p); d = mix(d,d3,morph); return d; } float charI(vec2 p, float morph){ vec2 prevP = p; float d = B(p,vec2(0.04,0.2)); float d3 = iconX(p); d = mix(d,d3,morph); return d; } float charO(vec2 p, float morph){ vec2 prevP2 = p; p.x*=0.68; p.y*=0.87; vec2 prevP = p; p.y = abs(p.y)-0.07; p*=Rot(radians(90.)); float d = S_parts(p); p = prevP2; float d3 = iconRect(p); d = mix(d,d3,morph); return d; } float charN(vec2 p, float morph){ vec2 prevP = p; p.x = abs(p.x)-0.11; float d = B(p,vec2(0.04,0.2)); p = prevP; p*=Rot(radians(-25.)); float d2 = B(p,vec2(0.04,0.3)); p = prevP; d2 = max(abs(p.y)-0.2,d2); d = min(d,d2); p = prevP; float d3 = iconCross(p); d = mix(d,d3,morph); return d; } float checkChar(int targetChar, int char){ return 1.-abs(sign(float(targetChar) - float(char))); } float drawFont(vec2 p, int char, float morph){ p.x*=0.7; p*=1.65; float d = charS(p,morph)*checkChar(ch_0,char); d += charE(p,morph)*checkChar(ch_1,char); d += charI(p,morph)*checkChar(ch_2,char); d += charO(p,morph)*checkChar(ch_3,char); d += charN(p,morph)*checkChar(ch_4,char); return d; } float pattern1(vec3 p, float n){ float frame = getAnimationValue()*getSceneAnimValue(); p.xy*=Rot(radians(-90.*getRotAnimValue()*getSceneAnimValue())); vec3 prevP = p; float d =drawFont(p.xy*vec2(0.15,0.135),int(mod(9.+iTime*n,5.0)),frame); d = max((abs(p.z)-0.1),d); return d; } float pattern2(vec3 p, float n){ float frame = getAnimationValue()*getSceneAnimValue(); p.xy*=Rot(radians(-90.*getRotAnimValue()*getSceneAnimValue())); vec3 prevP = p; float d = drawFont((p.xy*0.3)-vec2(-0.15,0.15),int(mod(8.+iTime*n*1.,5.0)),frame); float d2 = drawFont((p.xy*0.3)-vec2(0.15,0.15),int(mod(7.+iTime*n*1.2,5.0)),frame); d = min(d,d2); d2 = drawFont((p.xy*0.3)-vec2(-0.15,-0.15),int(mod(5.+iTime*n*1.5,5.0)),frame); d = min(d,d2); d2 = drawFont((p.xy*0.3)-vec2(0.15,-0.15),int(mod(3.+iTime*n*1.3,5.0)),frame); d = min(d,d2); d = max((abs(p.z)-0.1),d); return d; } float pattern3(vec3 p, float n){ p.xy*=Rot(radians(-90.*getRotAnimValue()*getSceneAnimValue())); vec3 prevP = p; p.xy*=Rot(radians(45.)); p.x+=iTime*0.2; p.x = mod(p.x,0.3)-0.15; float d = B(p.xy,vec2(0.05,10.)); p = prevP; d = max(B(p.xy,vec2(0.95)),d); d = max((abs(p.z)-0.1),d); return d; } vec2 GetDist(vec3 p) { vec3 prevP = p; p.y-=0.5*iTime; vec2 id = floor(p.xy*0.5); p.z-=3.; p.xy = mod(p.xy,2.0)-1.0; float n = random(id); float t = iTime*2.; float d = 10.; if(n<0.45){ d = pattern1(p,n); } else if(n>=0.45 && n<0.9){ d = pattern2(p,n); } else if(n>=0.9){ d = pattern3(p,n); } p = prevP; p.xz*=Rot(radians(-getBoxAnimation())); float d2 = sdBox(p,vec3(0.9+getSceneAnimValue()*5.)); return vec2(mix(d2,d,getSceneAnimValue()),0.0); } vec2 RayMarch(vec3 ro, vec3 rd, float side, int stepnum) { vec2 dO = vec2(0.0); for(int i=0; iMAX_DIST || abs(dS.x)=0.45 && n<0.9){ d = pattern2(vec3(gr,0),n); } else if(n>=0.9){ d = pattern3(vec3(gr,0),n); } p = prevP; float d2 = B(p,vec2(1.0)); d2 = max(-B(p,vec2(0.85)),d2); d = min(d,d2); return d; } // the reflection code reference from the following: https://www.shadertoy.com/view/tsXSRs vec3 reflectionBg(vec2 uv){ const float pi = 3.14159; return mix(vec3(0.05), vec3(2.), smoothstep(pi*0.35, pi*0.98, uv.y)); } vec3 materials(int mat, vec3 n, vec3 rd, vec3 p, vec3 col){ float IOR = 1.309; //IOR:index of reflection vec3 rdir = refract(-rd,n,1.0/IOR); col = reflectionBg(SUV(rdir)); col = diffuseMaterial(n,rd,p,col); vec3 col2 = vec3(0.); p.xz*=Rot(radians(-getBoxAnimation())); n.xz*=Rot(radians(-getBoxAnimation())); vec3 colXZ = mix(col2,vec3(1.),S(pattern2D(p.xz,1.,1.),0.0)); vec3 colYZ = (n.x < 0.0) ? mix(col2,vec3(1.),S(pattern2D(p.yz,-1.,-1.),0.0)) : mix(col2,vec3(1.),S(pattern2D(p.yz*vec2(-1.,1.),1.,-1.),0.0)); vec3 colXY = (n.z < 0.0) ? mix(col2,vec3(1.),S(slogo(p.xy),0.0)) : mix(col2,vec3(1.),S(slogo(p.xy*vec2(-1.,1)),0.0)); col2 = colXZ*abs(n.y)+colXY*abs(n.z)+colYZ*abs(n.x); return mix(col2,col,getSceneAnimValue()); } float sessions(vec2 p){ vec2 prevP = p; p*=1.5; p.x*=1.5; p.x+=0.05; float d = drawFont(p-vec2(-0.9,0.0),0,0.); float d2 = drawFont(p-vec2(-0.6,0.0),1,0.); d = min(d,d2); d2 = drawFont(p-vec2(-0.3,0.0),0,0.); d = min(d,d2); d2 = drawFont(p-vec2(0.,0.0),0,0.); d = min(d,d2); d2 = drawFont(p-vec2(0.2,0.0),2,0.); d = min(d,d2); d2 = drawFont(p-vec2(0.4,0.0),3,0.); d = min(d,d2); d2 = drawFont(p-vec2(0.7,0.0),4,0.); d = min(d,d2); d2 = drawFont(p-vec2(1.,0.0),0,0.); d = min(d,d2); return d; } vec3 draw2D(vec2 p, vec3 col){ vec2 prevP = p; float d = sessions(p); col = mix(col,vec3(1.0),S(d,0.0)); p.y-=iTime*0.1; p.y = mod(p.y,0.2)-0.1; d = sessions(p); p = prevP; d = max(abs(p.y)-0.2,d); d = max(-(abs(p.y)-0.09),d); col = mix(col,vec3(0.6),S(d,0.0)); p.x = abs(p.x)-0.55; d = stripes(p,1.); col = mix(col,vec3(1.),S(d,0.0)); return col; } void main( void ) { vec2 uv = (gl_FragCoord.xy-.5*resolution.xy)/resolution.y; vec2 prevUV = uv; uv.xy*=Rot(radians(90.*getRotAnimValue()*getSceneAnimValue())); vec3 ro = vec3(0, 0, -3.-(3.*getAnimationValue()*getSceneAnimValue())); ro.yz *= Rot(radians(-5.0)); ro.xz *= Rot(radians(sin(iTime*0.2)*10.0)); vec3 rd = R(uv, ro, vec3(0,0.0,0), 1.0); vec2 d = RayMarch(ro, rd, 1.,MAX_STEPS); vec3 col = vec3(.0); if(d.x