Subdivision Surfaces

Sunday, 19 April 2009.


An implementation of the Catmull-Clark subdivision algorithm. In case you've never heard of it, it is an algorithm for turning a very jagged surface into a very smooth one. It may be most familiar to some as the way Pixar creates smooth 3D models for their movies (the Catmull of Catmull-Clark happens to be the current president of Pixar and Disney).



If you click and hold the mouse, you can see the original (jagged) surface. If you let go, you can see the smoothed surface that is the result of applying the smoothing algorithm twice.

If you look closely at the code, you'll notice that I create sentinel squares at the edges of the mesh when I subdivide it—this is to prevent the edges of the mesh from flying all over the place during subdivision (since the algorithm was really designed for closed models, not surfaces).

The code feels like it should have ended up smaller; after all, it’s a common effect in 4KB demos. Maybe I'll figure out a good way to simplify it.


Lavender, the Lonely Pink Elephant