Daniel Gray

Thoughts, Notes, Ideas, Projects

Contact

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

  1. Mandelbulb - The 3D extension of the Mandelbrot set. Explore infinite detail in a bulbous, organic structure using spherical coordinates and power iterations.

  2. Quaternion Julia Sets - 4D quaternion fractals projected into 3D space. Discover swirling, organic forms with complex rotational symmetries.

  3. Menger Sponge - The 3D generalization of the Sierpinski carpet. A recursive geometric fractal with infinite surface area and zero volume.

  4. Mandelbox - A box-folded fractal combining sphere inversion with scaling. Creates intricate geometric patterns with sharp edges and smooth curves.

Geometric Fractals

  1. Sierpinski Tetrahedron - The 3D version of the Sierpinski triangle. Recursive tetrahedral subdivision creating a fractal with fascinating self-similarity.

  2. 3D IFS Fractals - Iterated Function Systems in 3D space. Create complex organic and geometric forms through affine transformations.

Advanced Techniques

  1. Distance Estimation Methods - Techniques for efficiently computing distances to fractal surfaces. Essential for fast ray marching.

  2. 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:

  1. Distance Estimation: Compute an approximate distance from any point to the fractal surface
  2. Ray Marching: Step along rays using the distance estimate for efficient traversal
  3. Surface Detection: When close enough, calculate normals and lighting
  4. 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

Related Series

Related Content

GLSL 3D Fractals - Mandelbulb

GLSL 3D Fractals - Mandelbulb The Mandelbulb is the 3D extension of the classic Mandelbrot set, discovered by Daniel White and Paul Nylander in 2009. It creates stunning organic, bulbous structures wi...

GLSL 3D Fractals - Quaternion Julia Sets

GLSL 3D Fractals - Quaternion Julia Sets Quaternion Julia sets extend the classic 2D Julia sets into 4D space using quaternion algebra, then project them back into 3D for visualization. The result is ...

GLSL 3D Fractals - Menger Sponge

GLSL 3D Fractals - Menger Sponge The Menger Sponge is the 3D generalization of the Sierpinski carpet, discovered by Karl Menger in 1926. It's a fascinating geometric fractal with paradoxical propertie...

GLSL 3D Fractals - Mandelbox

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 geometri...

GLSL 3D Fractals - Sierpinski Tetrahedron

GLSL 3D Fractals - Sierpinski Tetrahedron The Sierpinski Tetrahedron is the 3D generalization of the classic Sierpinski triangle. It's created by recursively subdividing a regular tetrahedron, removin...

GLSL 3D Fractals - 3D IFS Fractals

GLSL 3D Fractals - 3D IFS Fractals Iterated Function Systems (IFS) are a powerful method for generating fractals using affine transformations. In 3D, IFS fractals can create stunning organic and geome...

Scroll for more posts(4 more available)