I think we can all agree that this looks pretty bloody amazing:
That’s because this week I tackled something I’ve been wanting to explore for years: creating fractal trees. I’ve always been fascinated by fractal graphics, ever since the early days of grinding out the Mandlebrot Set pixel by pixel on a BBC Micro in a dizzying eight colours. And one branch – if you’ll pardon the expression – of fractal graphics is fractal trees. Using a few simple rules, recursively, it’s possible to create startlingly natural-looking vegetation. Once you know that, it’s very hard to look at plants and trees in the real world without noticing how they’re all made out of simple patterns recurring at different scales.
As I say, it’s something I’ve wanted to explore for years, but it’s only recently that I’ve had a platform on which to do so: my game engine. (Which I really should find a cooler name for than “my game engine”.) It turned out to be surprisingly easy to set up. In almost no time at all I had a little C++ class that made wireframe trees by recursively splitting branches into sub-branches, the sort of thing you’ve probably seen before:
Then I added a function for creating solid 3D geometry, and got results like this:
Finally, I added routines to temper the symmetry with randomisation, and a sample that had previously looked like a piece of broccoli turned into this:
Isn’t that brilliant? And there are about 50 million more where that came from, because it’s all based on a random number seed. That’s what 740608 looks like, in case you were wondering.
I was so pleased with the result, and it was so near the end of the working week, that I almost left it there. But I just couldn’t resist seeing what would happen if I plugged my trees into the instanced drawing system I’d used to cover my procedural terrain with grass. Amazing scenes, that’s what happened. I’d totally forgotten that left to its own devices, my game engine colours every model differently, according to a simple algorithm for creating harmonic palette sequences. It’s like something out of The Magic Roundabout. Take a look.