eka merkki lukittu

This commit is contained in:
Teemu Järvisalo
2024-07-27 17:40:11 +03:00
parent fa12676bee
commit 0f6b4dd3e1
2 changed files with 182 additions and 141 deletions

View File

@ -102,7 +102,7 @@ float sdTriPrism( vec3 p, vec2 h, float rot )
// ANIMATION //
//////////////////
const float TWOPI = 6.28318530718;
vec3 lookAtPoint = vec3(0, -1., 0.);
vec3 lookAtPoint = vec3(0, -0.5, 0.);
const vec3 glyph1Pos = vec3(1.7,-1.1,0.0);
const vec3 glyph2Pos = vec3(2.0,0.0,0.0);
@ -123,7 +123,6 @@ float timedSine(float maxCycles, float startTime, float timeFact) {
float calcFactor (float startTime)
{
const float FACTOR = 9.0;
float factor = 9.0 + 9.0*clamp(sin(timedSine(2.0, startTime, 2.5) * 0.05), -0.9, 0.9);
return factor;
}
@ -131,26 +130,24 @@ float calcFactor (float startTime)
// Animate ring movements
vec3 ringAnim( in vec3 p) {
const float STARTDELAY = 9.0;
const float OTHERDELAY = 14.0;
float factor = 0.;
const float OTHERDELAY = 15.0;
// delay start
if( u_time >= STARTDELAY ) {
p.xy = rot2D(calcFactor(STARTDELAY)) * p.xy;
}
// if(u_time >= OTHERDELAY) {
// p.xy = rot2D(calcFactor(OTHERDELAY) * -1.0) * p.xy;
// }
if(u_time >= OTHERDELAY) {
p.xy = rot2D(calcFactor(OTHERDELAY) * -1.0) * p.xy;
}
return p;
}
// Animate prism movements
float prismAnim(in float x, in float delay) {
if(u_time >= delay) {
x += (0.045*clamp(sin((timedSine(2.0, delay, 10.0) * 0.4)),-0.9, 0.9));
if(u_time >= delay && u_time <= delay + 1.0) {
x += (0.045*clamp(sin((timedSine(3.0, delay, 20.0) * 0.4)),-0.8, 0.8));
}
return x;
}
@ -367,51 +364,67 @@ vec3 postProcess(vec3 col) {
return col;
}
// zoom camera on glyph lock for extra oomph
float cameraZoomAnim(float o) {
float delay = 13.45;
if(u_time > delay) {
o -= (0.25 - smoothstep(-0.7,0.5,sin((timedSine(1.5, delay, 8.0))))) * 0.2;
}
return o;
}
vec3 cameraPos()
{
// first zoom in to the gate
vec3 cPos = vec3(0, clamp(6.-u_time,2.,6.), clamp((75.-u_time*8.0),6.,75.));
if (u_time > 7.5)
{
cPos += vec3(0, clamp(7.5-u_time,-1.,0.), 0.);
}
// close up shot for 1st glyph lock
if (u_time > 12.) {
cPos = vec3(2.0,-1.0,1.0);
}
//zoom away for 2nd glyph animation
if (u_time > 15.) {
cPos = vec3(-1.0, -1.0, 4.0);
}
//close up shot for the 2nd glyph lock
cPos.z = cameraZoomAnim(cPos.z);
return cPos;
}
vec3 cameraPointAt(vec3 p) {
// look at 1st glyph
if(u_time > 12.) {
p = glyph1Pos;
}
if(u_time > 15.) {
p = vec3(0.0,0.1,0.0);
}
return p;
}
// flash screen with glyph color when it is locked
vec3 colorFlashesAnim(in vec3 col) {
vec3 flashColor = vec3(0.95, 0.35, 0.06);
float delay = 13.2;
float delay = 13.5;
if(u_time > delay) {
float x = smoothstep(-1.0,0.8,sin((timedSine(0.38, delay*2.0, 2.0)*2.0)));
float x = smoothstep(-1.0,0.8,sin((timedSine(0.8, delay, 8.0)*2.0)));
col = mix(col, flashColor * (x * 1.4), x * 0.76);
}
return col;
}
// zoom camera on glyph lock for extra oomph
float cameraZoomAnim(float o) {
float delay = 13.0;
if(u_time > delay) {
o -= smoothstep(-0.7,0.5,sin((timedSine(0.4, delay, 1.0)*2.0))) * 0.2;
}
return o;
}
void main()
{
// Initialization
@ -419,13 +432,11 @@ void main()
vec3 ro = cameraPos();
vec3 rd = getCameraRayDir(uv, ro, cameraPointAt(lookAtPoint), 1.); // ray direction
vec3 rd = getCameraRayDir(uv, ro, cameraPointAt(lookAtPoint), 2.); // ray direction
vec3 col = vec3(0); // color
float d = rayMarch(ro, rd);
// ro.z = cameraZoomAnim(ro.z);
if (d < 500.) {
// Lighting
vec3 p = ro + rd * d;
@ -476,11 +487,13 @@ void main()
float fogAmount = 0.02;
col = col*exp(-d*fogAmount) + applyFog(col, d, rd, vec3(0., .3, -1.), fogAmount) * (1.0-exp(-d*fogAmount));
// col = colorFlashesAnim(col); // animated color flash
} else {
col = vec3(0.1529, 0.1765, 0.3922) + rd.y * 0.4;
}
col = colorFlashesAnim(col); // animated color flash
gl_FragColor = vec4(postProcess(col), 1);