GLSL 3D Fractals - Mandelbox
The Mandelbox is a fascinating 3D fractal discovered by Tom Lowe in 2010. It combines sphere inversion with box folding and scaling operations, creating intricate geometric patterns with both sharp edges and smooth curves. Unlike the Mandelbulb, the Mandelbox uses a different folding technique that produces more angular, architectural structures.
Interactive Demo
Move your mouse to rotate the camera and explore the Mandelbox. Scroll to adjust the scale parameter and see how it changes the fractal structure:
Mathematical Foundation
Box Folding
The Mandelbox uses a box folding operation that folds space around a cube:
vec3 boxFold(vec3 z) {
for (int i = 0; i < 3; i++) {
if (z[i] > 1.0) z[i] = 2.0 - z[i];
else if (z[i] < -1.0) z[i] = -2.0 - z[i];
}
return z;
}
Sphere Inversion
After folding, the Mandelbox applies sphere inversion:
float sphereRadius = 1.0;
if (length(z) < sphereRadius) {
z = z * (sphereRadius * sphereRadius) / dot(z, z);
}
Scaling and Iteration
The complete Mandelbox iteration combines folding, inversion, and scaling:
Where:
- boxFold: Folds space around a cube
- sphereFold: Inverts space inside a sphere
- scale: Typically around 2.0, controls the fractal's detail level
- c: The constant point being tested
Distance Estimation
The distance estimate for the Mandelbox uses the derivative of the iteration:
Where is the derivative accumulated during iteration.
Key Parameters
Scale Parameter
The scale parameter controls the fractal's detail:
- scale < 2.0: Creates more compact, detailed structures
- scale = 2.0: Classic Mandelbox
- scale > 2.0: More open, less detailed structures
Fixed Radius
The fixed radius for sphere inversion affects the smoothness:
- Smaller radius: More angular, box-like structures
- Larger radius: Smoother, more organic curves
Min Radius
The minimum radius prevents division by zero and controls the inversion strength.
Visual Characteristics
The Mandelbox exhibits:
- Geometric precision: Sharp edges and corners from box folding
- Organic curves: Smooth transitions from sphere inversion
- Infinite detail: Self-similar structures at all scales
- Architectural beauty: Reminiscent of impossible geometry
Implementation Details
The GLSL implementation uses:
- Ray marching with distance estimation
- Efficient iteration with early termination
- Normal calculation using finite differences
- Adaptive step sizes for performance
References
- "Mandelbox" by Tom Lowe - Original discovery
- Fractal Forums - Mandelbox Discussion
- Inigo Quilez - Distance Estimation
Related Articles
- Mandelbulb - Spherical coordinate fractals
- Distance Estimation Methods - Techniques for efficient rendering
- GLSL 3D Fractals Series