Strange 3D objects, Perlin noise
18 May 2008
Click to run demo
Recently I've been thinking on ways of programmatically creating curvy, organic-looking shapes in 3D.
High-level recipe:
- Start with a cylinder or sphere-shaped mesh, where the vertices are evenly spaced . The vertices of the mesh can be thought of as a matrix or grid, where the left and right edges are curved 360 degrees until they meet.
- Take an interesting bitmap with varying light and dark areas, whose height and width match the number of rows and columns in the mesh.
- Use brightness (or some other color-derived property) from the pixels of the bitmap as a multiplier value to dictate the distance of the corresponding vertices from the z-axis (center) of the shape.
That's basically it. In Flash, the built-in BitmapData.perlinNoise
method is perfect for generating interesting gradients. The kicker is that the last parameter of the method allows you to change the x & y offset for each 'octave' (think semi-transparent layer), allowing for gradual, random-looking changes over time.
So on each update, change the offset of each octave of the perlin noise image and recalculate the vertices accordingly. The behavior and properties of Perlin noise does the rest.