Generation of volumetric escape time fractals

Generation of volumetric escape time fractals

ARTICLE IN PRESS Computers & Graphics 27 (2003) 977–982 Chaos and graphics Generation of volumetric escape time fractals Slawek Nikiel*, Adam Goins...

277KB Sizes 3 Downloads 39 Views

ARTICLE IN PRESS

Computers & Graphics 27 (2003) 977–982

Chaos and graphics

Generation of volumetric escape time fractals Slawek Nikiel*, Adam Goinski ! ! ! Department of Control and Computation Engineering, University of Zielona Gora, ul. Podgorna 50, 65-246 Zielona Gora, Poland

Abstract Aesthetically appealing two-dimensional escape time fractals are often based on complex-function transformations. The same methods of analysis and rendering can be extended to create fractal solids. Methods for generation of these objects very often use quaternion representations for transforming points in three or four dimensions. In this tutorial and artistic statement, we describe a simple yet effective approach for visualizing escape times of general quadratic fractal maps in the third dimension. The approach allows us to automatically generate diverse and beautiful volumetric shapes in real time on currently available personal computers. r 2003 Elsevier Ltd. All rights reserved. Keywords: Iteration; Computer art; Shape geometry; Volume rendering; Multidimensional fractals

1. Introduction This tutorial and artistic statement describes a simple method for automatically producing a wide range of artistically interesting forms. As is well known, the role of 3-D graphics is becoming increasingly important in the world of personal computers. Almost all modern operating systems provide graphics drivers and a set of low-level application programming interfaces (APIs) for creating advanced 3-D graphics. Increasingly, advanced 3-D graphics cards are continually being created by hardware companies. Also, a 3-D graphics engine is a vital part of a virtual reality system, a computer environment likely to be pervasive in the near future. In the paper, we present a new shape modeler of complex 3-D objects. As is well known, fractal modeling can yield a diversity of shapes that are stunningly beautiful and similar to natural patterns [1,2]. The method presented in the paper is based upon the idea of the automated fractal art generators, previously advanced by Sprott and Pickover [3]. Here, we extend the concept to higher dimensions and fractal solids. As in two-dimensional sets of nonlinear functions, in 3-D we *Corresponding author. E-mail addresses: [email protected] (S. Nikiel), adam [email protected] (A. Goinski).

will select artistically intriguing forms from a virtually infinite set of possible solids. In particular, we often enjoy exploring visually interesting shapes either similar to natural phenomena or that present unique geometries. The approach here may be extended to a wide range of applications, including real-time computer graphics (e.g. computer games), 3-D modelers (e.g. software like 3-D Studio Max), and geometry compression.

2. General three-dimensional quadratic fractal maps The implementation of escape time fractals relies on iterative mathematical calculations. In particular, the method is based on monitoring the number of iterations necessary to determine whether an orbit sequence tends to infinity or not. One of the most popular approaches is to use nonlinear equations with chaotic solutions. The solutions are most interesting if they involve at least two variables x and y, which can be used to represent horizontal and vertical positions on a graphics screen. With complex numbers, used in equations where x and y are elements of the complex number z, the simplest and most popular equation used as an example is z ¼ z2 þ c; where c is a complex constant. This way we can render the most popular escape-time fractals such as

0097-8493/$ - see front matter r 2003 Elsevier Ltd. All rights reserved. doi:10.1016/j.cag.2003.08.013

ARTICLE IN PRESS 978

S. Nikiel, A. Goinski / Computers & Graphics 27 (2003) 977–982

Mandelbrot and Julia sets [4]. Interestingly, these kinds of fractals have become so popular that interactive fractal presentation and magnification is now possible on cell phones equipped with the Java-language programming environment. One such example is mFrac, a distributed fractal explorer for mobile devices such as phones and PDAs. Developed by Maxence Bernard, mFrac’s supported platform is the J2MEt (Javat 2 Platform, Micro Edition) plus MIDP (Mobile Information Device Profile). More information can be obtained at http://mu-j.com/mufrac/. mFrac uses a distributed architecture to deliver fractals to mobile devices using the HTTP protocol. Fractals are generated remotely by the mFrac fractal server. The traditional complex functions used to create appealing fractal graphics can be extended to higher dimensions to make fractal surfaces and solids. The most popular methods for generation of fractal solids use quaternion representations for transformations of points in three- and fourdimensional spaces. A quaternion has four components, one real part and three imaginary parts [5]. Also, a commutative generalization of complex numbers called bicomplex numbers has been successfully applied to generating aesthetically pleasing three- and four-dimensional fractals [6]. From our observations, a combination of linear and quadratic functions may be used to produce fractal forms with a beautiful and visually balanced shape. Therefore, we decided to extend previous methods [3] to the third dimension. The authors of the 2-D algorithm observed that visually appealing fractals often occur when the orbit ‘‘slowly’’ escapes to infinity. The same rule can be applied to solids. In a similar manner, we start by choosing 30 coefficients of the generalized function (Function 1), limiting ourselves to the simplest (at most quadratic) nonlinearities. Our goal is to automatically and efficiently produce visually interesting structures. The coefficients axx are chosen randomly over the range 1.2–1.2 with increments of 0.1. To simplify our nomenclature and for quick reference, each number is represented as a letter of the alphabet (A ¼ 1:2; B ¼ 1:1; through Y ¼ 1:2): 2

3. The application

2

xnew ¼ a00 þ a01 x þ a02 y þ a03 z þ a04 x þ a05 y þ a06 z2 þ a07 xy þ a08 xz þ a09 yz;

ynew ¼ a10 þ a11 x þ a12 y þ a13 z þ a14 x2 þ a15 y2 þ a16 z2 þ a17 xy þ a18 xz þ a19 yz; znew ¼ a20 þ a21 x þ a22 y þ a23 z þ a24 x2 þ a25 y2 þ a26 z2 þ a27 xy þ a28 xz þ a29 yz:

the escape time at certain position in three-dimensional space. This can be viewed directly as a set of points or as particles with a volumetric element assigned to each point with a selected escape time. As is well known, it is possible to apply isosurface generation algorithms to data such as this in order to obtain a surface of polygons. Representation of three possible ways to visualize fractal volumes is depicted in Figs. 1–5. Volumetric objects straightforwardly represented by points in space require huge amounts of memory to achieve very fine resolution of rendered images. (For instance, a SVGA quality rendering with antialiasing and supersampling would require approximately 8 GB of memory—a 1000  1000  1000 set of 8 point voxel with 1 byte color. By using the term ‘‘8 point voxel’’, I mean that each depicted voxel consists of 8 smaller parts necessary for super sampling.) Such representations also present challenges when lighting and shadows are determined. However, it is possible to render lowerquality fractal solids in real time on currently available personal computers. The isosurface extraction algorithm can be applied to reduce the volumetric resolution to meet the real-time criteria. The well-known ‘‘marching cubes algorithm’’ can extract the isosurfaces where the ‘‘densities’’ are the same. In our case, the densities are escape time values. The method divides space into a regularly spaced grid. It then considers each cube in the grid, ‘‘marching’’ through the space one after another. It evaluates the field at each vertex of the cube. If the isosurface passes through the cube, then it is relatively simple to identify inside and outside vertices and to construct a set of triangles approximating the isosurface [7]. The algorithm is very fast and can handle shapes with caves and holes, which is particularly important in the case of fractal objects. However, it generates a huge number of triangles for a given surface regardless of its geometrical complexity. The approach can produce almost the same number of triangles for a flat surface and for a very complex surface over the same area.

ð1Þ

As illustrated in the pseudocode in Table 1, the function is iterated with initial conditions x, y, z chosen from the volume R3. The output of the algorithm is a volumetric cloud of points with values corresponding to

The main program is written in C++ using Win32 API and the DirectX 8.1 interface. The rapid visualization requires a second-generation 3-D accelerator because we desire ‘‘multi-texturing’’ in a single pass. Real-time generation and modification of fractal objects is one of the main purposes of our research. Furthermore, we take special care about saving and recreating volume objects based on the convenient n-letter code described in the previous section. We think users of this approach may enjoy saving such codes and exchanging them with colleagues for artistic and other evaluation. For a three-dimensional fractal, only 30 chars are needed to save and recreate the object in any volume

ARTICLE IN PRESS S. Nikiel, A. Goinski / Computers & Graphics 27 (2003) 977–982

979

Table 1 Pseudocode for computation {Pseudocode illustrate method for generating EscapeTime fractals} {built with ‘‘3-D points’’} program fractals; const MaxColors=80; {Numbers of layers in 3-D} { variables } var x, y, z : Real; a : array [0..29] of Real; fDimX, fDimY, fDimZ : Real; iSizeX, iSizeY, iSizeZ : Integer; fScaleX, fScaleY, fScaleZ : Real; n : Integer; iKernelColor : Integer;

iMaxBound : Integer; fMaxSolution : Real; { Calculate current solution for x, y and z. Increment. } procedure AdvanceXY; var xnew, ynew : Real; begin xnew:¼a[0]+xa[1]+ya[2]+za[3]+ xxa[4]+yya[5]+zza[6]+ xya[7]+xza[8]+yza[9]; ynew:¼a[10]+xa[11]+ya[12]+za[13]+ xxa[14]+yya[15]+zza[16]+ xya[17]+xza[18]+yza[19]; z:¼a[20]+xa[21]+ya[22]+za[23]+ xxa[24]+yya[25]+zza[26]+ xya[27]+xza[28]+yza[29]; x:¼xnew; y:¼ynew; n:¼n+1; end; { Generates points of fractal. Display. } procedure GeneratePoints; var k, i, j : Integer; fScreenX, fScreenY, fScreenZ : Real; begin fWidthDiv:¼iWidth/fScaleX; fHeightDiv:¼iHeight/fScaleY; fDepthDiv:¼iDepth/fScaleZ; for k:¼0 to iSizeZ do for i:¼0 to iSizeX do for j:¼0 to iSizeY do begin x:¼fDimX+i/fWidthDiv; y:¼fDimYj/fHeightDiv; z:¼fDimZk/fDepthDiv; n:¼0; while (noMaxColors) and ((xx+yy+zz)ofMaxSolution) do AdvanceXY; { render only one layer of fractal } if n=iKernelColor then begin

{ current point in fractal space } { fractal code (fractal coefficients) } { dimensions of fractal space (e.g.=8.0f) } { e.g.=300, 3D dimensions of solid } { scales of dimensions (e.g.=4.0f) } { a color/layer of a point } { a threshold color; i.e. the number of the first visible layer of a fractal (e.g.=5). Layers are numbered from 0 } { e.g.=1000 } { e.g.=1000000.0f }

ARTICLE IN PRESS S. Nikiel, A. Goinski / Computers & Graphics 27 (2003) 977–982

980 Table 1 (Continued.)

{ put point on screen in 3D space (centering it) } fScreenX:¼i–iSizeX  0.5; fScreenY:¼j–iSizeY  0.5; fScreenZ:¼kiSizeZ  0.5; PutPoint3D( fScreenX, fScreenY, fScreenZ ); end; end; end; { Set parameters of a fractal (from 1.2 to 1.2). Prepare fractal environment } procedure SetParams; var i : Integer; begin x:¼0; y:¼0; z:¼0; { randomly chosen parameters } For i:¼0 to 30 do a[i]:¼(random(25)12 )/10.0; end; { Test the solution. See Pickover and Sprott for details } procedure TestSoln; begin If n=iMaxBound then n:¼0; { solution is bounded } if ( xx+yy+zz )>fMaxSolution then { solution escaped } begin if n>100 then n:¼iMaxBound else n:¼0; end; end; begin randomize; { set some initial values } iSizeX :¼100; iSizeY :¼100; iSizeZ:¼100; fDimX:¼8.0; fDimY :¼8.0; fDimZ:¼8.0; fScaleX:¼4.0; fScaleY:¼4.0; fScaleZ:¼4.0; n:¼0; iKernelColor:¼6; iMaxBound:¼1000; fMaxSolution:¼1000000.0; { main loop } repeat if n=0 then SetParams; AdvanceXY; TestSoln; if n=iMaxBound then begin GeneratePoints(); n:¼0; { draw fractal } end; until keypressed; { loop until a key is pressed } end.

resolution, in any form and any time. Those fractals are purely deterministic. We also desire to show the separated isosurface layers of fractals we create. These layers correspond to different escape times, and outer layers correspond to longer escape times. In high resolutions, the top and middle layers exhibit beautiful visual effects and very

interesting shapes. We may think of every layer of a given fractal generating a new one without changing the parameters. The application and the general idea are both under development. Four-dimensional objects and new methods of texture mapping are especially interesting to us. In Figs. 1–5, we present sample screenshots taken from the working application.

ARTICLE IN PRESS S. Nikiel, A. Goinski / Computers & Graphics 27 (2003) 977–982

Fig. 1. A 3-D fractal based on points. (Resolution: 80  80  80, about 10,000 points) code: EJWLGYVWHMPSJR WMEJKQLMHECLQGNF.

Fig. 2. A 3-D fractal based on particles. (Resolution: 140  140  140, about 40 K of particles) code: DOCPUFMAHJRMOQGPKURROPMHJLDQWH.

4. Performance Good performance is a desired goal of real-time applications. As far as real-time rendering is concerned, the particle-based fractal comprised about 3.5 million points (the fractal was generated in 300  300  300 volumetric resolution and was rendered in real time on a GeForce2 with a P3 processor). On the other hand, the 3-D modeler based on polygons (using the ‘‘marching cubes’’ algorithms) has a slightly worse performance,

981

Fig. 3. 3-D fractal based on textured polygons with light map. (Resolution: 100  100  100, about 124 K of faces) code: GMQKKBYNHMLJHPOPMBGUNHMOOAOWTH.

Fig. 4. 3-D fractal based on textured polygons with light map. (Resolution: 100  100  100, about 90 K of faces) code: GNMKQTVYUYJFRXTQNSKUDJGKKLSAFM.

but still meets real-time requirements. Hence, the time required to initially generate a fractal is proportional to the size of a volumetric space, but, once the data is computed, it can be rendered with a huge amount of polygons on any modern 3-D accelerator. During the tests, the average amount of triangles required was about 15,000 in the 80  80  80 volumetric space. Obviously, the particle-based fractals need a larger mesh to achieve a more striking visual effect than polygonbased ones. This is due to surface approximation of

ARTICLE IN PRESS 982

S. Nikiel, A. Goinski / Computers & Graphics 27 (2003) 977–982

or dust-like appearances. The fractal generator can also serve as a tool for modeling complex amorphous shapes. Our future work will focus on extension of the method to higher dimensions. We also hope to create a system in which the computer can automatically scan a huge number of forms and select those predicted to have greatest aesthetical appeal, using methods similar to those reported by Pickover and Sprott [8,9]. Also, more efficient isosurface generation algorithms will be applied along with the triangle mesh optimization. Another interesting challenge to consider is accurate texture mapping on such amorphous objects. We would like to apply wood and marble textures to such objects and would enjoy hearing from artists who have successfully created such objects using the initial methods described in this paper. Fig. 5. 3-D fractal based on textured polygons with light map. (Resolution: 100  100  100, about 26 K of faces) code: NDKTJKDNFNMSMAEPAVKUMDAYQOPARJ.

References triangles in the second case. We hope to gain better performance by using SSE instructions and different algorithms for creating a polygonal surface. (SSE stands for Streaming SIMD Extensions, used for enhancing the performance of media applications.)

5. Conclusion The method described in the paper is simple and sufficiently efficient to run in real time using personal computers. General quadratic mappings, when extended to the third dimension, produce a wide range of visually striking objects. From our observations, the most visually interesting forms are relatively smooth and have balanced (symmetrical) shapes. Viewers should note that the 3-D forms, resulting from a combination of linear and quadratic functions, can have smooth, rough,

[1] Mandelbrot B. The fractal geometry of nature. New York: Freeman; 1993. [2] Barnsley MF. Fractals everywhere. New York: Academic Press; 1988. [3] Sprott JC, Pickover CA. Automatic generation of general quadratic map basins. Computers and Graphics 1995;19(2):309–13. [4] Peitgen HO, Richter PH. The beauty of fractals: images of complex dynamical systems. New York: Springer; 1986. [5] Gomatarn J, et al. Generalization of the Mandelbrot set: quaternionic quadratic maps. Chaos, Solitons and Fractals 1995;5:971–85. [6] Rochon D. A generalized Mandelbrot set for bicomplex numbers. Fractals 2000;8(2):355–68. [7] Montani C, Scateni R, Scopigno R. Discretized marching cubes. Visualization ’94 Proceedings. Silverspring, MD: IEEE Computer Society Press, 1994. p. 281–7. [8] Pickover C. Keys to infinity. New York: Wiley; 1995. [9] Pickover C. Chaos in wonderland. New York: St. Martin’s Press; 1994.