kamera ajotukset + valo

This commit is contained in:
2024-08-02 16:29:20 +03:00
parent 68820b5366
commit 405f72dce6
3 changed files with 74 additions and 65 deletions

View File

@ -43,7 +43,7 @@ USE_WIDECHAR_TEXTS=1
########### Time base ########### ########### Time base ###########
USE_TIME_DIVIDER_IN_X86_CODE=1 USE_TIME_DIVIDER_IN_X86_CODE=1
TIME_DIVIDER=96218.180 TIME_DIVIDER=89694.914
TIME_BASE=bars TIME_BASE=bars
AUDIO_DELAY=2048 AUDIO_DELAY=2048
@ -66,4 +66,4 @@ AUDIO_SAMPLING_RATE=44100
LOOP_END=28.0 LOOP_END=28.0
LOOP_START=24.0 LOOP_START=24.0
LOOP_ENABLED=0 LOOP_ENABLED=0
TIME_DIVIDER_INT=96218 TIME_DIVIDER_INT=89694

View File

@ -112,7 +112,7 @@ float calcFactor (float startTime)
// Animate ring movements // Animate ring movements
vec3 ringAnim(vec3 p) { vec3 ringAnim(vec3 p) {
for (float i = 0.; i < 7.; i++) { 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(u_time > rotateDelay) {
if(mod(i,2.) >= 1.) o = -1.; if(mod(i,2.) >= 1.) o = -1.;
p.xy *= rot2D(calcFactor(rotateDelay)*o); p.xy *= rot2D(calcFactor(rotateDelay)*o);
@ -191,7 +191,7 @@ vec3 map(vec3 p, int displace)
choppy = mix(choppy,1.0,0.4); 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)); d2 = max(d2, sdCappedCylinder ( p, 0.3, 1.7));
d = min(d, d2); d = min(d, d2);
if (d==d2) { if (d==d2) {
@ -216,7 +216,7 @@ vec3 map(vec3 p, int displace)
if (i == 1.) anRot += .2; if (i == 1.) anRot += .2;
if (i == 7.) anRot -= .2; if (i == 7.) anRot -= .2;
q.xy = rot2D(anRot) * q.xy; 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 // We can now call each prism by it's index
// draw all except the middle bottom prism // draw all except the middle bottom prism
if (i > 0.) { if (i > 0.) {
@ -266,9 +266,10 @@ vec3 getNormal(vec3 p) {
return no(n); 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); 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); d = rayMarch(p+n*.0025, l, 1);
if(d<length(lightPos-p)) dif *= shadow; if(d<length(lightPos-p)) dif *= shadow;
return dif; return dif;
@ -322,7 +323,7 @@ vec3 postProcess(vec3 col) {
col = smoothstep(0., 1., col); col = smoothstep(0., 1., col);
// fade out at the end // fade out at the end
col += 1.0 - vec3(cl((31. - u_time)*.5, 0., 1.0)); col += 1.0 - vec3(cl((46. - u_time)*.5, 0., 1.0));
return col; return col;
} }
@ -335,18 +336,23 @@ vec3 cameraPos()
if (u_time > 10.5) cPos = vec3(2.,-1.,1.); if (u_time > 10.5) cPos = vec3(2.,-1.,1.);
// zoom away for 2nd glyph animation // zoom away for 2nd glyph animation
if (u_time > 12.) cPos = vec3(-1., -.7, 4.); 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 = vec3(0., 0., 4.);
cPos.yz *= rot2D(-0.6-(cos(u_time-15.))*0.2); cPos.yz *= rot2D(-0.6-(cos(u_time-15.))*0.05);
cPos.xz *= rot2D(sin((u_time-16.5)*0.3)); 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.); cPos = vec3(3., -.7, 4.);
} }
if (u_time > 21.8) { if (u_time > 32.5)
cPos.yz *= rot2D(((1.-cos(u_time-21.8))*-0.025)); {
cPos.xz *= rot2D(sin((u_time-21.8)*0.07)); 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; return cPos;
@ -358,8 +364,8 @@ vec3 cameraPointAt() {
if (u_time > 10.5) p = vec3(1.7,-1.1,0.); if (u_time > 10.5) p = vec3(1.7,-1.1,0.);
// look gate at distance // look gate at distance
if(u_time > 12.) p = vec3(0.); 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 > 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 > 19.5) p = vec3(0.); if(u_time > 23.5) p = vec3(0.);
return p; return p;
} }
@ -381,7 +387,7 @@ vec3 sceneGate(vec2 uv)
{ {
// Initialization // Initialization
vec3 ro = cameraPos(), 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.); col = vec3(0.);
float d = rayMarch(ro, rd,0), mat = 0.; float d = rayMarch(ro, rd,0), mat = 0.;
@ -397,15 +403,16 @@ vec3 sceneGate(vec2 uv)
// 4: Shadow intensity // 4: Shadow intensity
// Lights // Lights
col += vec3(0.82, 0.5, 0.9) * getLight(p, vec3( 10., 15., 25.), 1., .2,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); 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 // 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.); col += vec3(0.29, 0.28, 0.33) * cl( dot( n, no(vec3(0. , 1., 10.))), 0., 1.);
if(mat==0.) if(mat==0.)
col *= vec3(0.2, 0.3, 0.3) + addSpecular(n,rd,.5, 2.); col *= vec3(0.2, 0.3, 0.3) + addSpecular(n,rd,.5, 2.);
if(mat==1.) 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.) if(mat==2.)
col *= vec3(0.7, 0.7, 0.4) + noise (p.xz*3.+1.5, 0.1,0); col *= vec3(0.7, 0.7, 0.4) + noise (p.xz*3.+1.5, 0.1,0);
if(mat==3.) if(mat==3.)

View File

@ -78,7 +78,7 @@ const char *__temp_cleaned_shader_glsl =
"{" "{"
"for(float i=0.;i<7.;i++)" "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(y>m)"
"{" "{"
"if(mod(i,2.)>=1.)" "if(mod(i,2.)>=1.)"
@ -132,7 +132,7 @@ const char *__temp_cleaned_shader_glsl =
"for(int i=0;i<4;i++)" "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);" "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);" "c=min(c,l);"
"if(c==l)" "if(c==l)"
"z=1.;" "z=1.;"
@ -153,7 +153,7 @@ const char *__temp_cleaned_shader_glsl =
"if(f==7.)" "if(f==7.)"
"d-=.2;" "d-=.2;"
"p.xy=n(d)*p.xy;" "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.)" "if(f>0.)"
"{" "{"
"p.x-=1.95;" "p.x-=1.95;"
@ -187,30 +187,29 @@ const char *__temp_cleaned_shader_glsl =
"}" "}"
"return i;" "return i;"
"}" "}"
"vec3 r(vec3 v)" "vec3 h(vec3 v)"
"{" "{"
"vec2 y=vec2(.01,0);" "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)));" "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);" "vec3 l=f(y-v);"
"i=f(dot(x,l),0.,i);" "i=f(dot(c,l)*i,0.,i)/(1.+r*length(y-v));"
"float c=t(v+x*.0025,l,1);" "r=t(v+c*.0025,l,1);"
"if(c<length(y-v))" "if(r<length(y-v))"
"i*=m;" "i*=m;"
"return i;" "return i;"
"}" "}"
"float n(vec3 v,vec3 y,vec3 f,float l)" "float f(vec3 v,vec3 y,vec3 f,float l)"
"{" "{"
"return pow(max(dot(reflect(f,v),y),0.),l)*((l+8.)/(m*8.));" "return pow(max(dot(reflect(f,v),y),0.),l)*((l+8.)/(m*8.));"
"}" "}"
"vec3 r(vec3 v,vec3 y,vec3 m,vec3 l)" "vec3 h(vec3 v,vec3 y,vec3 m,vec3 l)"
"{" "{"
"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;" "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(f(y,m,l,60.))*.2;"
"}" "}"
"vec3 s(vec2 v,vec3 y,vec3 i,float m)" "vec3 n(vec2 v,vec3 y,vec3 i,float m)"
"{" "{"
"y=f(i-y);" "y=f(i-y);"
"i=f(cross(vec3(0,1,0),y));" "i=f(cross(vec3(0,1,0),y));"
@ -225,28 +224,30 @@ const char *__temp_cleaned_shader_glsl =
"v=vec3(2,-1,1);" "v=vec3(2,-1,1);"
"if(y>12.)" "if(y>12.)"
"v=vec3(-1,-.7,4);" "v=vec3(-1,-.7,4);"
"if(y>13.5)" "if(y>14.5)"
"v=vec3(0,0,4),v.yz*=n(-.6-cos(y-15.)*.2),v.xz*=n(sin((y-16.5)*.3));" "v=vec3(0,0,4),v.yz*=n(-.6-cos(y-15.)*.05),v.xz*=n(sin((y-16.5)*.1));"
"if(y>19.5)" "if(y>23.5)"
"v=vec3(3,-.7,4);" "v=vec3(3,-.7,4);"
"if(y>21.8)" "if(y>32.5)"
"v.yz*=n((1.-cos(y-21.8))*-.025),v.xz*=n(sin((y-21.8)*.07));" "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;" "return v;"
"}" "}"
"vec3 n()" "vec3 h()"
"{" "{"
"vec3 v=vec3(0,-.5,0);" "vec3 v=vec3(0,-.5,0);"
"if(y>10.5)" "if(y>10.5)"
"v=vec3(1.7,-1.1,0);" "v=vec3(1.7,-1.1,0);"
"if(y>12.)" "if(y>12.)"
"v=vec3(0);" "v=vec3(0);"
"if(y>13.5)" "if(y>14.5)"
"v=mix(vec3(1.5,1.4,0),vec3(-1.5,1.4,0),(y-13.5)*.13);" "v=mix(vec3(1.5,1.4,0),vec3(-1.5,1.4,0),(y-16.5)*.13);"
"if(y>19.5)" "if(y>23.5)"
"v=vec3(0);" "v=vec3(0);"
"return v;" "return v;"
"}" "}"
"vec3 h(vec3 v)" "vec3 r(vec3 v)"
"{" "{"
"if(y>10.75)" "if(y>10.75)"
"{" "{"
@ -255,38 +256,39 @@ const char *__temp_cleaned_shader_glsl =
"}" "}"
"return v;" "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 d(vec2 v)"
"{" "{"
"vec3 m=f(),l=s(v,m,n(),f((28.-y)*-2.,2.,25.)),i=vec3(0);" "vec3 m=f(),l=n(v,m,h(),f((43.-y)*-2.,2.,25.)),i=vec3(0);"
"float c=t(m,l,0),d=0.;" "float c=t(m,l,0),s=0.;"
"if(c<5e2)" "if(c<5e2)"
"{" "{"
"vec3 v=m+l*c,y=r(v);" "vec3 v=m+l*c,z=h(v);"
"d=w(v,0).y;" "s=w(v,0).y;"
"i+=vec3(.82,.5,.9)*f(v,vec3(10,15,25),.2,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.,y);" "i+=vec3(.79,.66,.43)*f(v,vec3(4,2,-15),1.,1.,z,1e-10);"
"i+=vec3(.29,.28,.33)*f(dot(y,f(vec3(0,1,10))),0.,1.);" "i+=vec3(0,.06,.7)*f(v,vec3(0,0,5),f((y-29.)*1e2,0.,50.),0.,z,3.1);"
"if(d==0.)" "i+=vec3(.29,.28,.33)*f(dot(z,f(vec3(0,1,10))),0.,1.);"
"i*=vec3(.2,.3,.3)+h(y,l,.5,2.);" "if(s==0.)"
"if(d==1.)" "i*=vec3(.2,.3,.3)+r(z,l,.5,2.);"
"i=r(v,y,f(vec3(0,.3,.8)),f(l));" "if(s==1.)"
"if(d==2.)" "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);" "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);" "i*=vec3(.8,.8,.5)+x(v.xz*5e2+1e5,.3,0);"
"if(d==4.)" "if(s==4.)"
"i*=vec3(0,.08,.11)+h(y,l,.3,.7);" "i*=vec3(0,.08,.11)+r(z,l,.3,.7);"
"if(d==5.)" "if(s==5.)"
"i=a*.4;" "i=a*.4;"
"if(d==6.)" "if(s==6.)"
"i*=vec3(.01,.04,.06)+h(y,l,.1,2.5);" "i*=vec3(.01,.04,.06)+r(z,l,.1,2.5);"
"}" "}"
"i+=z*a*.25;" "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()" "void main()"
"{" "{"