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.)