float map(vec3 p){ vec3 p2 = p;
vec3 p3 = p;
vec3 p4 = p;
vec3 p5 = p;
vec3 re2 = vec3(4.);
p2 = mod(p2+re2*vec3(0.5,0.5,0.),re2)-re2*0.5;
p3 = mod(p3+re2*vec3(0.5,0.,0.5),re2)-re2*0.5;
p4 = mod(p4+re2*vec3(0.,0.5,0.5),re2)-re2*0.5;
p5 = mod(p5+re2*vec3(0.),re2)-re2*0.5;
float d5 = min(min(min(box(p2,vec3(1.)),box(p3,vec3(1.))),box(p4,vec3(1.))),box(p5,vec3(1.)));
float d5i = max(-100.,-d5); vec3 pl = abs(p); if(pl.x>pl.z)pl.x=pl.z; if(pl.x>pl.y)pl.x=pl.y;
vec3 pl2 =abs(p);
if(pl2.x>pl2.y)pl2.x=pl2.y;
if(pl2.x<pl2.z)pl2.x=pl2.z;
vec3 pl3 =abs(p);
if(pl3.x<pl3.y)pl3.x=pl3.y;
float tl = 0.25;
float d6 = clamp(length(fract(pl.x*1.5)-0.5)-0.2,-10.,tl); float d7 = clamp(length(fract(pl2.x*1.5)-0.5)-0.2,-10.,tl);
float d8 = clamp(length(fract(pl3.x*1.5)-0.5)-0.2,-10.,tl);
float d7b = max(d7,d8);
float d9 = box(p,vec3(4.5)); vec3 p9 = (p+0.5)/5.;
float di = max(d6,d5);
float di2 = max(d7b,d5i);
float di3 = min(di,di2);
float dt =max(di3,d9);
return dt;
}