An infinite black-and-white lattice, flown through in twenty lines of code.
A genuine three-dimensional scene — depth, surfaces, a camera gliding forward — conjured from about twenty lines. There are no models and no triangles. Instead a ray is fired through every pixel and marched forward until it bumps into a surface defined purely by arithmetic. The surface here is a
for (float i=0.; i<90. && dd>.001 && d<2.; i++) {
d += dd;
p += rd*d;
dd = map(p)*.02;
}The
The whole world is one function. Its core is the dot(sin(p), cos(p.zxy)) — a single expression that carves a smooth, three-way-symmetric lattice out of empty space. This shader nests one gyroid inside another and multiplies in high-frequency sine waves, so the lattice ripples and shears as you move through it.
#define gyr(p) dot(sin(p.xyz), cos(p.zxy))It isn’t a true distance field — the values are only roughly proportional to real distance — which is why the march takes cautious 0.02-scaled steps instead of full ones.
Once a ray lands, the surface
vec3 n = norm(p);
float bw = n.x + n.y;
bw *= SS(.9, .15, 1./d); // fog out the far distance