This commit is contained in:
2024-08-01 21:12:04 +03:00
parent 4cd5b486ec
commit 3760f1faac
2 changed files with 107 additions and 97 deletions

View File

@ -72,6 +72,11 @@ float sdTriPrism( vec3 p, vec2 h, float rot )
return max(q.z-h.y,max(q.x*.866025+p.y*.5,-p.y)-h.x*.5);
}
float sdPyramid( vec3 p, float s)
{
p = abs(p);
return (p.x+p.y+p.z-s)*0.577;// 35027;
}
//////////////////
// ANIMATION //
@ -88,20 +93,12 @@ float sdTriPrism( vec3 p, vec2 h, float rot )
// DELAYS
float STARTDELAY = 9., glow = 0.;
// COLORS
vec3
glyph3Pos = vec3(1.5,1.4,0.0),
glyph5Pos = vec3(-1.5,1.4,0.0),
fogColor1 = vec3(0.49, 0.18, 0.49), // fog color1
fogColor2 = vec3(0.93, 0.37, 0.16), // fog color2
indirColor = vec3(0.29, 0.28, 0.33), // indirect light color
light1Color = vec3(0.82, 0.5, 0.9),
light2Color = vec3(0.79, 0.66, 0.43),
chevronColor = vec3(0.46, 0.0, 0.9),
SEA_BASE = vec3(0.0, 0.1, 0.3),
SEA_WATER_COLOR =vec3(0.11, 0.16, 0.18);
// POSITIONS
// COLORS
vec3 chevronColor = vec3(0.36, 0.9, 0.0);
// with duration d, startTime s and speed up with timeFact
float timedSine(vec3 i) {
return min((u_time - i.y)*i.z, i.x*PI);
@ -182,7 +179,7 @@ vec3 map(vec3 p, int displace)
d2 = min(d2, step);
stepDist += .2;
}
d2 += noise(p.xz * 50.+200., .01, 0) - noise (p.yz*2.+1.5, 0.15,0);
d2 += noise(p.xz * 50.+200., .007, 0);
d = min(d, d2);
if (d==d2) mat = 2.0;
@ -208,6 +205,10 @@ vec3 map(vec3 p, int displace)
d = min(d,d2);
if (d==d2) mat = 3.0;
// pyradmid
d2 = sdPyramid(p+vec3(-75., 0., 100.), 60.);
d = min(d, d2);
if (d==d2) mat=3.;
// Prisms
for(float i = 0.; i < 8.; i++ ) {
an = 24.67 / (PI * 2.); // sector size
@ -254,7 +255,7 @@ float rayMarch(vec3 ro, vec3 rd, int a) {
d = map(ro + rd * t, 0); // Get distance to objects
if (a==0&&d.z<0.3) glow += 0.05/(1.0 + 10.*pow(d.z, .5));
t += d.x; // "march" the ray
if (d.x < 1e-3 || t > 400.) break;
if (d.x < 1e-3 || t > 500.) break;
}
return t;
}
@ -288,7 +289,7 @@ float specular(vec3 normal,vec3 lightPos,vec3 rayOrigin,float specular) {
vec3 getSeaColor(vec3 p, vec3 n, vec3 l, vec3 eye) {
vec3 color = SEA_BASE + diffuse(n,l,60.0) * SEA_WATER_COLOR * 0.3;
vec3 color = vec3(0.0, 0.1, 0.3) + diffuse(n,l,60.0) * vec3(0.11, 0.16, 0.18) * 0.3;
color -= vec3(0.73, 0.15, 0.66) * pow(cl(1.-dot(n, -eye), 0., 1.), .7);
color += vec3(specular(n,l,eye,60.0))*0.2;
return color;
@ -296,8 +297,8 @@ vec3 getSeaColor(vec3 p, vec3 n, vec3 l, vec3 eye) {
vec3 applyFog(vec3 col, float t, vec3 rd, vec3 lightDir, float b ) {
vec3 fogColor = mix( fogColor1, // blue
fogColor2, // yellow
vec3 fogColor = mix( vec3(0.34, 0.11, 0.34), // blue
vec3(0.93, 0.37, 0.16), // yellow
pow(max( dot(rd, lightDir), 0.) ,8.));
return mix( col, fogColor, 1.0 - exp(-t*b) );
}
@ -360,7 +361,7 @@ vec3 cameraPointAt() {
if (u_time > 10.5) p = vec3(1.7,-1.1,0.);
// look gate at distance
if(u_time > 12.) p = vec3(0.);
if(u_time > 13.5) p = mix(glyph3Pos,glyph5Pos, (u_time-13.5)*0.13);
if(u_time > 13.5) p = mix(vec3(1.5,1.4,0.0),vec3(-1.5,1.4,0.0), (u_time-13.5)*0.13);
if(u_time > 19.5) p = vec3(0.);
return p;
}
@ -387,7 +388,7 @@ vec3 sceneGate(vec2 uv)
col = vec3(0.);
float d = rayMarch(ro, rd,0), mat = 0.;
if (d < 200.) {
if (d < 500.) {
// Lighting
vec3 p = ro + rd * d,
n = getNormal(p);
@ -399,17 +400,17 @@ vec3 sceneGate(vec2 uv)
// 4: Shadow intensity
// Lights
col += light1Color * getLight(p, vec3( 10., 15., 25.), 1., .2,n);
col += light2Color * getLight(p, vec3( 4., 2., -15.), 1., 1.,n);
col += vec3(0.82, 0.5, 0.9) * getLight(p, vec3( 10., 15., 25.), 1., .2,n);
col += vec3(0.79, 0.66, 0.43) * getLight(p, vec3( 4., 2., -15.), 1., 1.,n);
// indirect lightning -> vec3 in normalize is light direction
col += indirColor * cl( dot( n, no(vec3(0. , 1., 10.))), 0., 1.);
col += vec3(0.29, 0.28, 0.33) * cl( dot( n, no(vec3(0. , 1., 10.))), 0., 1.);
if(mat==0.)
col *= vec3(0.2, 0.3, 0.3) + addSpecular(n,rd,.5, 2.);
if(mat==1.)
col = getSeaColor(p, n, no(vec3(0.0,0.3,0.8)),no(rd));
if(mat==2.)
col *= vec3(.8, .8, .5);
col *= vec3(0.7, 0.7, 0.4) + noise (p.xz*3.+1.5, 0.1,0);
if(mat==3.)
col *= vec3(.8, .8, .5) + noise(p.xz*500.+1e5, .3,0);
if(mat==4.)

View File

@ -8,9 +8,9 @@ const char *__temp_cleaned_shader_glsl =
"uniform vec2 v;"
"uniform float y;"
"const float m=22./7.;"
"vec3 f(vec3 y)"
"vec3 f(vec3 v)"
"{"
"return normalize(y);"
"return normalize(v);"
"}"
"float f(float v,float f,float y)"
"{"
@ -24,8 +24,8 @@ const char *__temp_cleaned_shader_glsl =
"}"
"float n(float v,float y,float m)"
"{"
"float z=max(m-abs(v-y),0.);"
"return max(v,y)+z*z*.25/m;"
"float x=max(m-abs(v-y),0.);"
"return max(v,y)+x*x*.25/m;"
"}"
"float f(vec2 v,int y)"
"{"
@ -39,13 +39,13 @@ const char *__temp_cleaned_shader_glsl =
"}"
"float x(vec2 v,float y,int m)"
"{"
"vec2 d=floor(v);"
"vec2 s=floor(v);"
"v=fract(v);"
"v=v*v*(3.-2.*v);"
"float z=y;"
"float x=y;"
"if(m==1)"
"z=2.;"
"return-y+z*mix(mix(f(d+vec2(0),m),f(d+vec2(1,0),m),v.x),mix(f(d+vec2(0,1),m),f(d+vec2(1),m),v.x),v.y);"
"x=2.;"
"return-y+x*mix(mix(f(s+vec2(0),m),f(s+vec2(1,0),m),v.x),mix(f(s+vec2(0,1),m),f(s+vec2(1),m),v.x),v.y);"
"}"
"float s(vec3 v,float y,float m)"
"{"
@ -63,13 +63,18 @@ const char *__temp_cleaned_shader_glsl =
"vec3 m=abs(v);"
"return max(m.z-y.y,max(m.x*.866025+v.y*.5,-v.y)-y.x*.5);"
"}"
"float z=0.;"
"vec3 d=vec3(1.5,1.4,0),i=vec3(-1.5,1.4,0),a=vec3(.49,.18,.49),p=vec3(.93,.37,.16),c=vec3(.29,.28,.33),l=vec3(.82,.5,.9),r=vec3(.79,.66,.43),C=vec3(.46,0,.9),F=vec3(0,.1,.3),K=vec3(.11,.16,.18);"
"float s(vec3 v)"
"{"
"v=abs(v);"
"return(v.x+v.y+v.z-60.)*.577;"
"}"
"float z=0.;"
"vec3 a=vec3(.36,.9,0);"
"float x(vec3 v)"
"{"
"return min((y-v.y)*v.z,v.x*m);"
"}"
"vec3 x(vec3 v)"
"vec3 t(vec3 v)"
"{"
"for(float i=0.;i<7.;i++)"
"{"
@ -78,15 +83,15 @@ const char *__temp_cleaned_shader_glsl =
"{"
"if(mod(i,2.)>=1.)"
"z=-1.;"
"v.xy*=n((9.+9.*f(sin(s(vec3(1.5,m,4))*.06),-.9,.9))*z);"
"v.xy*=n((9.+9.*f(sin(x(vec3(1.5,m,4))*.06),-.9,.9))*z);"
"}"
"}"
"return v;"
"}"
"float t(vec2 v)"
"float w(vec2 v)"
"{"
"if(y>=v.y)"
"v.x+=.045*f(sin(s(vec3(3,v.y,40))*.4),-.8,.8);"
"v.x+=.045*f(sin(x(vec3(3,v.y,40))*.4),-.8,.8);"
"return v.x;"
"}"
"float t(vec2 v,float y)"
@ -97,27 +102,27 @@ const char *__temp_cleaned_shader_glsl =
"f=mix(f,v,f);"
"return pow(1.-pow(f.x*f.y,.65),y);"
"}"
"vec3 x(vec3 v,int f)"
"vec3 w(vec3 v,int f)"
"{"
"float z=0.,i=1e3,r=m/12.,p,d=floor(atan(v.y,v.x)/r+.5)*r;"
"vec3 a=v;"
"a.xy=n(d)*a.xy;"
"float c=length(max(abs(a.xy-vec2(1.8,0))-vec2(.24,.14),0.))-.02,l=abs(length(v.xy)-1.8)-.2;"
"float z=0.,i=1e3,r=m/12.,a,d=floor(atan(v.y,v.x)/r+.5)*r;"
"vec3 p=v;"
"p.xy=n(d)*p.xy;"
"float c=length(max(abs(p.xy-vec2(1.8,0))-vec2(.24,.14),0.))-.02,l=abs(length(v.xy)-1.8)-.2;"
"c=min(c,l);"
"l=n(abs(length(v.xy)-1.75)-.08,abs(v.z-.1)-.04,.005);"
"c=n(max(-l,c),abs(v.z)-.1,.02);"
"vec3 C=x(v),K=C;"
"vec3 h=t(v),g=h;"
"r=m/16.;"
"K.xy=n(floor(atan(C.y,C.x)/r+.5)*r)*K.xy;"
"l=n(K.xyz-vec3(1.75,0,0),vec3(.04,.14,.05))-.02+x(v.xy*1e2,.001,0);"
"g.xy=n(floor(atan(h.y,h.x)/r+.5)*r)*g.xy;"
"l=n(g.xyz-vec3(1.75,0,0),vec3(.04,.14,.05))-.02+x(v.xy*1e2,.001,0);"
"c=min(c,l);"
"if(c==l)"
"z=6.;"
"l=1e3;"
"float F=1.5,e=0.,b,g=4.,E=.6,D=.2;"
"float C=1.5,e=0.,b,E=4.,D=.6,B=.2;"
"for(int i=0;i<4;i++)"
"p=n(vec3(v.x,v.y+F+.05,v.z),vec3(2,.2,F))-.05,l=min(l,p),F+=.2;"
"l+=x(v.xz*50.+2e2,.01,0)-x(v.yz*2.+1.5,.15,0);"
"a=n(vec3(v.x,v.y+C+.05,v.z),vec3(2,.2,C))-.05,l=min(l,a),C+=.2;"
"l+=x(v.xz*50.+2e2,.007,0);"
"c=min(c,l);"
"if(c==l)"
"z=2.;"
@ -125,7 +130,7 @@ const char *__temp_cleaned_shader_glsl =
"{"
"vec2 f=v.xy;"
"for(int i=0;i<4;i++)"
"b=t((f+y)*E,g)+t((f-y)*E,g),e+=b*D,f*=mat2(1.6,1.2,-1.2,1.6),E*=1.9,D*=.22,g=mix(g,1.,.4);"
"b=t((f+y)*D,E)+t((f-y)*D,E),e+=b*B,f*=mat2(1.6,1.2,-1.2,1.6),D*=1.9,B*=.22,E=mix(E,1.,.4);"
"}"
"l=max(max(-s(v,2.,min(2.-(y-23.)*3.,2.3)),s(v,.025,1.6)-e*.15),s(v,.3,1.7));"
"c=min(c,l);"
@ -133,32 +138,36 @@ const char *__temp_cleaned_shader_glsl =
"z=1.;"
"l=v.y+3.7+x(vec2(v.x,v.z*.44-40.)*.04+1e2,20.,0)+.25*sin(v.z*.5+y);"
"c=min(c,l);"
"if(c==l)"
"z=3.;"
"l=s(v+vec3(-75,0,100));"
"c=min(c,l);"
"if(c==l)"
"z=3.;"
"for(float f=0.;f<8.;f++)"
"{"
"r=24.67/(m*2.);"
"a=v;"
"p=v;"
"d=r+(f+1.)*m/4.;"
"if(f==1.)"
"d+=.2;"
"if(f==7.)"
"d-=.2;"
"a.xy=n(d)*a.xy;"
"float p=9.+(f-1.)*2.+1.5;"
"p.xy=n(d)*p.xy;"
"float x=9.+(f-1.)*2.+1.5;"
"if(f>0.)"
"{"
"a.x-=1.95;"
"vec3 v=a;"
"if(y>p)"
"v.x=t(vec2(v.x,p));"
"float f=s(vec3(a.x-.06,a.yz),vec2(.1,.15))-.01;"
"p.x-=1.95;"
"vec3 v=p;"
"if(y>x)"
"v.x=w(vec2(v.x,x));"
"float f=s(vec3(p.x-.06,p.yz),vec2(.1,.15))-.01;"
"l=min(max(-s(vec3(v.x-.14,v.yz),vec2(.22))-.01,s(vec3(v),vec2(.2,.12))-.02),f);"
"c=min(c,l);"
"if(c==l)"
"z=4.;"
"if(c==f)"
"if(y>p+.2)"
"if(y>x+.2)"
"z=5.,i=min(l,f);"
"}"
"}"
@ -170,26 +179,26 @@ const char *__temp_cleaned_shader_glsl =
"float i=0.;"
"for(int c=0;c<100;c++)"
"{"
"m=x(v+y*i,0);"
"m=w(v+y*i,0);"
"if(f==0&&m.z<.3)"
"z+=.05/(1.+10.*pow(m.z,.5));"
"i+=m.x;"
"if(m.x<.001||i>4e2)"
"if(m.x<.001||i>5e2)"
"break;"
"}"
"return i;"
"}"
"vec3 w(vec3 v)"
"vec3 r(vec3 v)"
"{"
"vec2 y=vec2(.01,0);"
"return f(x(v,1).x-vec3(x(v-y.xyy,1).x,x(v-y.yxy,1).x,x(v-y.yyx,1)));"
"return f(w(v,1).x-vec3(w(v-y.xyy,1).x,w(v-y.yxy,1).x,w(v-y.yyx,1)));"
"}"
"float f(vec3 v,vec3 y,float m,vec3 z)"
"float f(vec3 v,vec3 y,float m,vec3 x)"
"{"
"float i=1.;"
"vec3 l=f(y-v);"
"i=f(dot(z,l),0.,i);"
"float c=t(v+z*.0025,l,1);"
"i=f(dot(x,l),0.,i);"
"float c=t(v+x*.0025,l,1);"
"if(c<length(y-v))"
"i*=m;"
"return i;"
@ -198,11 +207,11 @@ const char *__temp_cleaned_shader_glsl =
"{"
"return pow(max(dot(reflect(f,v),y),0.),l)*((l+8.)/(m*8.));"
"}"
"vec3 s(vec3 v,vec3 y,vec3 m,vec3 l)"
"vec3 r(vec3 v,vec3 y,vec3 m,vec3 l)"
"{"
"return F+pow(dot(y,m)*.4+.6,60.)*K*.3-vec3(.73,.15,.66)*pow(f(1.-dot(y,-l),0.,1.),.7)+vec3(n(y,m,l,60.))*.2;"
"return vec3(0,.1,.3)+pow(dot(y,m)*.4+.6,60.)*vec3(.11,.16,.18)*.3-vec3(.73,.15,.66)*pow(f(1.-dot(y,-l),0.,1.),.7)+vec3(n(y,m,l,60.))*.2;"
"}"
"vec3 t(vec2 v,vec3 y,vec3 i,float m)"
"vec3 s(vec2 v,vec3 y,vec3 i,float m)"
"{"
"y=f(i-y);"
"i=f(cross(vec3(0,1,0),y));"
@ -233,7 +242,7 @@ const char *__temp_cleaned_shader_glsl =
"if(y>12.)"
"v=vec3(0);"
"if(y>13.5)"
"v=mix(d,i,(y-13.5)*.13);"
"v=mix(vec3(1.5,1.4,0),vec3(-1.5,1.4,0),(y-13.5)*.13);"
"if(y>19.5)"
"v=vec3(0);"
"return v;"
@ -242,8 +251,8 @@ const char *__temp_cleaned_shader_glsl =
"{"
"if(y>10.75)"
"{"
"float f=smoothstep(-1.,.8,sin(s(vec3(.8,10.75,8))*2.));"
"v=mix(v,f*1.4*C,f*.76);"
"float f=smoothstep(-1.,.8,sin(x(vec3(.8,10.75,8))*2.));"
"v=mix(v,f*1.4*a,f*.76);"
"}"
"return v;"
"}"
@ -251,38 +260,38 @@ const char *__temp_cleaned_shader_glsl =
"{"
"return vec3(n(v,f(vec3(0,.3,.8)),f(y),pow(10.,l)))*m;"
"}"
"vec3 e(vec2 v)"
"vec3 d(vec2 v)"
"{"
"vec3 m=f(),i=t(v,m,n(),f((28.-y)*-2.,2.,25.)),d=vec3(0);"
"float K=t(m,i,0),g=0.;"
"if(K<2e2)"
"vec3 m=f(),l=s(v,m,n(),f((28.-y)*-2.,2.,25.)),i=vec3(0);"
"float c=t(m,l,0),d=0.;"
"if(c<5e2)"
"{"
"vec3 v=m+i*K,y=w(v);"
"g=x(v,0).y;"
"d+=l*f(v,vec3(10,15,25),.2,y);"
"d+=r*f(v,vec3(4,2,-15),1.,y);"
"d+=c*f(dot(y,f(vec3(0,1,10))),0.,1.);"
"if(g==0.)"
"d*=vec3(.2,.3,.3)+h(y,i,.5,2.);"
"if(g==1.)"
"d=s(v,y,f(vec3(0,.3,.8)),f(i));"
"if(g==2.)"
"d*=vec3(.8,.8,.5);"
"if(g==3.)"
"d*=vec3(.8,.8,.5)+x(v.xz*5e2+1e5,.3,0);"
"if(g==4.)"
"d*=vec3(0,.08,.11)+h(y,i,.3,.7);"
"if(g==5.)"
"d=C*.4;"
"if(g==6.)"
"d*=vec3(.01,.04,.06)+h(y,i,.1,2.5);"
"vec3 v=m+l*c,y=r(v);"
"d=w(v,0).y;"
"i+=vec3(.82,.5,.9)*f(v,vec3(10,15,25),.2,y);"
"i+=vec3(.79,.66,.43)*f(v,vec3(4,2,-15),1.,y);"
"i+=vec3(.29,.28,.33)*f(dot(y,f(vec3(0,1,10))),0.,1.);"
"if(d==0.)"
"i*=vec3(.2,.3,.3)+h(y,l,.5,2.);"
"if(d==1.)"
"i=r(v,y,f(vec3(0,.3,.8)),f(l));"
"if(d==2.)"
"i*=vec3(.7,.7,.4)+x(v.xz*3.+1.5,.1,0);"
"if(d==3.)"
"i*=vec3(.8,.8,.5)+x(v.xz*5e2+1e5,.3,0);"
"if(d==4.)"
"i*=vec3(0,.08,.11)+h(y,l,.3,.7);"
"if(d==5.)"
"i=a*.4;"
"if(d==6.)"
"i*=vec3(.01,.04,.06)+h(y,l,.1,2.5);"
"}"
"d+=z*C*3.;"
"return smoothstep(0.,1.,pow(h(mix(d,mix(a,p,pow(max(dot(i,vec3(0,-.1,-1)),0.),8.)),1.-exp(-K*.01)))*vec3(.9,.8,.7),vec3(.45)))+1.-vec3(f((31.-y)*.5,0.,1.));"
"i+=z*a*3.;"
"return smoothstep(0.,1.,pow(h(mix(i,mix(vec3(.34,.11,.34),vec3(.93,.37,.16),pow(max(dot(l,vec3(0,-.1,-1)),0.),8.)),1.-exp(-c*.01)))*vec3(.9,.8,.7),vec3(.45)))+1.-vec3(f((31.-y)*.5,0.,1.));"
"}"
"void main()"
"{"
"gl_FragColor=vec4(e((gl_FragCoord.xy*2.-v.xy)/v.y),1);"
"gl_FragColor=vec4(d((gl_FragCoord.xy*2.-v.xy)/v.y),1);"
"}";
#endif // SHADER_MINIFIED_H_