Ray Tracing Fractal Geometry
Posted 14th March, 2015 in 3D, Design, ScratchPad
A couple of months back, while browsing the site of Ryan Geiss (the guy behind the classic MilkDrop music visualizer for Winamp among other things) I stumbled across Gpucaster, a small program of his that “uses your GPU to quickly render highly-detailed, arbitrary 3D isosurfaces (functions) with semi-realistic lighting (5 point light sources with ambient occlusion)”.
By his own admission, Gpucaster is something Ryan “threw together under the worst conditions possible” and while very capable of generating some beautiful images, it’s also pretty raw and somewhat less than inviting to work with. As is typically the case with these kind of things, various work and study commitments at the time meant that after a brief evening of cursory investigation, Gpucaster found it’s way onto the long neglected list of ‘things to explore in more detail at a later date’.
Then more recently, while on my usual periodic search for new content to try out with the Oculus Rift HMD I came across a ‘demo’ called Foreign Nature by Julius Horsthuis. Intrigued as to how something that looked so much like a ray traced fractal was possibly going to render at the 75hz frame rate required for the Rift, I was initially disappointed to learn it was in fact a non-interactive, pre-rendered 360 degree panoramic video (meaning no real 3D depth or positional tracking).
I went ahead and downloaded the 4K version of the video regardless and after floating through it’s near 10 minute duration in the Whirligig player was quite surprised at how engaging an experience it turned out to be even with it’s limitations. Immediately reminded of my evening spent with Gpucaster, I was curious to learn more about the tools Julius used to create the video. That’s when I came across Mandelbulb 3D.
So what is Mandelbulb 3D? Well, according to Mandelbulb.com…
“Mandelbulb 3D is a free software application created for 3D fractal imaging. Developed by Jesse and a group of Fractal Forums contributors, based on Daniel White and Paul Nylander’s Mandelbulb work, MB3D formulates dozens of nonlinear equations into an amazing range of fractal objects. The 3D rendering environment includes lighting, color, specularity, depth-of-field, shadow- and glow- effects; allowing the user fine control over the imaging effects.”
Like Gpucaster, Mandelbulb 3D provides tools to render some stunning ray traced scenes of mathematically generated 3D geometry. It’s feature set is significantly larger but the accompanying UI, while still a little less than intuitive, remains approachable enough to yield genuinely creative results in a very reasonable amount of time. The images accompanying this post were all created in a single afternoon of initial experiments.
While most aspects of the rendering environment should be somewhat familiar to anyone with a background in 3D graphics, it’s the approach to geometry that differs significantly from a traditional modelling process. This isn’t a blog post about how fractals work (an infinitely fascinating subject in itself …pun intended) but if you have even the slightest interest in the nature of such things, I highly recommend some basic research. Imaginary numbers and the complex plane turn out to be far less intimidating than they sound and with even a basic understanding of what’s happening, it really is hard to walk away without a renewed fascination for the world around you.
For those who don’t wish to dig into details at this point, one way to get some intuition of what’s happening is to look at the brief Wikipedia page on the Menger Sponge, specifically the first section titled Construction. Of key significance here is the final part about iterating ad infinitum where subsequent iterations of a modifying function are fed the output of their previous iteration, forging further self similar detail onto geometry at increasingly smaller scales. The greater the number of iterations, the higher the level of detail at the objects current scale. This is the essence of what you are seeing when you zoom through a two dimensional fractal image, exploring what appears to be infinitely emerging self-similar patterns.
Clearly there’s a lot more to this than I’m attempting to introduce here but hopefully the previous paragraph provides some sense of how very different this approach is to the established geometry building workflows of tools such as Maya or 3ds Max. Mandelbulb 3D comes with a library of fractal formulas to use as starting points, allowing you to modify and combine up to six to iterate with simultaneously. With some careful experimentation you can begin to intuitively generate some obscenely complex geometry but any attempt to fashion pre-conceived shapes of a specific arbitrary nature feels almost entirely impossible. Instead the process is a combination of searching and modifying; exploring the results of combined formulae, then mindfully adjusting their values to refine the output.
This may all sound like fun and certainly results in some intriguing abstract imagery but the more interesting question is, can any aspect of this process be incorporated into a larger creative pipeline? A significant feature of MB3D that I’m yet to mention is the ability to render video as Julius has in Foreign Nature. To plot a course and zoom deep into these worlds of my own making in 360 degree panoramic video is certainly something I’m keen to try but I’m yet to find time to venture into the animation features. I suspect that with a little experimentation, elaborate skyboxes could be created for use in a game engine of choice but as appears to be the case with 360 degree video content, care must be taken to ensure the camera is a significant distance from all surfaces in order to maintain a relatively convincing result when projected that way.
Julius has created a great video that examines the same question of usefulness. He’s primarily approaching the subject from the perspective of VFX as opposed to game development but he does mention the possibility of generating high poly meshes from the resulting geometry, which theoretically could be used to generate normal maps. From a practical point of view I get the feeling that there’s little to exploit here without a lot of re-ordering of other established steps in the pipeline, nevertheless I’m a huge fan of the aesthetic and as and when time permits I plan to continue exploring.