Mapping a Cube to a Sphere

I’m 3D printing a shell to transform an 8x8x8 LED cube into a sphere, and it’s halfway done. Each of the 6 identical pieces takes about 9 hours to print. The three segments in the video are held together with duct tape.

I’d love to reduce the light bleed between pixels a bit by using opaque filament everywhere but the outer surface, but I’d need a dual extruder printer to make that work.

I’ve been working on the mapping and code while the other parts are printing, and it’s been a good refresher in spherical coordinates. I was particularly happy to realize that when all pixel positions lie on the surface of a sphere, you can alter many existing 2D patterns to work by calculating the spherical coordinates (rho, theta, phi) of each pixel, normalizing theta and phi to [0,1], then calling render2D(index, theta, phi) instead of render2D(index, x, y).