uudet musat

This commit is contained in:
2024-07-29 19:35:28 +03:00
2 changed files with 138 additions and 22 deletions

View File

@ -57,11 +57,6 @@ float sdCappedCylinder( vec3 p, float h, float r )
return min(max(d.x,d.y),0.0) + length(max(d,0.0));
}
float sdBox(vec2 p, vec2 r)
{
return length( max(abs(p)-r,0.) );
}
float sdBox2(vec3 p, vec3 b) {
vec3 q = abs(p) - b;
return length(max(q,0.)) + min(max(q.x,max(q.y,q.z)),0.);
@ -107,13 +102,12 @@ SEA_WATER_COLOR =vec3(0.4,0.5,0.3);
// with duration d, startTime s and speed up with timeFact
float timedSine(vec3 i) {
i.y *= i.z;
return PI * min(((u_time * i.z) - i.y) / PI, i.x);
return min((u_time - i.y)*i.z, i.x*PI);
}
float calcFactor (float startTime)
{
return 9. + 9.*clamp(sin(timedSine(vec3(1.5, startTime, 4.)) * 0.06), -.9, .9);
return STARTDELAY + STARTDELAY*clamp(sin(timedSine(vec3(1.5, startTime, 4.)) * 0.06), -.9, .9);
}
// Animate ring movements
@ -156,7 +150,7 @@ vec2 map(vec3 p, int displace)
vec3 q = p;
q.xy = mat2(cos(anRot),-sin(anRot),
sin(anRot), cos(anRot))*q.xy;
float d = sdBox( q.xy - vec2(1.8,0.), vec2(0.24,0.14) ) - .02,
float d = length(max(abs(q.xy - vec2(1.8,0.))-vec2(0.24,0.14),0.)) - .02,
// Main ring
d2 = abs(length(p.xy) - 1.8) - .2;
@ -236,9 +230,8 @@ vec2 map(vec3 p, int displace)
uv *= mat2(1.6,1.2,-1.2,1.6); freq *= 1.9; amp *= 0.22;
choppy = mix(choppy,1.0,0.4);
}
}
float cs = sdCappedCylinder(p, .025, 1.6) - h*0.15;
d2 = max(-sdCappedCylinder(p, 2.0, clamp((2.0 - 3.*(u_time - 23.0)),-.2,2.3)), cs);
}
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(d2, sdCappedCylinder ( p, 0.3, 1.7));
d = min(d, d2);
if (d==d2) mat = 1.0;
@ -326,6 +319,8 @@ vec3 postProcess(vec3 col) {
// Contrast = a
col = smoothstep(0., 1., col);
// fade out at the end
col += 1.2 - vec3(clamp((32. - u_time)*.35, 0., 1.2));
return col;
}
@ -337,8 +332,7 @@ vec3 cameraPos()
// close up shot for 1st glyph lock
if (u_time > 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.) cPos =mix(vec3(-1., -.7, 4.), vec3(0., 0.5, -1.), (u_time - 13.)*0.3);
if (u_time > 12.) cPos = vec3(-1., -.7, 4.);
return cPos;
}
@ -347,8 +341,7 @@ vec3 cameraPointAt() {
// look at 1st glyph
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.) p = mix(vec3(0.), vec3(0., 2., -5.), (u_time - 13.)*0.3);
if(u_time > 12.) p = vec3(0.);
return p;
}
@ -361,6 +354,11 @@ vec3 colorFlashesAnim(vec3 col) {
return col;
}
vec3 addSpecular(vec3 nor, vec3 rod, float amount)
{
return vec3(specular(nor,normalize(vec3(0.0,0.3,0.8)),normalize(rod),60.0))*amount;
}
vec3 sceneGate(vec2 uv)
{
// Initialization
@ -392,16 +390,15 @@ vec3 sceneGate(vec2 uv)
col += indirColor * clamp( dot( n, normalize(vec3(0. , 1., 10.))), 0., 1.);
if(mat==0.)
col *= vec3(.3) + vec3(specular(n,normalize(vec3(0.0,0.3,0.8)),normalize(rd),60.0))*0.5;
if(mat==1.){
col *= vec3(.3) + addSpecular(n,rd,0.5);
if(mat==1.)
col = getSeaColor(p, n, normalize(vec3(0.0,0.3,0.8)),normalize(rd)); //col = vec3(0.,0.,.5); // + (noise(5.*(p.xy+2.)+u_time, -1.0) * noise(50.*(p.xy+2.), -0.4) + 0.5*noise(20.*(p.xy+2.0)-u_time, -0.5) * noise(5.*(p.xy+2.0), -0.75))*smoothstep(0.,0.75,(u_time-5.0)*0.1) + vec3(0.,0.,0.5*noise(10.*(p.xy+4.0)-u_time, -0.5));
}
if(mat==2.)
col *= vec3(.3, .1, .0)+ vec3(specular(n,normalize(vec3(0.0,0.3,0.8)),normalize(rd),60.0))*0.1; // - 0.2*noise((vec2(100.*p.x+300.,75.*p.z+150.0)), -2.2) * noise((vec2(15.*p.x+2.0,3.*p.z+2.)), -1.) + noise((vec2(15.*p.x+2.4,3.*p.z+2.)), -0.25);
col *= vec3(.3, .1, .0)+ addSpecular(n,rd,0.1); // - 0.2*noise((vec2(100.*p.x+300.,75.*p.z+150.0)), -2.2) * noise((vec2(15.*p.x+2.0,3.*p.z+2.)), -1.) + noise((vec2(15.*p.x+2.4,3.*p.z+2.)), -0.25);
if(mat==3.)
col *= vec3(.8, .8, .5) + noise(p.xz*500.+100., .3,0); // + noise(p.xz*1000.+5000., 0.1) + noise(p.xz*1000.+5000., 0.1);
col *= vec3(.8, .8, .5) + noise(p.xz*500.+1e5, .3,0); // + noise(p.xz*1000.+5000., 0.1) + noise(p.xz*1000.+5000., 0.1);
if(mat==4.)
col *= vec3(.1)+ vec3(specular(n,normalize(vec3(0.0,0.3,0.8)),normalize(rd),60.0))*0.5;
col *= vec3(.1)+ addSpecular(n,rd,0.5);
if(mat ==5.)
col *= chevronColor; // activated glyph color