Page 1 of 1

Menger's sponge

Posted: Fri Feb 03, 2017 2:53 pm
by shviller
So I made a depth 5 Menger's sponge, and it worked well enough I decided I can throw some ghetto SSAA on top of it (a 3200x2400 RenderTarget for a 800x600 window). Drag LMB to rotate, wheel to zoom.

A friend complained that his laptop can't properly handle a depth 4 sponge in XScreenSaver, and depth 5 is entirely unbearable. I said it shouldn't lag unless it's just straight up made from 3200000 individual cubes (and even that should probably work fine on modern hardware), so I tried to show how it can be made with a lot fewer polygons.

This is how I did it: the M₅ mesh is made from 20 M₄ meshes, and M₄ is 6 (one for each cardinal direction) stacks of 81 textured quads, the quad being an entire cross-section of the sponge, its texture coming from an atlas of 16 81x81 bitmaps. Fewer than 20K polys in total, and one 324x324 texture.

Many thanks to Kjell for answering a lot of dumb questions I threw his way while making this, and for straight up making the camera controls (with all the quat math) for me.

I hope this cheeky thing inspires someone to do something cool. :)

Re: Menger's sponge

Posted: Fri Feb 03, 2017 4:51 pm
by VilleK
Cool! Thanks for sharing. Works fine here.