From 405f72dce6558acd9e2a367e6f35cf4cf996f45e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20J=C3=A4rvisalo?= Date: Fri, 2 Aug 2024 16:29:20 +0300 Subject: [PATCH] kamera ajotukset + valo --- base.config | 4 +-- shader.glsl | 45 ++++++++++++++---------- shader_minified.h | 90 ++++++++++++++++++++++++----------------------- 3 files changed, 74 insertions(+), 65 deletions(-) diff --git a/base.config b/base.config index 84ebf72..699f986 100644 --- a/base.config +++ b/base.config @@ -43,7 +43,7 @@ USE_WIDECHAR_TEXTS=1 ########### Time base ########### USE_TIME_DIVIDER_IN_X86_CODE=1 -TIME_DIVIDER=96218.180 +TIME_DIVIDER=89694.914 TIME_BASE=bars AUDIO_DELAY=2048 @@ -66,4 +66,4 @@ AUDIO_SAMPLING_RATE=44100 LOOP_END=28.0 LOOP_START=24.0 LOOP_ENABLED=0 -TIME_DIVIDER_INT=96218 +TIME_DIVIDER_INT=89694 diff --git a/shader.glsl b/shader.glsl index 346286c..b5a6002 100644 --- a/shader.glsl +++ b/shader.glsl @@ -112,7 +112,7 @@ float calcFactor (float startTime) // Animate ring movements vec3 ringAnim(vec3 p) { for (float i = 0.; i < 7.; i++) { - float rotateDelay = STARTDELAY + (i * 2.), o=1.; + float rotateDelay = STARTDELAY + (i * 3.), o=1.; if(u_time > rotateDelay) { if(mod(i,2.) >= 1.) o = -1.; p.xy *= rot2D(calcFactor(rotateDelay)*o); @@ -191,7 +191,7 @@ vec3 map(vec3 p, int displace) choppy = mix(choppy,1.0,0.4); } } - d2 = max(-sdCappedCylinder(p, 2.0, min((2.0 - (u_time - 23.0)*3.),2.3)), sdCappedCylinder(p, .025, 1.6) - h*0.15); + d2 = max(-sdCappedCylinder(p, 2.0, min((1.7 - (u_time - 28.9)*2.5),2.3)), sdCappedCylinder(p, .025, 1.6) - h*0.15); d2 = max(d2, sdCappedCylinder ( p, 0.3, 1.7)); d = min(d, d2); if (d==d2) { @@ -216,7 +216,7 @@ vec3 map(vec3 p, int displace) if (i == 1.) anRot += .2; if (i == 7.) anRot -= .2; q.xy = rot2D(anRot) * q.xy; - float rotateDelay = STARTDELAY + (i - 1.) * 2. + 1.5; + float rotateDelay = STARTDELAY + (i - 1.) * 3. + 1.5; // We can now call each prism by it's index // draw all except the middle bottom prism if (i > 0.) { @@ -266,9 +266,10 @@ vec3 getNormal(vec3 p) { return no(n); } -float getLight(vec3 p, vec3 lightPos, float intensity, float shadow, vec3 n) { +float getLight(vec3 p, vec3 lightPos, float intensity, float shadow, vec3 n, float atte) { vec3 l = no(lightPos - p); - float dif = cl(dot(n, l), 0., intensity), + float len = length( lightPos - p ); // Distance from the light to the surface point. + float dif = cl(dot(n, l)*intensity, 0., intensity) * 1.0 / (1.0 + atte*len), d = rayMarch(p+n*.0025, l, 1); if(d 10.5) cPos = vec3(2.,-1.,1.); // zoom away for 2nd glyph animation if (u_time > 12.) cPos = vec3(-1., -.7, 4.); - if (u_time > 13.5) { + if (u_time > 14.5) { cPos = vec3(0., 0., 4.); - cPos.yz *= rot2D(-0.6-(cos(u_time-15.))*0.2); - cPos.xz *= rot2D(sin((u_time-16.5)*0.3)); + cPos.yz *= rot2D(-0.6-(cos(u_time-15.))*0.05); + cPos.xz *= rot2D(sin((u_time-16.5)*0.1)); } - if (u_time > 19.5) + if (u_time > 23.5) { cPos = vec3(3., -.7, 4.); } - if (u_time > 21.8) { - cPos.yz *= rot2D(((1.-cos(u_time-21.8))*-0.025)); - cPos.xz *= rot2D(sin((u_time-21.8)*0.07)); + if (u_time > 32.5) + { + cPos = vec3(-20.,10.,50.); + } + if (u_time > 36.5) { + cPos = vec3(3., -.7, 4.); + cPos.yz *= rot2D(((1.-cos(u_time-36.5))*-0.025)); + cPos.xz *= rot2D(sin((u_time-36.5)*0.07)); } return cPos; @@ -358,8 +364,8 @@ 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(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.); + if(u_time > 14.5) p = mix(vec3(1.5,1.4,0.0),vec3(-1.5,1.4,0.0), (u_time-16.5)*0.13); + if(u_time > 23.5) p = vec3(0.); return p; } @@ -381,7 +387,7 @@ vec3 sceneGate(vec2 uv) { // Initialization vec3 ro = cameraPos(), - rd = getCameraRayDir(uv, ro, cameraPointAt(), cl((28.-u_time)*-2.,2.,25.)), + rd = getCameraRayDir(uv, ro, cameraPointAt(), cl((43.-u_time)*-2.,2.,25.)), col = vec3(0.); float d = rayMarch(ro, rd,0), mat = 0.; @@ -397,15 +403,16 @@ vec3 sceneGate(vec2 uv) // 4: Shadow intensity // Lights - 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); + col += vec3(0.82, 0.5, 0.9) * getLight(p, vec3( 10., 15., 25.), 1., .2,n,1e-10); + col += vec3(0.79, 0.66, 0.43) * getLight(p, vec3( 4., 2., -15.), 1., 1.,n,1e-10); + col += vec3(0.0, 0.06, 0.7) * getLight(p, vec3( 0., 0., 5.),cl((u_time-29.0)*100.,0.,50.), 0.0,n,3.1); // indirect lightning -> vec3 in normalize is light direction 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)); + col *= getSeaColor(p, n, no(vec3(0.0,0.3,0.8)),no(rd)); if(mat==2.) col *= vec3(0.7, 0.7, 0.4) + noise (p.xz*3.+1.5, 0.1,0); if(mat==3.) diff --git a/shader_minified.h b/shader_minified.h index 4b4381d..3a70bb6 100644 --- a/shader_minified.h +++ b/shader_minified.h @@ -78,7 +78,7 @@ const char *__temp_cleaned_shader_glsl = "{" "for(float i=0.;i<7.;i++)" "{" - "float m=9.+i*2.,z=1.;" + "float m=9.+i*3.,z=1.;" "if(y>m)" "{" "if(mod(i,2.)>=1.)" @@ -132,7 +132,7 @@ const char *__temp_cleaned_shader_glsl = "for(int i=0;i<4;i++)" "b=t((f+y)*E,C)+t((f-y)*E,C),e+=b*D,f*=mat2(1.6,1.2,-1.2,1.6),E*=1.9,D*=.22,C=mix(C,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));" + "l=max(max(-s(v,2.,min(1.7-(y-28.9)*2.5,2.3)),s(v,.025,1.6)-e*.15),s(v,.3,1.7));" "c=min(c,l);" "if(c==l)" "z=1.;" @@ -153,7 +153,7 @@ const char *__temp_cleaned_shader_glsl = "if(f==7.)" "d-=.2;" "p.xy=n(d)*p.xy;" - "float r=9.+(f-1.)*2.+1.5;" + "float r=9.+(f-1.)*3.+1.5;" "if(f>0.)" "{" "p.x-=1.95;" @@ -187,30 +187,29 @@ const char *__temp_cleaned_shader_glsl = "}" "return i;" "}" - "vec3 r(vec3 v)" + "vec3 h(vec3 v)" "{" "vec2 y=vec2(.01,0);" "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 x)" + "float f(vec3 v,vec3 y,float i,float m,vec3 c,float r)" "{" - "float i=1.;" "vec3 l=f(y-v);" - "i=f(dot(x,l),0.,i);" - "float c=t(v+x*.0025,l,1);" - "if(c12.)" "v=vec3(-1,-.7,4);" - "if(y>13.5)" - "v=vec3(0,0,4),v.yz*=n(-.6-cos(y-15.)*.2),v.xz*=n(sin((y-16.5)*.3));" - "if(y>19.5)" + "if(y>14.5)" + "v=vec3(0,0,4),v.yz*=n(-.6-cos(y-15.)*.05),v.xz*=n(sin((y-16.5)*.1));" + "if(y>23.5)" "v=vec3(3,-.7,4);" - "if(y>21.8)" - "v.yz*=n((1.-cos(y-21.8))*-.025),v.xz*=n(sin((y-21.8)*.07));" + "if(y>32.5)" + "v=vec3(-20,10,50);" + "if(y>36.5)" + "v=vec3(3,-.7,4),v.yz*=n((1.-cos(y-36.5))*-.025),v.xz*=n(sin((y-36.5)*.07));" "return v;" "}" - "vec3 n()" + "vec3 h()" "{" "vec3 v=vec3(0,-.5,0);" "if(y>10.5)" "v=vec3(1.7,-1.1,0);" "if(y>12.)" "v=vec3(0);" - "if(y>13.5)" - "v=mix(vec3(1.5,1.4,0),vec3(-1.5,1.4,0),(y-13.5)*.13);" - "if(y>19.5)" + "if(y>14.5)" + "v=mix(vec3(1.5,1.4,0),vec3(-1.5,1.4,0),(y-16.5)*.13);" + "if(y>23.5)" "v=vec3(0);" "return v;" "}" - "vec3 h(vec3 v)" + "vec3 r(vec3 v)" "{" "if(y>10.75)" "{" @@ -255,38 +256,39 @@ const char *__temp_cleaned_shader_glsl = "}" "return v;" "}" - "vec3 h(vec3 v,vec3 y,float m,float l)" + "vec3 r(vec3 v,vec3 y,float m,float l)" "{" - "return vec3(n(v,f(vec3(0,.3,.8)),f(y),pow(10.,l)))*m;" + "return vec3(f(v,f(vec3(0,.3,.8)),f(y),pow(10.,l)))*m;" "}" "vec3 d(vec2 v)" "{" - "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.;" + "vec3 m=f(),l=n(v,m,h(),f((43.-y)*-2.,2.,25.)),i=vec3(0);" + "float c=t(m,l,0),s=0.;" "if(c<5e2)" "{" - "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.)" + "vec3 v=m+l*c,z=h(v);" + "s=w(v,0).y;" + "i+=vec3(.82,.5,.9)*f(v,vec3(10,15,25),1.,.2,z,1e-10);" + "i+=vec3(.79,.66,.43)*f(v,vec3(4,2,-15),1.,1.,z,1e-10);" + "i+=vec3(0,.06,.7)*f(v,vec3(0,0,5),f((y-29.)*1e2,0.,50.),0.,z,3.1);" + "i+=vec3(.29,.28,.33)*f(dot(z,f(vec3(0,1,10))),0.,1.);" + "if(s==0.)" + "i*=vec3(.2,.3,.3)+r(z,l,.5,2.);" + "if(s==1.)" + "i*=h(v,z,f(vec3(0,.3,.8)),f(l));" + "if(s==2.)" "i*=vec3(.7,.7,.4)+x(v.xz*3.+1.5,.1,0);" - "if(d==3.)" + "if(s==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.)" + "if(s==4.)" + "i*=vec3(0,.08,.11)+r(z,l,.3,.7);" + "if(s==5.)" "i=a*.4;" - "if(d==6.)" - "i*=vec3(.01,.04,.06)+h(y,l,.1,2.5);" + "if(s==6.)" + "i*=vec3(.01,.04,.06)+r(z,l,.1,2.5);" "}" "i+=z*a*.25;" - "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.));" + "return smoothstep(0.,1.,pow(r(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((46.-y)*.5,0.,1.));" "}" "void main()" "{"