*Mathematics
of Height
Field Fractals*

Most of the common fractal types used by fractal artists are 2-dimensional objects in the complex plane. See Mathematics of Divergent Fractals for a brief discussion on complex arithmetic. Typically the fractal is iterated at each point in the plane until the bailout criteria are reached. A third dimension can be created by using the iteration value, some function of the iteration value, the magnitude of the fractal or some function of the magnitude, or, if an orbit trap coloring method is being used, some function of the orbit trap distance.

3-Dimensional rendering needs to create the surface that depends upon the complex value in the plane and the height value. This surface is rarely smooth, and usually has discontinuities around every pixel position. The rendering method must also be able to handle the multitude of hidden surfaces objects of this type usually have. If the image is colored by the distance from some fixed point to the surface, and the coloring algorithm has a shallow gradient, a satisfactory or interesting coloring of the surface can usually be obtained. Artistic flexibility would be quite limited, however.

The most flexible approach to surface rendering, which also handles the hidden surface removal problem, is to use raytracing. Raytracing is a process to provide realistic lighting, perspective and hidden surface removal effects to a scene. A raytracer includes includes a camera (or eye) and one or more light sources. The raytrace process can be envisioned as the shooting of rays from the camera to the objects in the scene. The raytracer uses the distance to the intersection point, the surface normal at the intersection point, and the angle and intensity of the light source(s) to determine the coloring at the intersection point. Precise mathematical formulas exist for calculating these parameters for regular solids such as spheres, planes, cubes, etc. To deal with a general curved surface, the surface is often approximated by a mesh of triangles. Precise equations are available for calculating the intersection points, normals, etc for ray-triangle intersections. The triangle approach has the limitation that it doesn't produce a smooth surface.

Raw Triangles |

Simulation of a smooth surface is carried out using Phong shading. With Phong shading the following is done. Each point or vertex within the mesh is shared by six triangles (except for the edges). An average normal is calculated for each vertex, which is the average of the normals of the six triangles. When a ray intersects one of the triangles in the mesh, the value of the normal at the intersection point would normally be the normal of the triangle. With Phong shading a different value is used. It is the interpolated normal from the average normals at the three vertices of the triangle. Phong shading also has an additional factor called specular lighting, which simulates the shiny spots that are seen on smooth surfaces.

Phong Shading |

With raytracing the distance coloring mode colors by the distance from the camera to the triangle intersection using raw triangles.

Distance Coloring |

The height value coloring mode uses the unrotated height value which is mapped to a color, and an algorithm similar to Phong shading called Gouraud shading. The color value used at the intersection point in the triangle is the interpolated value from the color values at each of the triangle vertices.

Height Value Coloring |

There are a number of approaches to creating height values.

**Height values based upon iteration number**

The simplest case is to use the iteration number itself. This will typically produce banding, or steps in the 3D object, as can be seen in the following image. The Phong shading method smooths the steps out somewhat, but they are still clearly visible.

Iteration Height Value |

Fractal artists have developed a number of algorithms to give a smoothed iteration count which, when used as the height value, will give a surface without steps. The methods include exponential smoothing, general smoothing and Vepstas/Härkönen smoothing. The following image uses general smoothing.

General Smoothing Height Value |

**Height values based upon fractal magnitude**

The height value used in this case is the magnitude of the fractal. In order for the magnitude to create a surface similar to that created by functions of the iteration number, it is transformed as follows:

height = tanh(1/magnitude)

Height values from the fractal magnitude give banding, or steps, similar to what is observed with the simple iteration value as the height value.

Magnitude Height Value |

**Height values based upon orbit trap distances**

As a fractal is iterated the complex value of the fractal forms an orbit in the complex plane. Orbit trapping is a process where the orbit is compared to some function (even a simple point can serve as the function) and the distance between the orbit and the function is calculated. There are a variety of criteria that can be used to pick a distance to used for coloring or for a height value. In the image below the function used is the bifolium function and the distance chosen to use as the height value is the closest approach between the orbit and the function.

Trap Height Value |