I keep forgetting that I made this and I think it's because I struggled with this one way more than the Mandelbulb. Naively I thought, "Hey, the Mandelbulb was easier to make than I thought. Why not try a Mandelbox?". Oh, boy was I wrong. It took numerous iterations and trial and error before I figured out what was going wrong. And here I layout for you all the fruits of my labour, pain-free. You're welcome.
I started with the basic pseudocode off of Wikipedia which produced an ugly stack of if statements. At some point, I found someone on the fractalforums who'd cut it down to a single line with a clamp function and testing that out in Houdini turned out to be successful. Two features of a Mandelbox involve a 'box fold' and 'sphere fold' to get the correct shapes. minR2 is the squared minimum radius of your sphere, and fxdR2 is the squared fixed radius of that sphere. r is the length of your vector. When you generate your channels in the wrangle, if you want to get the same scale-2 Mandelbox in the image below you'll want to set scale to 2 and iterations to 7.
Now, what you'll want to do is make sure you have the right options laid out for your VDB. This is where most of my trouble was coming from, I believe. I created a 12x12x12 cube, piped it into a bound and then used a vdb from polygons. I set my voxel size to 0.015(I do not recommend this to begin with. Start with something higher.), ticked for a surface VDB and named it 'stuff'. You want to check fill interior and then pipe the vdb into a wrangle. This is my VEX code:
If you use a convertvdb to convert to polygons the sweet spot for the Isovalue is around 0.035. For the render setup, I generally just use a camera, an environment light and an additional three-point light setup if I feel that I need to highlight some areas. Here is a screenshot from my viewport:
Overall, the result isn't bad. It's very slow and the detail is a little undefined in some areas but the shape isn't awful considering we're using software that isn't made for fractal generation. The general shape is correct at least. Save often! I managed to crash Houdini a few times testing different isovalues.
I hope this tutorial helps you. Unlike the Mandelbulb, there don't seem to be any tutorials online about how to make a Mandelbox in Houdini so I hope my experiments give you a good starting point at the very least. You can go beyond my version by testing out other values for scale, iterations and changing the values around in the code. It would be cool to see what you guys come up with, especially if you find any way of optimising this thing.
Again, Wikipedia, Syntopia and the fractalforums were the most useful resources I found as well as this page at Mark Craig's blog. If you would like to send me an email ping me at this address: steambeanblog@gmail.com. Comment and subscribe(yes, you can do that now) so you can get notifications about new stuff on the blog.
Take care and stay safe,
- Kat