off
ikonic>
OUT 0 B

Glass

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 geometric forms, from ferns and trees to complex geometric structures. The technique applies a set of transformations iteratively, with each transformation having a probability of being applied.

Interactive Demo

Move your mouse to rotate the camera and explore the IFS fractal. Scroll to adjust parameters and see how the structure evolves:

Mathematical Foundation

Affine Transformations

An affine transformation in 3D combines:

  • Rotation: $R \in \mathbb{R}^{3 \times 3}$
  • Scaling: $s \in \mathbb{R}$
  • Translation: $\mathbf{t} \in \mathbb{R}^3$

The transformation is:

$$\mathbf{x}_{n+1} = s \cdot R \cdot \mathbf{x}_n + \mathbf{t}$$

IFS Definition

An IFS consists of $N$ transformations $\{T_1, T_2, \ldots, T_N\}$, each with:

  • A transformation matrix $M_i$
  • A translation vector $\mathbf{t}_i$
  • A probability $p_i$ (for random IFS)

Deterministic IFS

In deterministic IFS, all transformations are applied:

$$\mathbf{x}_{n+1} = T_i(\mathbf{x}_n) \quad \text{for all } i$$

The fractal is the union of all transformed copies.

Random IFS

In random IFS, transformations are chosen probabilistically:

$$P(T_i) = p_i \quad \text{where } \sum_{i=1}^{N} p_i = 1$$

Distance Estimation

For IFS fractals, we can estimate distance by finding the minimum distance to any transformed copy:

$$d(\mathbf{p}) = \min_i \left\{ d(T_i^{-1}(\mathbf{p})) \cdot s_i \right\}$$

Where $s_i$ is the scale factor of transformation $i$.

Classic IFS Examples

Sierpinski Triangle (2D → 3D)

The 3D Sierpinski triangle uses three transformations:

$$T_1(\mathbf{x}) = \frac{1}{2}\mathbf{x} + \begin{pmatrix} 0 \\ 0 \\ 0 \end{pmatrix}$$
$$T_2(\mathbf{x}) = \frac{1}{2}\mathbf{x} + \begin{pmatrix} 0.5 \\ 0 \\ 0 \end{pmatrix}$$
$$T_3(\mathbf{x}) = \frac{1}{2}\mathbf{x} + \begin{pmatrix} 0.25 \\ 0.433 \\ 0 \end{pmatrix}$$

Barnsley Fern (3D Extension)

The famous Barnsley fern can be extended to 3D:

$$T_1(\mathbf{x}) = \begin{pmatrix} 0 & 0 & 0 \\ 0 & 0.16 & 0 \\ 0 & 0 & 0 \end{pmatrix}\mathbf{x}$$
$$T_2(\mathbf{x}) = \begin{pmatrix} 0.85 & 0.04 & 0 \\ -0.04 & 0.85 & 0 \\ 0 & 0 & 0.9 \end{pmatrix}\mathbf{x} + \begin{pmatrix} 0 \\ 1.6 \\ 0 \end{pmatrix}$$

3D Spiral IFS

A 3D spiral IFS creates organic, twisting forms:

$$T_i(\mathbf{x}) = R_z(\theta_i) \cdot R_y(\phi_i) \cdot S(s_i) \cdot \mathbf{x} + \mathbf{t}_i$$

Where $R_z$ and $R_y$ are rotation matrices, and $S$ is a scaling matrix.

Implementation Details

The GLSL implementation uses:

  • Ray marching with distance estimation
  • Iterative transformation application
  • Minimum distance calculation across all transformations
  • Normal calculation using finite differences

Key Parameters

Transformation Count

The number of transformations affects:

  • Complexity: More transformations = more detail
  • Performance: More transformations = slower rendering
  • Shape: Different transformations create different forms

Scale Factors

Scale factors control:

  • Self-similarity: Smaller scales = more detail
  • Convergence: Scales < 1.0 ensure convergence
  • Structure: Different scales create different patterns

Probabilities (Random IFS)

In random IFS, probabilities control:

  • Density: Higher probability = more points
  • Shape: Different probabilities emphasize different regions
  • Organic appearance: Non-uniform probabilities create natural forms

Visual Characteristics

3D IFS fractals exhibit:

  • Organic beauty: Natural, plant-like structures
  • Geometric precision: Mathematical perfection
  • Infinite detail: Self-similar at all scales
  • Variety: Can create vastly different forms

References

  • "Fractals Everywhere" by Michael Barnsley
  • "The Algorithmic Beauty of Plants" by Prusinkiewicz and Lindenmayer
  • IFS Fractals

Related Articles