GLSL 3D Fractals Series
3D fractals represent some of the most visually stunning and mathematically fascinating objects in computer graphics. This series explores how to render these infinite structures in real-time using GLSL shaders, combining ray marching with distance estimation to create breathtaking visualizations.
Series Overview
Each article in this series:
- Explains the mathematical foundation of a 3D fractal
- Provides interactive shader examples you can modify in real-time
- Demonstrates ray marching techniques for efficient rendering
- Shows optimization strategies for real-time performance
Articles in This Series
Classic 3D Fractals
-
Mandelbulb - The 3D extension of the Mandelbrot set. Explore infinite detail in a bulbous, organic structure using spherical coordinates and power iterations.
-
Quaternion Julia Sets - 4D quaternion fractals projected into 3D space. Discover swirling, organic forms with complex rotational symmetries.
-
Menger Sponge - The 3D generalization of the Sierpinski carpet. A recursive geometric fractal with infinite surface area and zero volume.
-
Mandelbox - A box-folded fractal combining sphere inversion with scaling. Creates intricate geometric patterns with sharp edges and smooth curves.
Geometric Fractals
-
Sierpinski Tetrahedron - The 3D version of the Sierpinski triangle. Recursive tetrahedral subdivision creating a fractal with fascinating self-similarity.
-
3D IFS Fractals - Iterated Function Systems in 3D space. Create complex organic and geometric forms through affine transformations.
Advanced Techniques
-
Distance Estimation Methods - Techniques for efficiently computing distances to fractal surfaces. Essential for fast ray marching.
-
Hybrid Fractals - Combining multiple fractal formulas to create new structures. Explore the creative possibilities of fractal composition.
Why 3D Fractals?
3D fractals are:
- Visually stunning: Infinite detail and organic beauty
- Mathematically rich: Deep connections to complex analysis, topology, and chaos theory
- Computationally fascinating: Require clever algorithms for real-time rendering
- Artistically inspiring: Used in films, games, and digital art
Ray Marching for Fractals
All fractals in this series use ray marching with distance estimation:
- Distance Estimation: Compute an approximate distance from any point to the fractal surface
- Ray Marching: Step along rays using the distance estimate for efficient traversal
- Surface Detection: When close enough, calculate normals and lighting
- Optimization: Use bounding spheres, early termination, and adaptive step sizes
Interactive Examples
All articles include interactive 3D shader examples using the <GLSLIDE> component. You can:
- Modify parameters in real-time and see results instantly
- Adjust camera angles with mouse movement
- Explore the fractal by zooming and rotating
- Experiment with different formulas and parameters
Interactive Previews
Click the buttons below to switch between different fractal demos. Only one demo runs at a time for optimal performance:
Mathematical Foundations
Complex Numbers → Quaternions
2D fractals use complex numbers: z = a + bi
3D fractals extend to quaternions: q = w + xi + yj + zk
Distance Estimation
For fractals defined by iteration z_{n+1} = f(z_n), the distance estimate is:
d ≈ |z_n| * log(|z_n|) / |z'_n|
Where z'_n is the derivative of the iteration.
Ray Marching Algorithm
float raymarch(vec3 ro, vec3 rd) {
float t = 0.0;
for (int i = 0; i < maxSteps; i++) {
vec3 p = ro + rd * t;
float d = distanceEstimate(p);
if (d < epsilon) return t; // Hit
t += d;
if (t > maxDist) break; // Miss
}
return -1.0;
}
Performance Optimization
Rendering 3D fractals in real-time requires optimization:
- Bounding spheres: Skip empty space quickly
- Adaptive step sizes: Larger steps in empty regions
- Early termination: Stop when close enough or too far
- Level of detail: Reduce iterations for distant objects
References
Academic Papers
- "The Mandelbulb: First 'True' 3D Image of the Mandelbrot Set?" by Daniel White and Paul Nylander
- "Distance Estimation Method for Rendering 3D Fractals" by Inigo Quilez
- "Quaternion Julia Sets" by John C. Hart et al.
Online Resources
- Inigo Quilez - Distance Estimation
- Fractal Forums - Community discussions
- Mandelbulb.com - Gallery and resources
Related Series
- Graphics Gems GLSL Series Index - Classic graphics algorithms
- Introduction to GLSL and Shaders - GLSL fundamentals