Vesi optimoitu

This commit is contained in:
2024-07-28 22:29:00 +03:00
parent f7a6502ea2
commit 1d606da897

View File

@ -51,20 +51,10 @@ float displacement( vec3 p )
// GEOMETRY //
/////////////////
float sdCylinder(vec3 p, vec3 a, vec3 b, float r)
float sdCappedCylinder( vec3 p, float h, float r )
{
vec3 ba = b - a;
vec3 pa = p - a;
float baba = dot(ba,ba);
float paba = dot(pa,ba);
float x = length(pa*baba-ba*paba) - r*baba;
float y = abs(paba-baba*0.5)-baba*0.5;
float x2 = x*x;
float y2 = y*y*baba;
float d = (max(x,y)<0.0)?-min(x2,y2):(((x>0.0)?x2:0.0)+((y>0.0)?y2:0.0));
return sign(d)*sqrt(abs(d))/baba;
vec2 d = abs(vec2(length(p.xy),p.z)) - vec2(r,h);
return min(max(d.x,d.y),0.0) + length(max(d,0.0));
}
float sdBox( in vec2 p, in vec2 r )
@ -281,9 +271,9 @@ vec2 map(in vec3 p)
d = min(d,sand);
float water = 1000.;
float cylinder1 = sdCylinder ( p, vec3(0.,0.,0.0), vec3(0.,0.,-0.01), 1.6);
float cylinder2 = sdCylinder ( p, vec3(0.,0.,1.), vec3(0.,0.,-1), clamp((2.0 - (u_time*2.0 - 2.0*23.0)),0.,2.0));
float cylinder3 = sdCylinder ( p, vec3(0.,0.,1.), vec3(0.,0.,-1.), 1.6);
float cylinder1 = sdCappedCylinder ( p, .025, 1.6);
float cylinder2 = sdCappedCylinder ( p, 2.0, clamp((2.0 - (u_time*2.0 - 2.0*23.0)),0.,2.0));
float cylinder3 = sdCappedCylinder ( p, 0.3, 1.6);
float disp = 0.;
disp = displacement(p)*clamp(((u_time-24.0)*0.5), 0., 0.25);
cylinder1 = cylinder1 + disp;
@ -459,8 +449,6 @@ void main()
float d = rayMarch(ro, rd);
if (d < 500.) {
// Lighting
vec3 p = ro + rd * d;
@ -475,13 +463,6 @@ void main()
float dif = 0.; //getLight(p, vec3( 2, 50, 2), .5, .2);
// Color for light 1
// col = vec3(dif * vec3(0.9216, 0.9294, 0.9412));
// Light 2
dif = getLight(p, vec3( -3, 5, 5), 1., 0.2);
// Color for light 2
@ -491,8 +472,6 @@ void main()
// Color for light 2
col += vec3(dif * light2Color);
vec3 lightPosition = glyph1Pos;
lightPosition.z = lightPosition.z + 0.3;
// dif = getLight(p, lightPosition, 3.75, 1.0);
@ -514,10 +493,6 @@ void main()
col += vec3(dif * glyphColor * att);
}
vec3 n = getNormal(p);
vec3 dir = vec3(1. , 10., 1.);
float ind = clamp( dot( n, normalize(dir )), 0.0, 1.0 );